babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045
  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/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @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
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * 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".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * 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"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * 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)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * 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
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. 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;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. 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;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * 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"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * 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".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * 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"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * 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".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** 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 */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** 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 */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** 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 */
  4100. static readonly GEQUAL: number;
  4101. /** 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 */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * 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.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. 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;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** 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 */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * 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.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. 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;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. 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;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. 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;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. 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);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * 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;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * 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).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * 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).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * 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.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * 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.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * 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.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * 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.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * 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.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * 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).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * 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).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * 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.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * 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.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * 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.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * 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.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * 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.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * 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).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * 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).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * 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.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * 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.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * 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.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * 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.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * 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.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * 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.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * 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).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * 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).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * 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.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * 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.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * 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.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * 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.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * 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.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * 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)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @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.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * 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.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * 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
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @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
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @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
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /**
  11559. * An event triggered when the manager is disposed.
  11560. */
  11561. onDisposeObservable: Observable<SpriteManager>;
  11562. private _onDisposeObserver;
  11563. /**
  11564. * Callback called when the manager is disposed
  11565. */
  11566. onDispose: () => void;
  11567. private _capacity;
  11568. private _spriteTexture;
  11569. private _epsilon;
  11570. private _scene;
  11571. private _vertexData;
  11572. private _buffer;
  11573. private _vertexBuffers;
  11574. private _indexBuffer;
  11575. private _effectBase;
  11576. private _effectFog;
  11577. /**
  11578. * Gets or sets the spritesheet texture
  11579. */
  11580. texture: Texture;
  11581. /**
  11582. * Creates a new sprite manager
  11583. * @param name defines the manager's name
  11584. * @param imgUrl defines the sprite sheet url
  11585. * @param capacity defines the maximum allowed number of sprites
  11586. * @param cellSize defines the size of a sprite cell
  11587. * @param scene defines the hosting scene
  11588. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11589. * @param samplingMode defines the smapling mode to use with spritesheet
  11590. */
  11591. constructor(
  11592. /** defines the manager's name */
  11593. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11594. private _appendSpriteVertex;
  11595. /**
  11596. * Intersects the sprites with a ray
  11597. * @param ray defines the ray to intersect with
  11598. * @param camera defines the current active camera
  11599. * @param predicate defines a predicate used to select candidate sprites
  11600. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11601. * @returns null if no hit or a PickingInfo
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Render all child sprites
  11606. */
  11607. render(): void;
  11608. /**
  11609. * Release associated resources
  11610. */
  11611. dispose(): void;
  11612. }
  11613. }
  11614. declare module "babylonjs/Sprites/sprite" {
  11615. import { Vector3 } from "babylonjs/Maths/math.vector";
  11616. import { Nullable } from "babylonjs/types";
  11617. import { ActionManager } from "babylonjs/Actions/actionManager";
  11618. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11619. import { Color4 } from "babylonjs/Maths/math.color";
  11620. /**
  11621. * Class used to represent a sprite
  11622. * @see http://doc.babylonjs.com/babylon101/sprites
  11623. */
  11624. export class Sprite {
  11625. /** defines the name */
  11626. name: string;
  11627. /** Gets or sets the current world position */
  11628. position: Vector3;
  11629. /** Gets or sets the main color */
  11630. color: Color4;
  11631. /** Gets or sets the width */
  11632. width: number;
  11633. /** Gets or sets the height */
  11634. height: number;
  11635. /** Gets or sets rotation angle */
  11636. angle: number;
  11637. /** Gets or sets the cell index in the sprite sheet */
  11638. cellIndex: number;
  11639. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11640. invertU: number;
  11641. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11642. invertV: number;
  11643. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11644. disposeWhenFinishedAnimating: boolean;
  11645. /** Gets the list of attached animations */
  11646. animations: Animation[];
  11647. /** Gets or sets a boolean indicating if the sprite can be picked */
  11648. isPickable: boolean;
  11649. /**
  11650. * Gets or sets the associated action manager
  11651. */
  11652. actionManager: Nullable<ActionManager>;
  11653. private _animationStarted;
  11654. private _loopAnimation;
  11655. private _fromIndex;
  11656. private _toIndex;
  11657. private _delay;
  11658. private _direction;
  11659. private _manager;
  11660. private _time;
  11661. private _onAnimationEnd;
  11662. /**
  11663. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11664. */
  11665. isVisible: boolean;
  11666. /**
  11667. * Gets or sets the sprite size
  11668. */
  11669. size: number;
  11670. /**
  11671. * Creates a new Sprite
  11672. * @param name defines the name
  11673. * @param manager defines the manager
  11674. */
  11675. constructor(
  11676. /** defines the name */
  11677. name: string, manager: ISpriteManager);
  11678. /**
  11679. * Starts an animation
  11680. * @param from defines the initial key
  11681. * @param to defines the end key
  11682. * @param loop defines if the animation must loop
  11683. * @param delay defines the start delay (in ms)
  11684. * @param onAnimationEnd defines a callback to call when animation ends
  11685. */
  11686. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11687. /** Stops current animation (if any) */
  11688. stopAnimation(): void;
  11689. /** @hidden */
  11690. _animate(deltaTime: number): void;
  11691. /** Release associated resources */
  11692. dispose(): void;
  11693. }
  11694. }
  11695. declare module "babylonjs/Collisions/pickingInfo" {
  11696. import { Nullable } from "babylonjs/types";
  11697. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11699. import { Sprite } from "babylonjs/Sprites/sprite";
  11700. import { Ray } from "babylonjs/Culling/ray";
  11701. /**
  11702. * Information about the result of picking within a scene
  11703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11704. */
  11705. export class PickingInfo {
  11706. /** @hidden */
  11707. _pickingUnavailable: boolean;
  11708. /**
  11709. * If the pick collided with an object
  11710. */
  11711. hit: boolean;
  11712. /**
  11713. * Distance away where the pick collided
  11714. */
  11715. distance: number;
  11716. /**
  11717. * The location of pick collision
  11718. */
  11719. pickedPoint: Nullable<Vector3>;
  11720. /**
  11721. * The mesh corresponding the the pick collision
  11722. */
  11723. pickedMesh: Nullable<AbstractMesh>;
  11724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11725. bu: number;
  11726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11727. bv: number;
  11728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11729. faceId: number;
  11730. /** Id of the the submesh that was picked */
  11731. subMeshId: number;
  11732. /** If a sprite was picked, this will be the sprite the pick collided with */
  11733. pickedSprite: Nullable<Sprite>;
  11734. /**
  11735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11736. */
  11737. originMesh: Nullable<AbstractMesh>;
  11738. /**
  11739. * The ray that was used to perform the picking.
  11740. */
  11741. ray: Nullable<Ray>;
  11742. /**
  11743. * Gets the normal correspodning to the face the pick collided with
  11744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11746. * @returns The normal correspodning to the face the pick collided with
  11747. */
  11748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11749. /**
  11750. * Gets the texture coordinates of where the pick occured
  11751. * @returns the vector containing the coordnates of the texture
  11752. */
  11753. getTextureCoordinates(): Nullable<Vector2>;
  11754. }
  11755. }
  11756. declare module "babylonjs/Events/pointerEvents" {
  11757. import { Nullable } from "babylonjs/types";
  11758. import { Vector2 } from "babylonjs/Maths/math.vector";
  11759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11760. import { Ray } from "babylonjs/Culling/ray";
  11761. /**
  11762. * Gather the list of pointer event types as constants.
  11763. */
  11764. export class PointerEventTypes {
  11765. /**
  11766. * 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.
  11767. */
  11768. static readonly POINTERDOWN: number;
  11769. /**
  11770. * The pointerup event is fired when a pointer is no longer active.
  11771. */
  11772. static readonly POINTERUP: number;
  11773. /**
  11774. * The pointermove event is fired when a pointer changes coordinates.
  11775. */
  11776. static readonly POINTERMOVE: number;
  11777. /**
  11778. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11779. */
  11780. static readonly POINTERWHEEL: number;
  11781. /**
  11782. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11783. */
  11784. static readonly POINTERPICK: number;
  11785. /**
  11786. * The pointertap event is fired when a the object has been touched and released without drag.
  11787. */
  11788. static readonly POINTERTAP: number;
  11789. /**
  11790. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11791. */
  11792. static readonly POINTERDOUBLETAP: number;
  11793. }
  11794. /**
  11795. * Base class of pointer info types.
  11796. */
  11797. export class PointerInfoBase {
  11798. /**
  11799. * Defines the type of event (PointerEventTypes)
  11800. */
  11801. type: number;
  11802. /**
  11803. * Defines the related dom event
  11804. */
  11805. event: PointerEvent | MouseWheelEvent;
  11806. /**
  11807. * Instantiates the base class of pointers info.
  11808. * @param type Defines the type of event (PointerEventTypes)
  11809. * @param event Defines the related dom event
  11810. */
  11811. constructor(
  11812. /**
  11813. * Defines the type of event (PointerEventTypes)
  11814. */
  11815. type: number,
  11816. /**
  11817. * Defines the related dom event
  11818. */
  11819. event: PointerEvent | MouseWheelEvent);
  11820. }
  11821. /**
  11822. * This class is used to store pointer related info for the onPrePointerObservable event.
  11823. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11824. */
  11825. export class PointerInfoPre extends PointerInfoBase {
  11826. /**
  11827. * Ray from a pointer if availible (eg. 6dof controller)
  11828. */
  11829. ray: Nullable<Ray>;
  11830. /**
  11831. * Defines the local position of the pointer on the canvas.
  11832. */
  11833. localPosition: Vector2;
  11834. /**
  11835. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11836. */
  11837. skipOnPointerObservable: boolean;
  11838. /**
  11839. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11840. * @param type Defines the type of event (PointerEventTypes)
  11841. * @param event Defines the related dom event
  11842. * @param localX Defines the local x coordinates of the pointer when the event occured
  11843. * @param localY Defines the local y coordinates of the pointer when the event occured
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11846. }
  11847. /**
  11848. * This type contains all the data related to a pointer event in Babylon.js.
  11849. * 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.
  11850. */
  11851. export class PointerInfo extends PointerInfoBase {
  11852. /**
  11853. * Defines the picking info associated to the info (if any)\
  11854. */
  11855. pickInfo: Nullable<PickingInfo>;
  11856. /**
  11857. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. * @param pickInfo Defines the picking info associated to the info (if any)\
  11861. */
  11862. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11863. /**
  11864. * Defines the picking info associated to the info (if any)\
  11865. */
  11866. pickInfo: Nullable<PickingInfo>);
  11867. }
  11868. /**
  11869. * Data relating to a touch event on the screen.
  11870. */
  11871. export interface PointerTouch {
  11872. /**
  11873. * X coordinate of touch.
  11874. */
  11875. x: number;
  11876. /**
  11877. * Y coordinate of touch.
  11878. */
  11879. y: number;
  11880. /**
  11881. * Id of touch. Unique for each finger.
  11882. */
  11883. pointerId: number;
  11884. /**
  11885. * Event type passed from DOM.
  11886. */
  11887. type: any;
  11888. }
  11889. }
  11890. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11891. import { Observable } from "babylonjs/Misc/observable";
  11892. import { Nullable } from "babylonjs/types";
  11893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11895. /**
  11896. * Manage the mouse inputs to control the movement of a free camera.
  11897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11898. */
  11899. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11900. /**
  11901. * Define if touch is enabled in the mouse input
  11902. */
  11903. touchEnabled: boolean;
  11904. /**
  11905. * Defines the camera the input is attached to.
  11906. */
  11907. camera: FreeCamera;
  11908. /**
  11909. * Defines the buttons associated with the input to handle camera move.
  11910. */
  11911. buttons: number[];
  11912. /**
  11913. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11914. */
  11915. angularSensibility: number;
  11916. private _pointerInput;
  11917. private _onMouseMove;
  11918. private _observer;
  11919. private previousPosition;
  11920. /**
  11921. * Observable for when a pointer move event occurs containing the move offset
  11922. */
  11923. onPointerMovedObservable: Observable<{
  11924. offsetX: number;
  11925. offsetY: number;
  11926. }>;
  11927. /**
  11928. * @hidden
  11929. * If the camera should be rotated automatically based on pointer movement
  11930. */
  11931. _allowCameraRotation: boolean;
  11932. /**
  11933. * Manage the mouse inputs to control the movement of a free camera.
  11934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11935. * @param touchEnabled Defines if touch is enabled or not
  11936. */
  11937. constructor(
  11938. /**
  11939. * Define if touch is enabled in the mouse input
  11940. */
  11941. touchEnabled?: boolean);
  11942. /**
  11943. * Attach the input controls to a specific dom element to get the input from.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Called on JS contextmenu event.
  11950. * Override this method to provide functionality.
  11951. */
  11952. protected onContextMenu(evt: PointerEvent): void;
  11953. /**
  11954. * Detach the current controls from the specified dom element.
  11955. * @param element Defines the element to stop listening the inputs from
  11956. */
  11957. detachControl(element: Nullable<HTMLElement>): void;
  11958. /**
  11959. * Gets the class name of the current intput.
  11960. * @returns the class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Get the friendly name associated with the input class.
  11965. * @returns the input friendly name
  11966. */
  11967. getSimpleName(): string;
  11968. }
  11969. }
  11970. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11971. import { Nullable } from "babylonjs/types";
  11972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11974. /**
  11975. * Manage the touch inputs to control the movement of a free camera.
  11976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11977. */
  11978. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11979. /**
  11980. * Defines the camera the input is attached to.
  11981. */
  11982. camera: FreeCamera;
  11983. /**
  11984. * Defines the touch sensibility for rotation.
  11985. * The higher the faster.
  11986. */
  11987. touchAngularSensibility: number;
  11988. /**
  11989. * Defines the touch sensibility for move.
  11990. * The higher the faster.
  11991. */
  11992. touchMoveSensibility: number;
  11993. private _offsetX;
  11994. private _offsetY;
  11995. private _pointerPressed;
  11996. private _pointerInput;
  11997. private _observer;
  11998. private _onLostFocus;
  11999. /**
  12000. * Attach the input controls to a specific dom element to get the input from.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Detach the current controls from the specified dom element.
  12007. * @param element Defines the element to stop listening the inputs from
  12008. */
  12009. detachControl(element: Nullable<HTMLElement>): void;
  12010. /**
  12011. * Update the current camera state depending on the inputs that have been used this frame.
  12012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12013. */
  12014. checkInputs(): void;
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. getClassName(): string;
  12020. /**
  12021. * Get the friendly name associated with the input class.
  12022. * @returns the input friendly name
  12023. */
  12024. getSimpleName(): string;
  12025. }
  12026. }
  12027. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12030. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12031. import { Nullable } from "babylonjs/types";
  12032. /**
  12033. * Default Inputs manager for the FreeCamera.
  12034. * It groups all the default supported inputs for ease of use.
  12035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12036. */
  12037. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12038. /**
  12039. * @hidden
  12040. */
  12041. _mouseInput: Nullable<FreeCameraMouseInput>;
  12042. /**
  12043. * Instantiates a new FreeCameraInputsManager.
  12044. * @param camera Defines the camera the inputs belong to
  12045. */
  12046. constructor(camera: FreeCamera);
  12047. /**
  12048. * Add keyboard input support to the input manager.
  12049. * @returns the current input manager
  12050. */
  12051. addKeyboard(): FreeCameraInputsManager;
  12052. /**
  12053. * Add mouse input support to the input manager.
  12054. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12055. * @returns the current input manager
  12056. */
  12057. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12058. /**
  12059. * Removes the mouse input support from the manager
  12060. * @returns the current input manager
  12061. */
  12062. removeMouse(): FreeCameraInputsManager;
  12063. /**
  12064. * Add touch input support to the input manager.
  12065. * @returns the current input manager
  12066. */
  12067. addTouch(): FreeCameraInputsManager;
  12068. /**
  12069. * Remove all attached input methods from a camera
  12070. */
  12071. clear(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Cameras/freeCamera" {
  12075. import { Vector3 } from "babylonjs/Maths/math.vector";
  12076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12077. import { Scene } from "babylonjs/scene";
  12078. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12079. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12080. /**
  12081. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12082. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12084. */
  12085. export class FreeCamera extends TargetCamera {
  12086. /**
  12087. * Define the collision ellipsoid of the camera.
  12088. * This is helpful to simulate a camera body like the player body around the camera
  12089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12090. */
  12091. ellipsoid: Vector3;
  12092. /**
  12093. * Define an offset for the position of the ellipsoid around the camera.
  12094. * This can be helpful to determine the center of the body near the gravity center of the body
  12095. * instead of its head.
  12096. */
  12097. ellipsoidOffset: Vector3;
  12098. /**
  12099. * Enable or disable collisions of the camera with the rest of the scene objects.
  12100. */
  12101. checkCollisions: boolean;
  12102. /**
  12103. * Enable or disable gravity on the camera.
  12104. */
  12105. applyGravity: boolean;
  12106. /**
  12107. * Define the input manager associated to the camera.
  12108. */
  12109. inputs: FreeCameraInputsManager;
  12110. /**
  12111. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. /**
  12115. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12116. * Higher values reduce sensitivity.
  12117. */
  12118. angularSensibility: number;
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12121. */
  12122. keysUp: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12125. */
  12126. keysDown: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12129. */
  12130. keysLeft: number[];
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12133. */
  12134. keysRight: number[];
  12135. /**
  12136. * Event raised when the camera collide with a mesh in the scene.
  12137. */
  12138. onCollide: (collidedMesh: AbstractMesh) => void;
  12139. private _collider;
  12140. private _needMoveForGravity;
  12141. private _oldPosition;
  12142. private _diffPosition;
  12143. private _newPosition;
  12144. /** @hidden */
  12145. _localDirection: Vector3;
  12146. /** @hidden */
  12147. _transformedDirection: Vector3;
  12148. /**
  12149. * Instantiates a Free Camera.
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. * @param name Define the name of the camera in the scene
  12154. * @param position Define the start position of the camera in the scene
  12155. * @param scene Define the scene the camera belongs to
  12156. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12157. */
  12158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12159. /**
  12160. * Attached controls to the current camera.
  12161. * @param element Defines the element the controls should be listened from
  12162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12163. */
  12164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12165. /**
  12166. * Detach the current controls from the camera.
  12167. * The camera will stop reacting to inputs.
  12168. * @param element Defines the element to stop listening the inputs from
  12169. */
  12170. detachControl(element: HTMLElement): void;
  12171. private _collisionMask;
  12172. /**
  12173. * Define a collision mask to limit the list of object the camera can collide with
  12174. */
  12175. collisionMask: number;
  12176. /** @hidden */
  12177. _collideWithWorld(displacement: Vector3): void;
  12178. private _onCollisionPositionChange;
  12179. /** @hidden */
  12180. _checkInputs(): void;
  12181. /** @hidden */
  12182. _decideIfNeedsToMove(): boolean;
  12183. /** @hidden */
  12184. _updatePosition(): void;
  12185. /**
  12186. * Destroy the camera and release the current resources hold by it.
  12187. */
  12188. dispose(): void;
  12189. /**
  12190. * Gets the current object class name.
  12191. * @return the class name
  12192. */
  12193. getClassName(): string;
  12194. }
  12195. }
  12196. declare module "babylonjs/Gamepads/gamepad" {
  12197. import { Observable } from "babylonjs/Misc/observable";
  12198. /**
  12199. * Represents a gamepad control stick position
  12200. */
  12201. export class StickValues {
  12202. /**
  12203. * The x component of the control stick
  12204. */
  12205. x: number;
  12206. /**
  12207. * The y component of the control stick
  12208. */
  12209. y: number;
  12210. /**
  12211. * Initializes the gamepad x and y control stick values
  12212. * @param x The x component of the gamepad control stick value
  12213. * @param y The y component of the gamepad control stick value
  12214. */
  12215. constructor(
  12216. /**
  12217. * The x component of the control stick
  12218. */
  12219. x: number,
  12220. /**
  12221. * The y component of the control stick
  12222. */
  12223. y: number);
  12224. }
  12225. /**
  12226. * An interface which manages callbacks for gamepad button changes
  12227. */
  12228. export interface GamepadButtonChanges {
  12229. /**
  12230. * Called when a gamepad has been changed
  12231. */
  12232. changed: boolean;
  12233. /**
  12234. * Called when a gamepad press event has been triggered
  12235. */
  12236. pressChanged: boolean;
  12237. /**
  12238. * Called when a touch event has been triggered
  12239. */
  12240. touchChanged: boolean;
  12241. /**
  12242. * Called when a value has changed
  12243. */
  12244. valueChanged: boolean;
  12245. }
  12246. /**
  12247. * Represents a gamepad
  12248. */
  12249. export class Gamepad {
  12250. /**
  12251. * The id of the gamepad
  12252. */
  12253. id: string;
  12254. /**
  12255. * The index of the gamepad
  12256. */
  12257. index: number;
  12258. /**
  12259. * The browser gamepad
  12260. */
  12261. browserGamepad: any;
  12262. /**
  12263. * Specifies what type of gamepad this represents
  12264. */
  12265. type: number;
  12266. private _leftStick;
  12267. private _rightStick;
  12268. /** @hidden */
  12269. _isConnected: boolean;
  12270. private _leftStickAxisX;
  12271. private _leftStickAxisY;
  12272. private _rightStickAxisX;
  12273. private _rightStickAxisY;
  12274. /**
  12275. * Triggered when the left control stick has been changed
  12276. */
  12277. private _onleftstickchanged;
  12278. /**
  12279. * Triggered when the right control stick has been changed
  12280. */
  12281. private _onrightstickchanged;
  12282. /**
  12283. * Represents a gamepad controller
  12284. */
  12285. static GAMEPAD: number;
  12286. /**
  12287. * Represents a generic controller
  12288. */
  12289. static GENERIC: number;
  12290. /**
  12291. * Represents an XBox controller
  12292. */
  12293. static XBOX: number;
  12294. /**
  12295. * Represents a pose-enabled controller
  12296. */
  12297. static POSE_ENABLED: number;
  12298. /**
  12299. * Represents an Dual Shock controller
  12300. */
  12301. static DUALSHOCK: number;
  12302. /**
  12303. * Specifies whether the left control stick should be Y-inverted
  12304. */
  12305. protected _invertLeftStickY: boolean;
  12306. /**
  12307. * Specifies if the gamepad has been connected
  12308. */
  12309. readonly isConnected: boolean;
  12310. /**
  12311. * Initializes the gamepad
  12312. * @param id The id of the gamepad
  12313. * @param index The index of the gamepad
  12314. * @param browserGamepad The browser gamepad
  12315. * @param leftStickX The x component of the left joystick
  12316. * @param leftStickY The y component of the left joystick
  12317. * @param rightStickX The x component of the right joystick
  12318. * @param rightStickY The y component of the right joystick
  12319. */
  12320. constructor(
  12321. /**
  12322. * The id of the gamepad
  12323. */
  12324. id: string,
  12325. /**
  12326. * The index of the gamepad
  12327. */
  12328. index: number,
  12329. /**
  12330. * The browser gamepad
  12331. */
  12332. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12333. /**
  12334. * Callback triggered when the left joystick has changed
  12335. * @param callback
  12336. */
  12337. onleftstickchanged(callback: (values: StickValues) => void): void;
  12338. /**
  12339. * Callback triggered when the right joystick has changed
  12340. * @param callback
  12341. */
  12342. onrightstickchanged(callback: (values: StickValues) => void): void;
  12343. /**
  12344. * Gets the left joystick
  12345. */
  12346. /**
  12347. * Sets the left joystick values
  12348. */
  12349. leftStick: StickValues;
  12350. /**
  12351. * Gets the right joystick
  12352. */
  12353. /**
  12354. * Sets the right joystick value
  12355. */
  12356. rightStick: StickValues;
  12357. /**
  12358. * Updates the gamepad joystick positions
  12359. */
  12360. update(): void;
  12361. /**
  12362. * Disposes the gamepad
  12363. */
  12364. dispose(): void;
  12365. }
  12366. /**
  12367. * Represents a generic gamepad
  12368. */
  12369. export class GenericPad extends Gamepad {
  12370. private _buttons;
  12371. private _onbuttondown;
  12372. private _onbuttonup;
  12373. /**
  12374. * Observable triggered when a button has been pressed
  12375. */
  12376. onButtonDownObservable: Observable<number>;
  12377. /**
  12378. * Observable triggered when a button has been released
  12379. */
  12380. onButtonUpObservable: Observable<number>;
  12381. /**
  12382. * Callback triggered when a button has been pressed
  12383. * @param callback Called when a button has been pressed
  12384. */
  12385. onbuttondown(callback: (buttonPressed: number) => void): void;
  12386. /**
  12387. * Callback triggered when a button has been released
  12388. * @param callback Called when a button has been released
  12389. */
  12390. onbuttonup(callback: (buttonReleased: number) => void): void;
  12391. /**
  12392. * Initializes the generic gamepad
  12393. * @param id The id of the generic gamepad
  12394. * @param index The index of the generic gamepad
  12395. * @param browserGamepad The browser gamepad
  12396. */
  12397. constructor(id: string, index: number, browserGamepad: any);
  12398. private _setButtonValue;
  12399. /**
  12400. * Updates the generic gamepad
  12401. */
  12402. update(): void;
  12403. /**
  12404. * Disposes the generic gamepad
  12405. */
  12406. dispose(): void;
  12407. }
  12408. }
  12409. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12410. import { Nullable } from "babylonjs/types";
  12411. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12412. import { Scene } from "babylonjs/scene";
  12413. module "babylonjs/Engines/engine" {
  12414. interface Engine {
  12415. /**
  12416. * Creates a raw texture
  12417. * @param data defines the data to store in the texture
  12418. * @param width defines the width of the texture
  12419. * @param height defines the height of the texture
  12420. * @param format defines the format of the data
  12421. * @param generateMipMaps defines if the engine should generate the mip levels
  12422. * @param invertY defines if data must be stored with Y axis inverted
  12423. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12424. * @param compression defines the compression used (null by default)
  12425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12426. * @returns the raw texture inside an InternalTexture
  12427. */
  12428. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12429. /**
  12430. * Update a raw texture
  12431. * @param texture defines the texture to update
  12432. * @param data defines the data to store in the texture
  12433. * @param format defines the format of the data
  12434. * @param invertY defines if data must be stored with Y axis inverted
  12435. */
  12436. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12437. /**
  12438. * Update a raw texture
  12439. * @param texture defines the texture to update
  12440. * @param data defines the data to store in the texture
  12441. * @param format defines the format of the data
  12442. * @param invertY defines if data must be stored with Y axis inverted
  12443. * @param compression defines the compression used (null by default)
  12444. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12445. */
  12446. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12447. /**
  12448. * Creates a new raw cube texture
  12449. * @param data defines the array of data to use to create each face
  12450. * @param size defines the size of the textures
  12451. * @param format defines the format of the data
  12452. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12453. * @param generateMipMaps defines if the engine should generate the mip levels
  12454. * @param invertY defines if data must be stored with Y axis inverted
  12455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12456. * @param compression defines the compression used (null by default)
  12457. * @returns the cube texture as an InternalTexture
  12458. */
  12459. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12460. /**
  12461. * Update a raw cube texture
  12462. * @param texture defines the texture to udpdate
  12463. * @param data defines the data to store
  12464. * @param format defines the data format
  12465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12466. * @param invertY defines if data must be stored with Y axis inverted
  12467. */
  12468. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12469. /**
  12470. * Update a raw cube texture
  12471. * @param texture defines the texture to udpdate
  12472. * @param data defines the data to store
  12473. * @param format defines the data format
  12474. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12475. * @param invertY defines if data must be stored with Y axis inverted
  12476. * @param compression defines the compression used (null by default)
  12477. */
  12478. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12479. /**
  12480. * Update a raw cube texture
  12481. * @param texture defines the texture to udpdate
  12482. * @param data defines the data to store
  12483. * @param format defines the data format
  12484. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12485. * @param invertY defines if data must be stored with Y axis inverted
  12486. * @param compression defines the compression used (null by default)
  12487. * @param level defines which level of the texture to update
  12488. */
  12489. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12490. /**
  12491. * Creates a new raw cube texture from a specified url
  12492. * @param url defines the url where the data is located
  12493. * @param scene defines the current scene
  12494. * @param size defines the size of the textures
  12495. * @param format defines the format of the data
  12496. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12497. * @param noMipmap defines if the engine should avoid generating the mip levels
  12498. * @param callback defines a callback used to extract texture data from loaded data
  12499. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12500. * @param onLoad defines a callback called when texture is loaded
  12501. * @param onError defines a callback called if there is an error
  12502. * @returns the cube texture as an InternalTexture
  12503. */
  12504. 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;
  12505. /**
  12506. * Creates a new raw cube texture from a specified url
  12507. * @param url defines the url where the data is located
  12508. * @param scene defines the current scene
  12509. * @param size defines the size of the textures
  12510. * @param format defines the format of the data
  12511. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12512. * @param noMipmap defines if the engine should avoid generating the mip levels
  12513. * @param callback defines a callback used to extract texture data from loaded data
  12514. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12515. * @param onLoad defines a callback called when texture is loaded
  12516. * @param onError defines a callback called if there is an error
  12517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12518. * @param invertY defines if data must be stored with Y axis inverted
  12519. * @returns the cube texture as an InternalTexture
  12520. */
  12521. 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;
  12522. /**
  12523. * Creates a new raw 3D texture
  12524. * @param data defines the data used to create the texture
  12525. * @param width defines the width of the texture
  12526. * @param height defines the height of the texture
  12527. * @param depth defines the depth of the texture
  12528. * @param format defines the format of the texture
  12529. * @param generateMipMaps defines if the engine must generate mip levels
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12532. * @param compression defines the compressed used (can be null)
  12533. * @param textureType defines the compressed used (can be null)
  12534. * @returns a new raw 3D texture (stored in an InternalTexture)
  12535. */
  12536. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12537. /**
  12538. * Update a raw 3D texture
  12539. * @param texture defines the texture to update
  12540. * @param data defines the data to store
  12541. * @param format defines the data format
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. */
  12544. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12545. /**
  12546. * Update a raw 3D texture
  12547. * @param texture defines the texture to update
  12548. * @param data defines the data to store
  12549. * @param format defines the data format
  12550. * @param invertY defines if data must be stored with Y axis inverted
  12551. * @param compression defines the used compression (can be null)
  12552. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12553. */
  12554. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12555. }
  12556. }
  12557. }
  12558. declare module "babylonjs/Materials/Textures/rawTexture" {
  12559. import { Scene } from "babylonjs/scene";
  12560. import { Texture } from "babylonjs/Materials/Textures/texture";
  12561. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12562. /**
  12563. * Raw texture can help creating a texture directly from an array of data.
  12564. * This can be super useful if you either get the data from an uncompressed source or
  12565. * if you wish to create your texture pixel by pixel.
  12566. */
  12567. export class RawTexture extends Texture {
  12568. /**
  12569. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12570. */
  12571. format: number;
  12572. private _engine;
  12573. /**
  12574. * Instantiates a new RawTexture.
  12575. * Raw texture can help creating a texture directly from an array of data.
  12576. * This can be super useful if you either get the data from an uncompressed source or
  12577. * if you wish to create your texture pixel by pixel.
  12578. * @param data define the array of data to use to create the texture
  12579. * @param width define the width of the texture
  12580. * @param height define the height of the texture
  12581. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12582. * @param scene define the scene the texture belongs to
  12583. * @param generateMipMaps define whether mip maps should be generated or not
  12584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12586. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12587. */
  12588. constructor(data: ArrayBufferView, width: number, height: number,
  12589. /**
  12590. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12591. */
  12592. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12593. /**
  12594. * Updates the texture underlying data.
  12595. * @param data Define the new data of the texture
  12596. */
  12597. update(data: ArrayBufferView): void;
  12598. /**
  12599. * Creates a luminance texture from some data.
  12600. * @param data Define the texture data
  12601. * @param width Define the width of the texture
  12602. * @param height Define the height of the texture
  12603. * @param scene Define the scene the texture belongs to
  12604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12607. * @returns the luminance texture
  12608. */
  12609. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12610. /**
  12611. * Creates a luminance alpha texture from some data.
  12612. * @param data Define the texture data
  12613. * @param width Define the width of the texture
  12614. * @param height Define the height of the texture
  12615. * @param scene Define the scene the texture belongs to
  12616. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12617. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12618. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12619. * @returns the luminance alpha texture
  12620. */
  12621. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12622. /**
  12623. * Creates an alpha texture from some data.
  12624. * @param data Define the texture data
  12625. * @param width Define the width of the texture
  12626. * @param height Define the height of the texture
  12627. * @param scene Define the scene the texture belongs to
  12628. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12629. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12630. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12631. * @returns the alpha texture
  12632. */
  12633. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12634. /**
  12635. * Creates a RGB texture from some data.
  12636. * @param data Define the texture data
  12637. * @param width Define the width of the texture
  12638. * @param height Define the height of the texture
  12639. * @param scene Define the scene the texture belongs to
  12640. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12643. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12644. * @returns the RGB alpha texture
  12645. */
  12646. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12647. /**
  12648. * Creates a RGBA texture from some data.
  12649. * @param data Define the texture data
  12650. * @param width Define the width of the texture
  12651. * @param height Define the height of the texture
  12652. * @param scene Define the scene the texture belongs to
  12653. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12656. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12657. * @returns the RGBA texture
  12658. */
  12659. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12660. /**
  12661. * Creates a R texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12670. * @returns the R texture
  12671. */
  12672. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12673. }
  12674. }
  12675. declare module "babylonjs/Maths/math.size" {
  12676. /**
  12677. * Interface for the size containing width and height
  12678. */
  12679. export interface ISize {
  12680. /**
  12681. * Width
  12682. */
  12683. width: number;
  12684. /**
  12685. * Heighht
  12686. */
  12687. height: number;
  12688. }
  12689. /**
  12690. * Size containing widht and height
  12691. */
  12692. export class Size implements ISize {
  12693. /**
  12694. * Width
  12695. */
  12696. width: number;
  12697. /**
  12698. * Height
  12699. */
  12700. height: number;
  12701. /**
  12702. * Creates a Size object from the given width and height (floats).
  12703. * @param width width of the new size
  12704. * @param height height of the new size
  12705. */
  12706. constructor(width: number, height: number);
  12707. /**
  12708. * Returns a string with the Size width and height
  12709. * @returns a string with the Size width and height
  12710. */
  12711. toString(): string;
  12712. /**
  12713. * "Size"
  12714. * @returns the string "Size"
  12715. */
  12716. getClassName(): string;
  12717. /**
  12718. * Returns the Size hash code.
  12719. * @returns a hash code for a unique width and height
  12720. */
  12721. getHashCode(): number;
  12722. /**
  12723. * Updates the current size from the given one.
  12724. * @param src the given size
  12725. */
  12726. copyFrom(src: Size): void;
  12727. /**
  12728. * Updates in place the current Size from the given floats.
  12729. * @param width width of the new size
  12730. * @param height height of the new size
  12731. * @returns the updated Size.
  12732. */
  12733. copyFromFloats(width: number, height: number): Size;
  12734. /**
  12735. * Updates in place the current Size from the given floats.
  12736. * @param width width to set
  12737. * @param height height to set
  12738. * @returns the updated Size.
  12739. */
  12740. set(width: number, height: number): Size;
  12741. /**
  12742. * Multiplies the width and height by numbers
  12743. * @param w factor to multiple the width by
  12744. * @param h factor to multiple the height by
  12745. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12746. */
  12747. multiplyByFloats(w: number, h: number): Size;
  12748. /**
  12749. * Clones the size
  12750. * @returns a new Size copied from the given one.
  12751. */
  12752. clone(): Size;
  12753. /**
  12754. * True if the current Size and the given one width and height are strictly equal.
  12755. * @param other the other size to compare against
  12756. * @returns True if the current Size and the given one width and height are strictly equal.
  12757. */
  12758. equals(other: Size): boolean;
  12759. /**
  12760. * The surface of the Size : width * height (float).
  12761. */
  12762. readonly surface: number;
  12763. /**
  12764. * Create a new size of zero
  12765. * @returns a new Size set to (0.0, 0.0)
  12766. */
  12767. static Zero(): Size;
  12768. /**
  12769. * Sums the width and height of two sizes
  12770. * @param otherSize size to add to this size
  12771. * @returns a new Size set as the addition result of the current Size and the given one.
  12772. */
  12773. add(otherSize: Size): Size;
  12774. /**
  12775. * Subtracts the width and height of two
  12776. * @param otherSize size to subtract to this size
  12777. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12778. */
  12779. subtract(otherSize: Size): Size;
  12780. /**
  12781. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12782. * @param start starting size to lerp between
  12783. * @param end end size to lerp between
  12784. * @param amount amount to lerp between the start and end values
  12785. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12786. */
  12787. static Lerp(start: Size, end: Size, amount: number): Size;
  12788. }
  12789. }
  12790. declare module "babylonjs/Animations/runtimeAnimation" {
  12791. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12792. import { Animatable } from "babylonjs/Animations/animatable";
  12793. import { Scene } from "babylonjs/scene";
  12794. /**
  12795. * Defines a runtime animation
  12796. */
  12797. export class RuntimeAnimation {
  12798. private _events;
  12799. /**
  12800. * The current frame of the runtime animation
  12801. */
  12802. private _currentFrame;
  12803. /**
  12804. * The animation used by the runtime animation
  12805. */
  12806. private _animation;
  12807. /**
  12808. * The target of the runtime animation
  12809. */
  12810. private _target;
  12811. /**
  12812. * The initiating animatable
  12813. */
  12814. private _host;
  12815. /**
  12816. * The original value of the runtime animation
  12817. */
  12818. private _originalValue;
  12819. /**
  12820. * The original blend value of the runtime animation
  12821. */
  12822. private _originalBlendValue;
  12823. /**
  12824. * The offsets cache of the runtime animation
  12825. */
  12826. private _offsetsCache;
  12827. /**
  12828. * The high limits cache of the runtime animation
  12829. */
  12830. private _highLimitsCache;
  12831. /**
  12832. * Specifies if the runtime animation has been stopped
  12833. */
  12834. private _stopped;
  12835. /**
  12836. * The blending factor of the runtime animation
  12837. */
  12838. private _blendingFactor;
  12839. /**
  12840. * The BabylonJS scene
  12841. */
  12842. private _scene;
  12843. /**
  12844. * The current value of the runtime animation
  12845. */
  12846. private _currentValue;
  12847. /** @hidden */
  12848. _animationState: _IAnimationState;
  12849. /**
  12850. * The active target of the runtime animation
  12851. */
  12852. private _activeTargets;
  12853. private _currentActiveTarget;
  12854. private _directTarget;
  12855. /**
  12856. * The target path of the runtime animation
  12857. */
  12858. private _targetPath;
  12859. /**
  12860. * The weight of the runtime animation
  12861. */
  12862. private _weight;
  12863. /**
  12864. * The ratio offset of the runtime animation
  12865. */
  12866. private _ratioOffset;
  12867. /**
  12868. * The previous delay of the runtime animation
  12869. */
  12870. private _previousDelay;
  12871. /**
  12872. * The previous ratio of the runtime animation
  12873. */
  12874. private _previousRatio;
  12875. private _enableBlending;
  12876. private _keys;
  12877. private _minFrame;
  12878. private _maxFrame;
  12879. private _minValue;
  12880. private _maxValue;
  12881. private _targetIsArray;
  12882. /**
  12883. * Gets the current frame of the runtime animation
  12884. */
  12885. readonly currentFrame: number;
  12886. /**
  12887. * Gets the weight of the runtime animation
  12888. */
  12889. readonly weight: number;
  12890. /**
  12891. * Gets the current value of the runtime animation
  12892. */
  12893. readonly currentValue: any;
  12894. /**
  12895. * Gets the target path of the runtime animation
  12896. */
  12897. readonly targetPath: string;
  12898. /**
  12899. * Gets the actual target of the runtime animation
  12900. */
  12901. readonly target: any;
  12902. /** @hidden */
  12903. _onLoop: () => void;
  12904. /**
  12905. * Create a new RuntimeAnimation object
  12906. * @param target defines the target of the animation
  12907. * @param animation defines the source animation object
  12908. * @param scene defines the hosting scene
  12909. * @param host defines the initiating Animatable
  12910. */
  12911. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12912. private _preparePath;
  12913. /**
  12914. * Gets the animation from the runtime animation
  12915. */
  12916. readonly animation: Animation;
  12917. /**
  12918. * Resets the runtime animation to the beginning
  12919. * @param restoreOriginal defines whether to restore the target property to the original value
  12920. */
  12921. reset(restoreOriginal?: boolean): void;
  12922. /**
  12923. * Specifies if the runtime animation is stopped
  12924. * @returns Boolean specifying if the runtime animation is stopped
  12925. */
  12926. isStopped(): boolean;
  12927. /**
  12928. * Disposes of the runtime animation
  12929. */
  12930. dispose(): void;
  12931. /**
  12932. * Apply the interpolated value to the target
  12933. * @param currentValue defines the value computed by the animation
  12934. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12935. */
  12936. setValue(currentValue: any, weight: number): void;
  12937. private _getOriginalValues;
  12938. private _setValue;
  12939. /**
  12940. * Gets the loop pmode of the runtime animation
  12941. * @returns Loop Mode
  12942. */
  12943. private _getCorrectLoopMode;
  12944. /**
  12945. * Move the current animation to a given frame
  12946. * @param frame defines the frame to move to
  12947. */
  12948. goToFrame(frame: number): void;
  12949. /**
  12950. * @hidden Internal use only
  12951. */
  12952. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12953. /**
  12954. * Execute the current animation
  12955. * @param delay defines the delay to add to the current frame
  12956. * @param from defines the lower bound of the animation range
  12957. * @param to defines the upper bound of the animation range
  12958. * @param loop defines if the current animation must loop
  12959. * @param speedRatio defines the current speed ratio
  12960. * @param weight defines the weight of the animation (default is -1 so no weight)
  12961. * @param onLoop optional callback called when animation loops
  12962. * @returns a boolean indicating if the animation is running
  12963. */
  12964. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12965. }
  12966. }
  12967. declare module "babylonjs/Animations/animatable" {
  12968. import { Animation } from "babylonjs/Animations/animation";
  12969. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12970. import { Nullable } from "babylonjs/types";
  12971. import { Observable } from "babylonjs/Misc/observable";
  12972. import { Scene } from "babylonjs/scene";
  12973. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12974. import { Node } from "babylonjs/node";
  12975. /**
  12976. * Class used to store an actual running animation
  12977. */
  12978. export class Animatable {
  12979. /** defines the target object */
  12980. target: any;
  12981. /** defines the starting frame number (default is 0) */
  12982. fromFrame: number;
  12983. /** defines the ending frame number (default is 100) */
  12984. toFrame: number;
  12985. /** defines if the animation must loop (default is false) */
  12986. loopAnimation: boolean;
  12987. /** defines a callback to call when animation ends if it is not looping */
  12988. onAnimationEnd?: (() => void) | null | undefined;
  12989. /** defines a callback to call when animation loops */
  12990. onAnimationLoop?: (() => void) | null | undefined;
  12991. private _localDelayOffset;
  12992. private _pausedDelay;
  12993. private _runtimeAnimations;
  12994. private _paused;
  12995. private _scene;
  12996. private _speedRatio;
  12997. private _weight;
  12998. private _syncRoot;
  12999. /**
  13000. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13001. * This will only apply for non looping animation (default is true)
  13002. */
  13003. disposeOnEnd: boolean;
  13004. /**
  13005. * Gets a boolean indicating if the animation has started
  13006. */
  13007. animationStarted: boolean;
  13008. /**
  13009. * Observer raised when the animation ends
  13010. */
  13011. onAnimationEndObservable: Observable<Animatable>;
  13012. /**
  13013. * Observer raised when the animation loops
  13014. */
  13015. onAnimationLoopObservable: Observable<Animatable>;
  13016. /**
  13017. * Gets the root Animatable used to synchronize and normalize animations
  13018. */
  13019. readonly syncRoot: Nullable<Animatable>;
  13020. /**
  13021. * Gets the current frame of the first RuntimeAnimation
  13022. * Used to synchronize Animatables
  13023. */
  13024. readonly masterFrame: number;
  13025. /**
  13026. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13027. */
  13028. weight: number;
  13029. /**
  13030. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13031. */
  13032. speedRatio: number;
  13033. /**
  13034. * Creates a new Animatable
  13035. * @param scene defines the hosting scene
  13036. * @param target defines the target object
  13037. * @param fromFrame defines the starting frame number (default is 0)
  13038. * @param toFrame defines the ending frame number (default is 100)
  13039. * @param loopAnimation defines if the animation must loop (default is false)
  13040. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13041. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13042. * @param animations defines a group of animation to add to the new Animatable
  13043. * @param onAnimationLoop defines a callback to call when animation loops
  13044. */
  13045. constructor(scene: Scene,
  13046. /** defines the target object */
  13047. target: any,
  13048. /** defines the starting frame number (default is 0) */
  13049. fromFrame?: number,
  13050. /** defines the ending frame number (default is 100) */
  13051. toFrame?: number,
  13052. /** defines if the animation must loop (default is false) */
  13053. loopAnimation?: boolean, speedRatio?: number,
  13054. /** defines a callback to call when animation ends if it is not looping */
  13055. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13056. /** defines a callback to call when animation loops */
  13057. onAnimationLoop?: (() => void) | null | undefined);
  13058. /**
  13059. * Synchronize and normalize current Animatable with a source Animatable
  13060. * This is useful when using animation weights and when animations are not of the same length
  13061. * @param root defines the root Animatable to synchronize with
  13062. * @returns the current Animatable
  13063. */
  13064. syncWith(root: Animatable): Animatable;
  13065. /**
  13066. * Gets the list of runtime animations
  13067. * @returns an array of RuntimeAnimation
  13068. */
  13069. getAnimations(): RuntimeAnimation[];
  13070. /**
  13071. * Adds more animations to the current animatable
  13072. * @param target defines the target of the animations
  13073. * @param animations defines the new animations to add
  13074. */
  13075. appendAnimations(target: any, animations: Animation[]): void;
  13076. /**
  13077. * Gets the source animation for a specific property
  13078. * @param property defines the propertyu to look for
  13079. * @returns null or the source animation for the given property
  13080. */
  13081. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13082. /**
  13083. * Gets the runtime animation for a specific property
  13084. * @param property defines the propertyu to look for
  13085. * @returns null or the runtime animation for the given property
  13086. */
  13087. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13088. /**
  13089. * Resets the animatable to its original state
  13090. */
  13091. reset(): void;
  13092. /**
  13093. * Allows the animatable to blend with current running animations
  13094. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13095. * @param blendingSpeed defines the blending speed to use
  13096. */
  13097. enableBlending(blendingSpeed: number): void;
  13098. /**
  13099. * Disable animation blending
  13100. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13101. */
  13102. disableBlending(): void;
  13103. /**
  13104. * Jump directly to a given frame
  13105. * @param frame defines the frame to jump to
  13106. */
  13107. goToFrame(frame: number): void;
  13108. /**
  13109. * Pause the animation
  13110. */
  13111. pause(): void;
  13112. /**
  13113. * Restart the animation
  13114. */
  13115. restart(): void;
  13116. private _raiseOnAnimationEnd;
  13117. /**
  13118. * Stop and delete the current animation
  13119. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13120. * @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)
  13121. */
  13122. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13123. /**
  13124. * Wait asynchronously for the animation to end
  13125. * @returns a promise which will be fullfilled when the animation ends
  13126. */
  13127. waitAsync(): Promise<Animatable>;
  13128. /** @hidden */
  13129. _animate(delay: number): boolean;
  13130. }
  13131. module "babylonjs/scene" {
  13132. interface Scene {
  13133. /** @hidden */
  13134. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13135. /** @hidden */
  13136. _processLateAnimationBindingsForMatrices(holder: {
  13137. totalWeight: number;
  13138. animations: RuntimeAnimation[];
  13139. originalValue: Matrix;
  13140. }): any;
  13141. /** @hidden */
  13142. _processLateAnimationBindingsForQuaternions(holder: {
  13143. totalWeight: number;
  13144. animations: RuntimeAnimation[];
  13145. originalValue: Quaternion;
  13146. }, refQuaternion: Quaternion): Quaternion;
  13147. /** @hidden */
  13148. _processLateAnimationBindings(): void;
  13149. /**
  13150. * Will start the animation sequence of a given target
  13151. * @param target defines the target
  13152. * @param from defines from which frame should animation start
  13153. * @param to defines until which frame should animation run.
  13154. * @param weight defines the weight to apply to the animation (1.0 by default)
  13155. * @param loop defines if the animation loops
  13156. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13157. * @param onAnimationEnd defines the function to be executed when the animation ends
  13158. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13159. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13160. * @param onAnimationLoop defines the callback to call when an animation loops
  13161. * @returns the animatable object created for this animation
  13162. */
  13163. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13164. /**
  13165. * Will start the animation sequence of a given target
  13166. * @param target defines the target
  13167. * @param from defines from which frame should animation start
  13168. * @param to defines until which frame should animation run.
  13169. * @param loop defines if the animation loops
  13170. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13171. * @param onAnimationEnd defines the function to be executed when the animation ends
  13172. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13173. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13174. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13175. * @param onAnimationLoop defines the callback to call when an animation loops
  13176. * @returns the animatable object created for this animation
  13177. */
  13178. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13179. /**
  13180. * Will start the animation sequence of a given target and its hierarchy
  13181. * @param target defines the target
  13182. * @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.
  13183. * @param from defines from which frame should animation start
  13184. * @param to defines until which frame should animation run.
  13185. * @param loop defines if the animation loops
  13186. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13187. * @param onAnimationEnd defines the function to be executed when the animation ends
  13188. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13189. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13190. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13191. * @param onAnimationLoop defines the callback to call when an animation loops
  13192. * @returns the list of created animatables
  13193. */
  13194. 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[];
  13195. /**
  13196. * Begin a new animation on a given node
  13197. * @param target defines the target where the animation will take place
  13198. * @param animations defines the list of animations to start
  13199. * @param from defines the initial value
  13200. * @param to defines the final value
  13201. * @param loop defines if you want animation to loop (off by default)
  13202. * @param speedRatio defines the speed ratio to apply to all animations
  13203. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13204. * @param onAnimationLoop defines the callback to call when an animation loops
  13205. * @returns the list of created animatables
  13206. */
  13207. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13208. /**
  13209. * Begin a new animation on a given node and its hierarchy
  13210. * @param target defines the root node where the animation will take place
  13211. * @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.
  13212. * @param animations defines the list of animations to start
  13213. * @param from defines the initial value
  13214. * @param to defines the final value
  13215. * @param loop defines if you want animation to loop (off by default)
  13216. * @param speedRatio defines the speed ratio to apply to all animations
  13217. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13218. * @param onAnimationLoop defines the callback to call when an animation loops
  13219. * @returns the list of animatables created for all nodes
  13220. */
  13221. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13222. /**
  13223. * Gets the animatable associated with a specific target
  13224. * @param target defines the target of the animatable
  13225. * @returns the required animatable if found
  13226. */
  13227. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13228. /**
  13229. * Gets all animatables associated with a given target
  13230. * @param target defines the target to look animatables for
  13231. * @returns an array of Animatables
  13232. */
  13233. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13234. /**
  13235. * Stops and removes all animations that have been applied to the scene
  13236. */
  13237. stopAllAnimations(): void;
  13238. }
  13239. }
  13240. module "babylonjs/Bones/bone" {
  13241. interface Bone {
  13242. /**
  13243. * Copy an animation range from another bone
  13244. * @param source defines the source bone
  13245. * @param rangeName defines the range name to copy
  13246. * @param frameOffset defines the frame offset
  13247. * @param rescaleAsRequired defines if rescaling must be applied if required
  13248. * @param skelDimensionsRatio defines the scaling ratio
  13249. * @returns true if operation was successful
  13250. */
  13251. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13252. }
  13253. }
  13254. }
  13255. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13256. /**
  13257. * Class used to override all child animations of a given target
  13258. */
  13259. export class AnimationPropertiesOverride {
  13260. /**
  13261. * Gets or sets a value indicating if animation blending must be used
  13262. */
  13263. enableBlending: boolean;
  13264. /**
  13265. * Gets or sets the blending speed to use when enableBlending is true
  13266. */
  13267. blendingSpeed: number;
  13268. /**
  13269. * Gets or sets the default loop mode to use
  13270. */
  13271. loopMode: number;
  13272. }
  13273. }
  13274. declare module "babylonjs/Bones/skeleton" {
  13275. import { Bone } from "babylonjs/Bones/bone";
  13276. import { Observable } from "babylonjs/Misc/observable";
  13277. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13278. import { Scene } from "babylonjs/scene";
  13279. import { Nullable } from "babylonjs/types";
  13280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13281. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13282. import { Animatable } from "babylonjs/Animations/animatable";
  13283. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13284. import { Animation } from "babylonjs/Animations/animation";
  13285. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13286. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13287. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13288. /**
  13289. * Class used to handle skinning animations
  13290. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13291. */
  13292. export class Skeleton implements IAnimatable {
  13293. /** defines the skeleton name */
  13294. name: string;
  13295. /** defines the skeleton Id */
  13296. id: string;
  13297. /**
  13298. * Defines the list of child bones
  13299. */
  13300. bones: Bone[];
  13301. /**
  13302. * Defines an estimate of the dimension of the skeleton at rest
  13303. */
  13304. dimensionsAtRest: Vector3;
  13305. /**
  13306. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13307. */
  13308. needInitialSkinMatrix: boolean;
  13309. /**
  13310. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13311. */
  13312. overrideMesh: Nullable<AbstractMesh>;
  13313. /**
  13314. * Gets the list of animations attached to this skeleton
  13315. */
  13316. animations: Array<Animation>;
  13317. private _scene;
  13318. private _isDirty;
  13319. private _transformMatrices;
  13320. private _transformMatrixTexture;
  13321. private _meshesWithPoseMatrix;
  13322. private _animatables;
  13323. private _identity;
  13324. private _synchronizedWithMesh;
  13325. private _ranges;
  13326. private _lastAbsoluteTransformsUpdateId;
  13327. private _canUseTextureForBones;
  13328. private _uniqueId;
  13329. /** @hidden */
  13330. _numBonesWithLinkedTransformNode: number;
  13331. /** @hidden */
  13332. _hasWaitingData: Nullable<boolean>;
  13333. /**
  13334. * Specifies if the skeleton should be serialized
  13335. */
  13336. doNotSerialize: boolean;
  13337. private _useTextureToStoreBoneMatrices;
  13338. /**
  13339. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13340. * Please note that this option is not available if the hardware does not support it
  13341. */
  13342. useTextureToStoreBoneMatrices: boolean;
  13343. private _animationPropertiesOverride;
  13344. /**
  13345. * Gets or sets the animation properties override
  13346. */
  13347. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13348. /**
  13349. * List of inspectable custom properties (used by the Inspector)
  13350. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13351. */
  13352. inspectableCustomProperties: IInspectable[];
  13353. /**
  13354. * An observable triggered before computing the skeleton's matrices
  13355. */
  13356. onBeforeComputeObservable: Observable<Skeleton>;
  13357. /**
  13358. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13359. */
  13360. readonly isUsingTextureForMatrices: boolean;
  13361. /**
  13362. * Gets the unique ID of this skeleton
  13363. */
  13364. readonly uniqueId: number;
  13365. /**
  13366. * Creates a new skeleton
  13367. * @param name defines the skeleton name
  13368. * @param id defines the skeleton Id
  13369. * @param scene defines the hosting scene
  13370. */
  13371. constructor(
  13372. /** defines the skeleton name */
  13373. name: string,
  13374. /** defines the skeleton Id */
  13375. id: string, scene: Scene);
  13376. /**
  13377. * Gets the current object class name.
  13378. * @return the class name
  13379. */
  13380. getClassName(): string;
  13381. /**
  13382. * Returns an array containing the root bones
  13383. * @returns an array containing the root bones
  13384. */
  13385. getChildren(): Array<Bone>;
  13386. /**
  13387. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13388. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13389. * @returns a Float32Array containing matrices data
  13390. */
  13391. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13392. /**
  13393. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13394. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13395. * @returns a raw texture containing the data
  13396. */
  13397. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13398. /**
  13399. * Gets the current hosting scene
  13400. * @returns a scene object
  13401. */
  13402. getScene(): Scene;
  13403. /**
  13404. * Gets a string representing the current skeleton data
  13405. * @param fullDetails defines a boolean indicating if we want a verbose version
  13406. * @returns a string representing the current skeleton data
  13407. */
  13408. toString(fullDetails?: boolean): string;
  13409. /**
  13410. * Get bone's index searching by name
  13411. * @param name defines bone's name to search for
  13412. * @return the indice of the bone. Returns -1 if not found
  13413. */
  13414. getBoneIndexByName(name: string): number;
  13415. /**
  13416. * Creater a new animation range
  13417. * @param name defines the name of the range
  13418. * @param from defines the start key
  13419. * @param to defines the end key
  13420. */
  13421. createAnimationRange(name: string, from: number, to: number): void;
  13422. /**
  13423. * Delete a specific animation range
  13424. * @param name defines the name of the range
  13425. * @param deleteFrames defines if frames must be removed as well
  13426. */
  13427. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13428. /**
  13429. * Gets a specific animation range
  13430. * @param name defines the name of the range to look for
  13431. * @returns the requested animation range or null if not found
  13432. */
  13433. getAnimationRange(name: string): Nullable<AnimationRange>;
  13434. /**
  13435. * Gets the list of all animation ranges defined on this skeleton
  13436. * @returns an array
  13437. */
  13438. getAnimationRanges(): Nullable<AnimationRange>[];
  13439. /**
  13440. * Copy animation range from a source skeleton.
  13441. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13442. * @param source defines the source skeleton
  13443. * @param name defines the name of the range to copy
  13444. * @param rescaleAsRequired defines if rescaling must be applied if required
  13445. * @returns true if operation was successful
  13446. */
  13447. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13448. /**
  13449. * Forces the skeleton to go to rest pose
  13450. */
  13451. returnToRest(): void;
  13452. private _getHighestAnimationFrame;
  13453. /**
  13454. * Begin a specific animation range
  13455. * @param name defines the name of the range to start
  13456. * @param loop defines if looping must be turned on (false by default)
  13457. * @param speedRatio defines the speed ratio to apply (1 by default)
  13458. * @param onAnimationEnd defines a callback which will be called when animation will end
  13459. * @returns a new animatable
  13460. */
  13461. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13462. /** @hidden */
  13463. _markAsDirty(): void;
  13464. /** @hidden */
  13465. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13466. /** @hidden */
  13467. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13468. private _computeTransformMatrices;
  13469. /**
  13470. * Build all resources required to render a skeleton
  13471. */
  13472. prepare(): void;
  13473. /**
  13474. * Gets the list of animatables currently running for this skeleton
  13475. * @returns an array of animatables
  13476. */
  13477. getAnimatables(): IAnimatable[];
  13478. /**
  13479. * Clone the current skeleton
  13480. * @param name defines the name of the new skeleton
  13481. * @param id defines the id of the new skeleton
  13482. * @returns the new skeleton
  13483. */
  13484. clone(name: string, id: string): Skeleton;
  13485. /**
  13486. * Enable animation blending for this skeleton
  13487. * @param blendingSpeed defines the blending speed to apply
  13488. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13489. */
  13490. enableBlending(blendingSpeed?: number): void;
  13491. /**
  13492. * Releases all resources associated with the current skeleton
  13493. */
  13494. dispose(): void;
  13495. /**
  13496. * Serialize the skeleton in a JSON object
  13497. * @returns a JSON object
  13498. */
  13499. serialize(): any;
  13500. /**
  13501. * Creates a new skeleton from serialized data
  13502. * @param parsedSkeleton defines the serialized data
  13503. * @param scene defines the hosting scene
  13504. * @returns a new skeleton
  13505. */
  13506. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13507. /**
  13508. * Compute all node absolute transforms
  13509. * @param forceUpdate defines if computation must be done even if cache is up to date
  13510. */
  13511. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13512. /**
  13513. * Gets the root pose matrix
  13514. * @returns a matrix
  13515. */
  13516. getPoseMatrix(): Nullable<Matrix>;
  13517. /**
  13518. * Sorts bones per internal index
  13519. */
  13520. sortBones(): void;
  13521. private _sortBones;
  13522. }
  13523. }
  13524. declare module "babylonjs/Bones/bone" {
  13525. import { Skeleton } from "babylonjs/Bones/skeleton";
  13526. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13527. import { Nullable } from "babylonjs/types";
  13528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13529. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13530. import { Node } from "babylonjs/node";
  13531. import { Space } from "babylonjs/Maths/math.axis";
  13532. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13533. /**
  13534. * Class used to store bone information
  13535. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13536. */
  13537. export class Bone extends Node {
  13538. /**
  13539. * defines the bone name
  13540. */
  13541. name: string;
  13542. private static _tmpVecs;
  13543. private static _tmpQuat;
  13544. private static _tmpMats;
  13545. /**
  13546. * Gets the list of child bones
  13547. */
  13548. children: Bone[];
  13549. /** Gets the animations associated with this bone */
  13550. animations: import("babylonjs/Animations/animation").Animation[];
  13551. /**
  13552. * Gets or sets bone length
  13553. */
  13554. length: number;
  13555. /**
  13556. * @hidden Internal only
  13557. * Set this value to map this bone to a different index in the transform matrices
  13558. * Set this value to -1 to exclude the bone from the transform matrices
  13559. */
  13560. _index: Nullable<number>;
  13561. private _skeleton;
  13562. private _localMatrix;
  13563. private _restPose;
  13564. private _baseMatrix;
  13565. private _absoluteTransform;
  13566. private _invertedAbsoluteTransform;
  13567. private _parent;
  13568. private _scalingDeterminant;
  13569. private _worldTransform;
  13570. private _localScaling;
  13571. private _localRotation;
  13572. private _localPosition;
  13573. private _needToDecompose;
  13574. private _needToCompose;
  13575. /** @hidden */
  13576. _linkedTransformNode: Nullable<TransformNode>;
  13577. /** @hidden */
  13578. _waitingTransformNodeId: Nullable<string>;
  13579. /** @hidden */
  13580. /** @hidden */
  13581. _matrix: Matrix;
  13582. /**
  13583. * Create a new bone
  13584. * @param name defines the bone name
  13585. * @param skeleton defines the parent skeleton
  13586. * @param parentBone defines the parent (can be null if the bone is the root)
  13587. * @param localMatrix defines the local matrix
  13588. * @param restPose defines the rest pose matrix
  13589. * @param baseMatrix defines the base matrix
  13590. * @param index defines index of the bone in the hiearchy
  13591. */
  13592. constructor(
  13593. /**
  13594. * defines the bone name
  13595. */
  13596. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13597. /**
  13598. * Gets the current object class name.
  13599. * @return the class name
  13600. */
  13601. getClassName(): string;
  13602. /**
  13603. * Gets the parent skeleton
  13604. * @returns a skeleton
  13605. */
  13606. getSkeleton(): Skeleton;
  13607. /**
  13608. * Gets parent bone
  13609. * @returns a bone or null if the bone is the root of the bone hierarchy
  13610. */
  13611. getParent(): Nullable<Bone>;
  13612. /**
  13613. * Returns an array containing the root bones
  13614. * @returns an array containing the root bones
  13615. */
  13616. getChildren(): Array<Bone>;
  13617. /**
  13618. * Sets the parent bone
  13619. * @param parent defines the parent (can be null if the bone is the root)
  13620. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13621. */
  13622. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13623. /**
  13624. * Gets the local matrix
  13625. * @returns a matrix
  13626. */
  13627. getLocalMatrix(): Matrix;
  13628. /**
  13629. * Gets the base matrix (initial matrix which remains unchanged)
  13630. * @returns a matrix
  13631. */
  13632. getBaseMatrix(): Matrix;
  13633. /**
  13634. * Gets the rest pose matrix
  13635. * @returns a matrix
  13636. */
  13637. getRestPose(): Matrix;
  13638. /**
  13639. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13640. */
  13641. getWorldMatrix(): Matrix;
  13642. /**
  13643. * Sets the local matrix to rest pose matrix
  13644. */
  13645. returnToRest(): void;
  13646. /**
  13647. * Gets the inverse of the absolute transform matrix.
  13648. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13649. * @returns a matrix
  13650. */
  13651. getInvertedAbsoluteTransform(): Matrix;
  13652. /**
  13653. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13654. * @returns a matrix
  13655. */
  13656. getAbsoluteTransform(): Matrix;
  13657. /**
  13658. * Links with the given transform node.
  13659. * The local matrix of this bone is copied from the transform node every frame.
  13660. * @param transformNode defines the transform node to link to
  13661. */
  13662. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13663. /**
  13664. * Gets the node used to drive the bone's transformation
  13665. * @returns a transform node or null
  13666. */
  13667. getTransformNode(): Nullable<TransformNode>;
  13668. /** Gets or sets current position (in local space) */
  13669. position: Vector3;
  13670. /** Gets or sets current rotation (in local space) */
  13671. rotation: Vector3;
  13672. /** Gets or sets current rotation quaternion (in local space) */
  13673. rotationQuaternion: Quaternion;
  13674. /** Gets or sets current scaling (in local space) */
  13675. scaling: Vector3;
  13676. /**
  13677. * Gets the animation properties override
  13678. */
  13679. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13680. private _decompose;
  13681. private _compose;
  13682. /**
  13683. * Update the base and local matrices
  13684. * @param matrix defines the new base or local matrix
  13685. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13686. * @param updateLocalMatrix defines if the local matrix should be updated
  13687. */
  13688. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13689. /** @hidden */
  13690. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13691. /**
  13692. * Flag the bone as dirty (Forcing it to update everything)
  13693. */
  13694. markAsDirty(): void;
  13695. /** @hidden */
  13696. _markAsDirtyAndCompose(): void;
  13697. private _markAsDirtyAndDecompose;
  13698. /**
  13699. * Translate the bone in local or world space
  13700. * @param vec The amount to translate the bone
  13701. * @param space The space that the translation is in
  13702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13703. */
  13704. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13705. /**
  13706. * Set the postion of the bone in local or world space
  13707. * @param position The position to set the bone
  13708. * @param space The space that the position is in
  13709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13710. */
  13711. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13712. /**
  13713. * Set the absolute position of the bone (world space)
  13714. * @param position The position to set the bone
  13715. * @param mesh The mesh that this bone is attached to
  13716. */
  13717. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13718. /**
  13719. * Scale the bone on the x, y and z axes (in local space)
  13720. * @param x The amount to scale the bone on the x axis
  13721. * @param y The amount to scale the bone on the y axis
  13722. * @param z The amount to scale the bone on the z axis
  13723. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13724. */
  13725. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13726. /**
  13727. * Set the bone scaling in local space
  13728. * @param scale defines the scaling vector
  13729. */
  13730. setScale(scale: Vector3): void;
  13731. /**
  13732. * Gets the current scaling in local space
  13733. * @returns the current scaling vector
  13734. */
  13735. getScale(): Vector3;
  13736. /**
  13737. * Gets the current scaling in local space and stores it in a target vector
  13738. * @param result defines the target vector
  13739. */
  13740. getScaleToRef(result: Vector3): void;
  13741. /**
  13742. * Set the yaw, pitch, and roll of the bone in local or world space
  13743. * @param yaw The rotation of the bone on the y axis
  13744. * @param pitch The rotation of the bone on the x axis
  13745. * @param roll The rotation of the bone on the z axis
  13746. * @param space The space that the axes of rotation are in
  13747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13748. */
  13749. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13750. /**
  13751. * Add a rotation to the bone on an axis in local or world space
  13752. * @param axis The axis to rotate the bone on
  13753. * @param amount The amount to rotate the bone
  13754. * @param space The space that the axis is in
  13755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13756. */
  13757. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13758. /**
  13759. * Set the rotation of the bone to a particular axis angle in local or world space
  13760. * @param axis The axis to rotate the bone on
  13761. * @param angle The angle that the bone should be rotated to
  13762. * @param space The space that the axis is in
  13763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13764. */
  13765. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13766. /**
  13767. * Set the euler rotation of the bone in local of world space
  13768. * @param rotation The euler rotation that the bone should be set to
  13769. * @param space The space that the rotation is in
  13770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13771. */
  13772. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13773. /**
  13774. * Set the quaternion rotation of the bone in local of world space
  13775. * @param quat The quaternion rotation that the bone should be set to
  13776. * @param space The space that the rotation is in
  13777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13778. */
  13779. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13780. /**
  13781. * Set the rotation matrix of the bone in local of world space
  13782. * @param rotMat The rotation matrix that the bone should be set to
  13783. * @param space The space that the rotation is in
  13784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13785. */
  13786. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13787. private _rotateWithMatrix;
  13788. private _getNegativeRotationToRef;
  13789. /**
  13790. * Get the position of the bone in local or world space
  13791. * @param space The space that the returned position is in
  13792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13793. * @returns The position of the bone
  13794. */
  13795. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13796. /**
  13797. * Copy the position of the bone to a vector3 in local or world space
  13798. * @param space The space that the returned position is in
  13799. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13800. * @param result The vector3 to copy the position to
  13801. */
  13802. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13803. /**
  13804. * Get the absolute position of the bone (world space)
  13805. * @param mesh The mesh that this bone is attached to
  13806. * @returns The absolute position of the bone
  13807. */
  13808. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13809. /**
  13810. * Copy the absolute position of the bone (world space) to the result param
  13811. * @param mesh The mesh that this bone is attached to
  13812. * @param result The vector3 to copy the absolute position to
  13813. */
  13814. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13815. /**
  13816. * Compute the absolute transforms of this bone and its children
  13817. */
  13818. computeAbsoluteTransforms(): void;
  13819. /**
  13820. * Get the world direction from an axis that is in the local space of the bone
  13821. * @param localAxis The local direction that is used to compute the world direction
  13822. * @param mesh The mesh that this bone is attached to
  13823. * @returns The world direction
  13824. */
  13825. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13826. /**
  13827. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13828. * @param localAxis The local direction that is used to compute the world direction
  13829. * @param mesh The mesh that this bone is attached to
  13830. * @param result The vector3 that the world direction will be copied to
  13831. */
  13832. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13833. /**
  13834. * Get the euler rotation of the bone in local or world space
  13835. * @param space The space that the rotation should be in
  13836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13837. * @returns The euler rotation
  13838. */
  13839. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13840. /**
  13841. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13842. * @param space The space that the rotation should be in
  13843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13844. * @param result The vector3 that the rotation should be copied to
  13845. */
  13846. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13847. /**
  13848. * Get the quaternion rotation of the bone in either local or world space
  13849. * @param space The space that the rotation should be in
  13850. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13851. * @returns The quaternion rotation
  13852. */
  13853. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13854. /**
  13855. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13856. * @param space The space that the rotation should be in
  13857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13858. * @param result The quaternion that the rotation should be copied to
  13859. */
  13860. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13861. /**
  13862. * Get the rotation matrix of the bone in local or world space
  13863. * @param space The space that the rotation should be in
  13864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13865. * @returns The rotation matrix
  13866. */
  13867. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13868. /**
  13869. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13870. * @param space The space that the rotation should be in
  13871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13872. * @param result The quaternion that the rotation should be copied to
  13873. */
  13874. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13875. /**
  13876. * Get the world position of a point that is in the local space of the bone
  13877. * @param position The local position
  13878. * @param mesh The mesh that this bone is attached to
  13879. * @returns The world position
  13880. */
  13881. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13882. /**
  13883. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13884. * @param position The local position
  13885. * @param mesh The mesh that this bone is attached to
  13886. * @param result The vector3 that the world position should be copied to
  13887. */
  13888. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13889. /**
  13890. * Get the local position of a point that is in world space
  13891. * @param position The world position
  13892. * @param mesh The mesh that this bone is attached to
  13893. * @returns The local position
  13894. */
  13895. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13896. /**
  13897. * Get the local position of a point that is in world space and copy it to the result param
  13898. * @param position The world position
  13899. * @param mesh The mesh that this bone is attached to
  13900. * @param result The vector3 that the local position should be copied to
  13901. */
  13902. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13903. }
  13904. }
  13905. declare module "babylonjs/Meshes/transformNode" {
  13906. import { DeepImmutable } from "babylonjs/types";
  13907. import { Observable } from "babylonjs/Misc/observable";
  13908. import { Nullable } from "babylonjs/types";
  13909. import { Camera } from "babylonjs/Cameras/camera";
  13910. import { Scene } from "babylonjs/scene";
  13911. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13912. import { Node } from "babylonjs/node";
  13913. import { Bone } from "babylonjs/Bones/bone";
  13914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13915. import { Space } from "babylonjs/Maths/math.axis";
  13916. /**
  13917. * 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.
  13918. * @see https://doc.babylonjs.com/how_to/transformnode
  13919. */
  13920. export class TransformNode extends Node {
  13921. /**
  13922. * Object will not rotate to face the camera
  13923. */
  13924. static BILLBOARDMODE_NONE: number;
  13925. /**
  13926. * Object will rotate to face the camera but only on the x axis
  13927. */
  13928. static BILLBOARDMODE_X: number;
  13929. /**
  13930. * Object will rotate to face the camera but only on the y axis
  13931. */
  13932. static BILLBOARDMODE_Y: number;
  13933. /**
  13934. * Object will rotate to face the camera but only on the z axis
  13935. */
  13936. static BILLBOARDMODE_Z: number;
  13937. /**
  13938. * Object will rotate to face the camera
  13939. */
  13940. static BILLBOARDMODE_ALL: number;
  13941. /**
  13942. * Object will rotate to face the camera's position instead of orientation
  13943. */
  13944. static BILLBOARDMODE_USE_POSITION: number;
  13945. private _forward;
  13946. private _forwardInverted;
  13947. private _up;
  13948. private _right;
  13949. private _rightInverted;
  13950. private _position;
  13951. private _rotation;
  13952. private _rotationQuaternion;
  13953. protected _scaling: Vector3;
  13954. protected _isDirty: boolean;
  13955. private _transformToBoneReferal;
  13956. private _isAbsoluteSynced;
  13957. private _billboardMode;
  13958. /**
  13959. * Gets or sets the billboard mode. Default is 0.
  13960. *
  13961. * | Value | Type | Description |
  13962. * | --- | --- | --- |
  13963. * | 0 | BILLBOARDMODE_NONE | |
  13964. * | 1 | BILLBOARDMODE_X | |
  13965. * | 2 | BILLBOARDMODE_Y | |
  13966. * | 4 | BILLBOARDMODE_Z | |
  13967. * | 7 | BILLBOARDMODE_ALL | |
  13968. *
  13969. */
  13970. billboardMode: number;
  13971. private _preserveParentRotationForBillboard;
  13972. /**
  13973. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13974. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13975. */
  13976. preserveParentRotationForBillboard: boolean;
  13977. /**
  13978. * 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
  13979. */
  13980. scalingDeterminant: number;
  13981. private _infiniteDistance;
  13982. /**
  13983. * Gets or sets the distance of the object to max, often used by skybox
  13984. */
  13985. infiniteDistance: boolean;
  13986. /**
  13987. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13988. * By default the system will update normals to compensate
  13989. */
  13990. ignoreNonUniformScaling: boolean;
  13991. /**
  13992. * 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
  13993. */
  13994. reIntegrateRotationIntoRotationQuaternion: boolean;
  13995. /** @hidden */
  13996. _poseMatrix: Nullable<Matrix>;
  13997. /** @hidden */
  13998. _localMatrix: Matrix;
  13999. private _usePivotMatrix;
  14000. private _absolutePosition;
  14001. private _absoluteScaling;
  14002. private _absoluteRotationQuaternion;
  14003. private _pivotMatrix;
  14004. private _pivotMatrixInverse;
  14005. protected _postMultiplyPivotMatrix: boolean;
  14006. protected _isWorldMatrixFrozen: boolean;
  14007. /** @hidden */
  14008. _indexInSceneTransformNodesArray: number;
  14009. /**
  14010. * An event triggered after the world matrix is updated
  14011. */
  14012. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14013. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14014. /**
  14015. * Gets a string identifying the name of the class
  14016. * @returns "TransformNode" string
  14017. */
  14018. getClassName(): string;
  14019. /**
  14020. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14021. */
  14022. position: Vector3;
  14023. /**
  14024. * 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)).
  14025. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14026. */
  14027. rotation: Vector3;
  14028. /**
  14029. * 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)).
  14030. */
  14031. scaling: Vector3;
  14032. /**
  14033. * 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).
  14034. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14035. */
  14036. rotationQuaternion: Nullable<Quaternion>;
  14037. /**
  14038. * The forward direction of that transform in world space.
  14039. */
  14040. readonly forward: Vector3;
  14041. /**
  14042. * The up direction of that transform in world space.
  14043. */
  14044. readonly up: Vector3;
  14045. /**
  14046. * The right direction of that transform in world space.
  14047. */
  14048. readonly right: Vector3;
  14049. /**
  14050. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14051. * @param matrix the matrix to copy the pose from
  14052. * @returns this TransformNode.
  14053. */
  14054. updatePoseMatrix(matrix: Matrix): TransformNode;
  14055. /**
  14056. * Returns the mesh Pose matrix.
  14057. * @returns the pose matrix
  14058. */
  14059. getPoseMatrix(): Matrix;
  14060. /** @hidden */
  14061. _isSynchronized(): boolean;
  14062. /** @hidden */
  14063. _initCache(): void;
  14064. /**
  14065. * Flag the transform node as dirty (Forcing it to update everything)
  14066. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14067. * @returns this transform node
  14068. */
  14069. markAsDirty(property: string): TransformNode;
  14070. /**
  14071. * Returns the current mesh absolute position.
  14072. * Returns a Vector3.
  14073. */
  14074. readonly absolutePosition: Vector3;
  14075. /**
  14076. * Returns the current mesh absolute scaling.
  14077. * Returns a Vector3.
  14078. */
  14079. readonly absoluteScaling: Vector3;
  14080. /**
  14081. * Returns the current mesh absolute rotation.
  14082. * Returns a Quaternion.
  14083. */
  14084. readonly absoluteRotationQuaternion: Quaternion;
  14085. /**
  14086. * Sets a new matrix to apply before all other transformation
  14087. * @param matrix defines the transform matrix
  14088. * @returns the current TransformNode
  14089. */
  14090. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14091. /**
  14092. * Sets a new pivot matrix to the current node
  14093. * @param matrix defines the new pivot matrix to use
  14094. * @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
  14095. * @returns the current TransformNode
  14096. */
  14097. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14098. /**
  14099. * Returns the mesh pivot matrix.
  14100. * Default : Identity.
  14101. * @returns the matrix
  14102. */
  14103. getPivotMatrix(): Matrix;
  14104. /**
  14105. * Prevents the World matrix to be computed any longer.
  14106. * @returns the TransformNode.
  14107. */
  14108. freezeWorldMatrix(): TransformNode;
  14109. /**
  14110. * Allows back the World matrix computation.
  14111. * @returns the TransformNode.
  14112. */
  14113. unfreezeWorldMatrix(): this;
  14114. /**
  14115. * True if the World matrix has been frozen.
  14116. */
  14117. readonly isWorldMatrixFrozen: boolean;
  14118. /**
  14119. * Retuns the mesh absolute position in the World.
  14120. * @returns a Vector3.
  14121. */
  14122. getAbsolutePosition(): Vector3;
  14123. /**
  14124. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14125. * @param absolutePosition the absolute position to set
  14126. * @returns the TransformNode.
  14127. */
  14128. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14129. /**
  14130. * Sets the mesh position in its local space.
  14131. * @param vector3 the position to set in localspace
  14132. * @returns the TransformNode.
  14133. */
  14134. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14135. /**
  14136. * Returns the mesh position in the local space from the current World matrix values.
  14137. * @returns a new Vector3.
  14138. */
  14139. getPositionExpressedInLocalSpace(): Vector3;
  14140. /**
  14141. * Translates the mesh along the passed Vector3 in its local space.
  14142. * @param vector3 the distance to translate in localspace
  14143. * @returns the TransformNode.
  14144. */
  14145. locallyTranslate(vector3: Vector3): TransformNode;
  14146. private static _lookAtVectorCache;
  14147. /**
  14148. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14149. * @param targetPoint the position (must be in same space as current mesh) to look at
  14150. * @param yawCor optional yaw (y-axis) correction in radians
  14151. * @param pitchCor optional pitch (x-axis) correction in radians
  14152. * @param rollCor optional roll (z-axis) correction in radians
  14153. * @param space the choosen space of the target
  14154. * @returns the TransformNode.
  14155. */
  14156. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14157. /**
  14158. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14159. * This Vector3 is expressed in the World space.
  14160. * @param localAxis axis to rotate
  14161. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14162. */
  14163. getDirection(localAxis: Vector3): Vector3;
  14164. /**
  14165. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14166. * localAxis is expressed in the mesh local space.
  14167. * result is computed in the Wordl space from the mesh World matrix.
  14168. * @param localAxis axis to rotate
  14169. * @param result the resulting transformnode
  14170. * @returns this TransformNode.
  14171. */
  14172. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14173. /**
  14174. * Sets this transform node rotation to the given local axis.
  14175. * @param localAxis the axis in local space
  14176. * @param yawCor optional yaw (y-axis) correction in radians
  14177. * @param pitchCor optional pitch (x-axis) correction in radians
  14178. * @param rollCor optional roll (z-axis) correction in radians
  14179. * @returns this TransformNode
  14180. */
  14181. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14182. /**
  14183. * Sets a new pivot point to the current node
  14184. * @param point defines the new pivot point to use
  14185. * @param space defines if the point is in world or local space (local by default)
  14186. * @returns the current TransformNode
  14187. */
  14188. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14189. /**
  14190. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14191. * @returns the pivot point
  14192. */
  14193. getPivotPoint(): Vector3;
  14194. /**
  14195. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14196. * @param result the vector3 to store the result
  14197. * @returns this TransformNode.
  14198. */
  14199. getPivotPointToRef(result: Vector3): TransformNode;
  14200. /**
  14201. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14202. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14203. */
  14204. getAbsolutePivotPoint(): Vector3;
  14205. /**
  14206. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14207. * @param result vector3 to store the result
  14208. * @returns this TransformNode.
  14209. */
  14210. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14211. /**
  14212. * Defines the passed node as the parent of the current node.
  14213. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14214. * @see https://doc.babylonjs.com/how_to/parenting
  14215. * @param node the node ot set as the parent
  14216. * @returns this TransformNode.
  14217. */
  14218. setParent(node: Nullable<Node>): TransformNode;
  14219. private _nonUniformScaling;
  14220. /**
  14221. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14222. */
  14223. readonly nonUniformScaling: boolean;
  14224. /** @hidden */
  14225. _updateNonUniformScalingState(value: boolean): boolean;
  14226. /**
  14227. * Attach the current TransformNode to another TransformNode associated with a bone
  14228. * @param bone Bone affecting the TransformNode
  14229. * @param affectedTransformNode TransformNode associated with the bone
  14230. * @returns this object
  14231. */
  14232. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14233. /**
  14234. * Detach the transform node if its associated with a bone
  14235. * @returns this object
  14236. */
  14237. detachFromBone(): TransformNode;
  14238. private static _rotationAxisCache;
  14239. /**
  14240. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14241. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14242. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14243. * The passed axis is also normalized.
  14244. * @param axis the axis to rotate around
  14245. * @param amount the amount to rotate in radians
  14246. * @param space Space to rotate in (Default: local)
  14247. * @returns the TransformNode.
  14248. */
  14249. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14250. /**
  14251. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14252. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14253. * The passed axis is also normalized. .
  14254. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14255. * @param point the point to rotate around
  14256. * @param axis the axis to rotate around
  14257. * @param amount the amount to rotate in radians
  14258. * @returns the TransformNode
  14259. */
  14260. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14261. /**
  14262. * Translates the mesh along the axis vector for the passed distance in the given space.
  14263. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14264. * @param axis the axis to translate in
  14265. * @param distance the distance to translate
  14266. * @param space Space to rotate in (Default: local)
  14267. * @returns the TransformNode.
  14268. */
  14269. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14270. /**
  14271. * Adds a rotation step to the mesh current rotation.
  14272. * x, y, z are Euler angles expressed in radians.
  14273. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14274. * This means this rotation is made in the mesh local space only.
  14275. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14276. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14277. * ```javascript
  14278. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14279. * ```
  14280. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14281. * 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.
  14282. * @param x Rotation to add
  14283. * @param y Rotation to add
  14284. * @param z Rotation to add
  14285. * @returns the TransformNode.
  14286. */
  14287. addRotation(x: number, y: number, z: number): TransformNode;
  14288. /**
  14289. * @hidden
  14290. */
  14291. protected _getEffectiveParent(): Nullable<Node>;
  14292. /**
  14293. * Computes the world matrix of the node
  14294. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14295. * @returns the world matrix
  14296. */
  14297. computeWorldMatrix(force?: boolean): Matrix;
  14298. protected _afterComputeWorldMatrix(): void;
  14299. /**
  14300. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14301. * @param func callback function to add
  14302. *
  14303. * @returns the TransformNode.
  14304. */
  14305. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14306. /**
  14307. * Removes a registered callback function.
  14308. * @param func callback function to remove
  14309. * @returns the TransformNode.
  14310. */
  14311. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14312. /**
  14313. * Gets the position of the current mesh in camera space
  14314. * @param camera defines the camera to use
  14315. * @returns a position
  14316. */
  14317. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14318. /**
  14319. * Returns the distance from the mesh to the active camera
  14320. * @param camera defines the camera to use
  14321. * @returns the distance
  14322. */
  14323. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14324. /**
  14325. * Clone the current transform node
  14326. * @param name Name of the new clone
  14327. * @param newParent New parent for the clone
  14328. * @param doNotCloneChildren Do not clone children hierarchy
  14329. * @returns the new transform node
  14330. */
  14331. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14332. /**
  14333. * Serializes the objects information.
  14334. * @param currentSerializationObject defines the object to serialize in
  14335. * @returns the serialized object
  14336. */
  14337. serialize(currentSerializationObject?: any): any;
  14338. /**
  14339. * Returns a new TransformNode object parsed from the source provided.
  14340. * @param parsedTransformNode is the source.
  14341. * @param scene the scne the object belongs to
  14342. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14343. * @returns a new TransformNode object parsed from the source provided.
  14344. */
  14345. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14346. /**
  14347. * Get all child-transformNodes of this node
  14348. * @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
  14349. * @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
  14350. * @returns an array of TransformNode
  14351. */
  14352. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14353. /**
  14354. * Releases resources associated with this transform node.
  14355. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14356. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14357. */
  14358. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14359. /**
  14360. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14361. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14362. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14363. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14364. * @returns the current mesh
  14365. */
  14366. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14367. private _syncAbsoluteScalingAndRotation;
  14368. }
  14369. }
  14370. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14371. import { Observable } from "babylonjs/Misc/observable";
  14372. import { Nullable } from "babylonjs/types";
  14373. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14374. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14376. import { Ray } from "babylonjs/Culling/ray";
  14377. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14378. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14379. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14380. /**
  14381. * Defines the types of pose enabled controllers that are supported
  14382. */
  14383. export enum PoseEnabledControllerType {
  14384. /**
  14385. * HTC Vive
  14386. */
  14387. VIVE = 0,
  14388. /**
  14389. * Oculus Rift
  14390. */
  14391. OCULUS = 1,
  14392. /**
  14393. * Windows mixed reality
  14394. */
  14395. WINDOWS = 2,
  14396. /**
  14397. * Samsung gear VR
  14398. */
  14399. GEAR_VR = 3,
  14400. /**
  14401. * Google Daydream
  14402. */
  14403. DAYDREAM = 4,
  14404. /**
  14405. * Generic
  14406. */
  14407. GENERIC = 5
  14408. }
  14409. /**
  14410. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14411. */
  14412. export interface MutableGamepadButton {
  14413. /**
  14414. * Value of the button/trigger
  14415. */
  14416. value: number;
  14417. /**
  14418. * If the button/trigger is currently touched
  14419. */
  14420. touched: boolean;
  14421. /**
  14422. * If the button/trigger is currently pressed
  14423. */
  14424. pressed: boolean;
  14425. }
  14426. /**
  14427. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14428. * @hidden
  14429. */
  14430. export interface ExtendedGamepadButton extends GamepadButton {
  14431. /**
  14432. * If the button/trigger is currently pressed
  14433. */
  14434. readonly pressed: boolean;
  14435. /**
  14436. * If the button/trigger is currently touched
  14437. */
  14438. readonly touched: boolean;
  14439. /**
  14440. * Value of the button/trigger
  14441. */
  14442. readonly value: number;
  14443. }
  14444. /** @hidden */
  14445. export interface _GamePadFactory {
  14446. /**
  14447. * Returns wether or not the current gamepad can be created for this type of controller.
  14448. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14449. * @returns true if it can be created, otherwise false
  14450. */
  14451. canCreate(gamepadInfo: any): boolean;
  14452. /**
  14453. * Creates a new instance of the Gamepad.
  14454. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14455. * @returns the new gamepad instance
  14456. */
  14457. create(gamepadInfo: any): Gamepad;
  14458. }
  14459. /**
  14460. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14461. */
  14462. export class PoseEnabledControllerHelper {
  14463. /** @hidden */
  14464. static _ControllerFactories: _GamePadFactory[];
  14465. /** @hidden */
  14466. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14467. /**
  14468. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14469. * @param vrGamepad the gamepad to initialized
  14470. * @returns a vr controller of the type the gamepad identified as
  14471. */
  14472. static InitiateController(vrGamepad: any): Gamepad;
  14473. }
  14474. /**
  14475. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14476. */
  14477. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14478. /**
  14479. * If the controller is used in a webXR session
  14480. */
  14481. isXR: boolean;
  14482. private _deviceRoomPosition;
  14483. private _deviceRoomRotationQuaternion;
  14484. /**
  14485. * The device position in babylon space
  14486. */
  14487. devicePosition: Vector3;
  14488. /**
  14489. * The device rotation in babylon space
  14490. */
  14491. deviceRotationQuaternion: Quaternion;
  14492. /**
  14493. * The scale factor of the device in babylon space
  14494. */
  14495. deviceScaleFactor: number;
  14496. /**
  14497. * (Likely devicePosition should be used instead) The device position in its room space
  14498. */
  14499. position: Vector3;
  14500. /**
  14501. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14502. */
  14503. rotationQuaternion: Quaternion;
  14504. /**
  14505. * The type of controller (Eg. Windows mixed reality)
  14506. */
  14507. controllerType: PoseEnabledControllerType;
  14508. protected _calculatedPosition: Vector3;
  14509. private _calculatedRotation;
  14510. /**
  14511. * The raw pose from the device
  14512. */
  14513. rawPose: DevicePose;
  14514. private _trackPosition;
  14515. private _maxRotationDistFromHeadset;
  14516. private _draggedRoomRotation;
  14517. /**
  14518. * @hidden
  14519. */
  14520. _disableTrackPosition(fixedPosition: Vector3): void;
  14521. /**
  14522. * Internal, the mesh attached to the controller
  14523. * @hidden
  14524. */
  14525. _mesh: Nullable<AbstractMesh>;
  14526. private _poseControlledCamera;
  14527. private _leftHandSystemQuaternion;
  14528. /**
  14529. * Internal, matrix used to convert room space to babylon space
  14530. * @hidden
  14531. */
  14532. _deviceToWorld: Matrix;
  14533. /**
  14534. * Node to be used when casting a ray from the controller
  14535. * @hidden
  14536. */
  14537. _pointingPoseNode: Nullable<TransformNode>;
  14538. /**
  14539. * Name of the child mesh that can be used to cast a ray from the controller
  14540. */
  14541. static readonly POINTING_POSE: string;
  14542. /**
  14543. * Creates a new PoseEnabledController from a gamepad
  14544. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14545. */
  14546. constructor(browserGamepad: any);
  14547. private _workingMatrix;
  14548. /**
  14549. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14550. */
  14551. update(): void;
  14552. /**
  14553. * Updates only the pose device and mesh without doing any button event checking
  14554. */
  14555. protected _updatePoseAndMesh(): void;
  14556. /**
  14557. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14558. * @param poseData raw pose fromthe device
  14559. */
  14560. updateFromDevice(poseData: DevicePose): void;
  14561. /**
  14562. * @hidden
  14563. */
  14564. _meshAttachedObservable: Observable<AbstractMesh>;
  14565. /**
  14566. * Attaches a mesh to the controller
  14567. * @param mesh the mesh to be attached
  14568. */
  14569. attachToMesh(mesh: AbstractMesh): void;
  14570. /**
  14571. * Attaches the controllers mesh to a camera
  14572. * @param camera the camera the mesh should be attached to
  14573. */
  14574. attachToPoseControlledCamera(camera: TargetCamera): void;
  14575. /**
  14576. * Disposes of the controller
  14577. */
  14578. dispose(): void;
  14579. /**
  14580. * The mesh that is attached to the controller
  14581. */
  14582. readonly mesh: Nullable<AbstractMesh>;
  14583. /**
  14584. * Gets the ray of the controller in the direction the controller is pointing
  14585. * @param length the length the resulting ray should be
  14586. * @returns a ray in the direction the controller is pointing
  14587. */
  14588. getForwardRay(length?: number): Ray;
  14589. }
  14590. }
  14591. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14592. import { Observable } from "babylonjs/Misc/observable";
  14593. import { Scene } from "babylonjs/scene";
  14594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14595. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14596. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14597. /**
  14598. * Defines the WebVRController object that represents controllers tracked in 3D space
  14599. */
  14600. export abstract class WebVRController extends PoseEnabledController {
  14601. /**
  14602. * Internal, the default controller model for the controller
  14603. */
  14604. protected _defaultModel: AbstractMesh;
  14605. /**
  14606. * Fired when the trigger state has changed
  14607. */
  14608. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14609. /**
  14610. * Fired when the main button state has changed
  14611. */
  14612. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14613. /**
  14614. * Fired when the secondary button state has changed
  14615. */
  14616. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14617. /**
  14618. * Fired when the pad state has changed
  14619. */
  14620. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14621. /**
  14622. * Fired when controllers stick values have changed
  14623. */
  14624. onPadValuesChangedObservable: Observable<StickValues>;
  14625. /**
  14626. * Array of button availible on the controller
  14627. */
  14628. protected _buttons: Array<MutableGamepadButton>;
  14629. private _onButtonStateChange;
  14630. /**
  14631. * Fired when a controller button's state has changed
  14632. * @param callback the callback containing the button that was modified
  14633. */
  14634. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14635. /**
  14636. * X and Y axis corresponding to the controllers joystick
  14637. */
  14638. pad: StickValues;
  14639. /**
  14640. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14641. */
  14642. hand: string;
  14643. /**
  14644. * The default controller model for the controller
  14645. */
  14646. readonly defaultModel: AbstractMesh;
  14647. /**
  14648. * Creates a new WebVRController from a gamepad
  14649. * @param vrGamepad the gamepad that the WebVRController should be created from
  14650. */
  14651. constructor(vrGamepad: any);
  14652. /**
  14653. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14654. */
  14655. update(): void;
  14656. /**
  14657. * Function to be called when a button is modified
  14658. */
  14659. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14660. /**
  14661. * Loads a mesh and attaches it to the controller
  14662. * @param scene the scene the mesh should be added to
  14663. * @param meshLoaded callback for when the mesh has been loaded
  14664. */
  14665. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14666. private _setButtonValue;
  14667. private _changes;
  14668. private _checkChanges;
  14669. /**
  14670. * Disposes of th webVRCOntroller
  14671. */
  14672. dispose(): void;
  14673. }
  14674. }
  14675. declare module "babylonjs/Lights/hemisphericLight" {
  14676. import { Nullable } from "babylonjs/types";
  14677. import { Scene } from "babylonjs/scene";
  14678. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14679. import { Color3 } from "babylonjs/Maths/math.color";
  14680. import { Effect } from "babylonjs/Materials/effect";
  14681. import { Light } from "babylonjs/Lights/light";
  14682. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14683. /**
  14684. * The HemisphericLight simulates the ambient environment light,
  14685. * so the passed direction is the light reflection direction, not the incoming direction.
  14686. */
  14687. export class HemisphericLight extends Light {
  14688. /**
  14689. * The groundColor is the light in the opposite direction to the one specified during creation.
  14690. * 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.
  14691. */
  14692. groundColor: Color3;
  14693. /**
  14694. * The light reflection direction, not the incoming direction.
  14695. */
  14696. direction: Vector3;
  14697. /**
  14698. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14699. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14700. * The HemisphericLight can't cast shadows.
  14701. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14702. * @param name The friendly name of the light
  14703. * @param direction The direction of the light reflection
  14704. * @param scene The scene the light belongs to
  14705. */
  14706. constructor(name: string, direction: Vector3, scene: Scene);
  14707. protected _buildUniformLayout(): void;
  14708. /**
  14709. * Returns the string "HemisphericLight".
  14710. * @return The class name
  14711. */
  14712. getClassName(): string;
  14713. /**
  14714. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14715. * Returns the updated direction.
  14716. * @param target The target the direction should point to
  14717. * @return The computed direction
  14718. */
  14719. setDirectionToTarget(target: Vector3): Vector3;
  14720. /**
  14721. * Returns the shadow generator associated to the light.
  14722. * @returns Always null for hemispheric lights because it does not support shadows.
  14723. */
  14724. getShadowGenerator(): Nullable<IShadowGenerator>;
  14725. /**
  14726. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14727. * @param effect The effect to update
  14728. * @param lightIndex The index of the light in the effect to update
  14729. * @returns The hemispheric light
  14730. */
  14731. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14732. /**
  14733. * Computes the world matrix of the node
  14734. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14735. * @param useWasUpdatedFlag defines a reserved property
  14736. * @returns the world matrix
  14737. */
  14738. computeWorldMatrix(): Matrix;
  14739. /**
  14740. * Returns the integer 3.
  14741. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14742. */
  14743. getTypeID(): number;
  14744. /**
  14745. * Prepares the list of defines specific to the light type.
  14746. * @param defines the list of defines
  14747. * @param lightIndex defines the index of the light for the effect
  14748. */
  14749. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14750. }
  14751. }
  14752. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14753. /** @hidden */
  14754. export var vrMultiviewToSingleviewPixelShader: {
  14755. name: string;
  14756. shader: string;
  14757. };
  14758. }
  14759. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14760. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14761. import { Scene } from "babylonjs/scene";
  14762. /**
  14763. * Renders to multiple views with a single draw call
  14764. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14765. */
  14766. export class MultiviewRenderTarget extends RenderTargetTexture {
  14767. /**
  14768. * Creates a multiview render target
  14769. * @param scene scene used with the render target
  14770. * @param size the size of the render target (used for each view)
  14771. */
  14772. constructor(scene: Scene, size?: number | {
  14773. width: number;
  14774. height: number;
  14775. } | {
  14776. ratio: number;
  14777. });
  14778. /**
  14779. * @hidden
  14780. * @param faceIndex the face index, if its a cube texture
  14781. */
  14782. _bindFrameBuffer(faceIndex?: number): void;
  14783. /**
  14784. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14785. * @returns the view count
  14786. */
  14787. getViewCount(): number;
  14788. }
  14789. }
  14790. declare module "babylonjs/Maths/math.frustum" {
  14791. import { Matrix } from "babylonjs/Maths/math.vector";
  14792. import { DeepImmutable } from "babylonjs/types";
  14793. import { Plane } from "babylonjs/Maths/math.plane";
  14794. /**
  14795. * Reprasents a camera frustum
  14796. */
  14797. export class Frustum {
  14798. /**
  14799. * Gets the planes representing the frustum
  14800. * @param transform matrix to be applied to the returned planes
  14801. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14802. */
  14803. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14804. /**
  14805. * Gets the near frustum plane transformed by the transform matrix
  14806. * @param transform transformation matrix to be applied to the resulting frustum plane
  14807. * @param frustumPlane the resuling frustum plane
  14808. */
  14809. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14810. /**
  14811. * Gets the far frustum plane transformed by the transform matrix
  14812. * @param transform transformation matrix to be applied to the resulting frustum plane
  14813. * @param frustumPlane the resuling frustum plane
  14814. */
  14815. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14816. /**
  14817. * Gets the left frustum plane transformed by the transform matrix
  14818. * @param transform transformation matrix to be applied to the resulting frustum plane
  14819. * @param frustumPlane the resuling frustum plane
  14820. */
  14821. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14822. /**
  14823. * Gets the right frustum plane transformed by the transform matrix
  14824. * @param transform transformation matrix to be applied to the resulting frustum plane
  14825. * @param frustumPlane the resuling frustum plane
  14826. */
  14827. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14828. /**
  14829. * Gets the top frustum plane transformed by the transform matrix
  14830. * @param transform transformation matrix to be applied to the resulting frustum plane
  14831. * @param frustumPlane the resuling frustum plane
  14832. */
  14833. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14834. /**
  14835. * Gets the bottom frustum plane transformed by the transform matrix
  14836. * @param transform transformation matrix to be applied to the resulting frustum plane
  14837. * @param frustumPlane the resuling frustum plane
  14838. */
  14839. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14840. /**
  14841. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14842. * @param transform transformation matrix to be applied to the resulting frustum planes
  14843. * @param frustumPlanes the resuling frustum planes
  14844. */
  14845. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14846. }
  14847. }
  14848. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14849. import { Camera } from "babylonjs/Cameras/camera";
  14850. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14851. import { Nullable } from "babylonjs/types";
  14852. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14853. import { Matrix } from "babylonjs/Maths/math.vector";
  14854. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14855. module "babylonjs/Engines/engine" {
  14856. interface Engine {
  14857. /**
  14858. * Creates a new multiview render target
  14859. * @param width defines the width of the texture
  14860. * @param height defines the height of the texture
  14861. * @returns the created multiview texture
  14862. */
  14863. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14864. /**
  14865. * Binds a multiview framebuffer to be drawn to
  14866. * @param multiviewTexture texture to bind
  14867. */
  14868. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14869. }
  14870. }
  14871. module "babylonjs/Cameras/camera" {
  14872. interface Camera {
  14873. /**
  14874. * @hidden
  14875. * 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)
  14876. */
  14877. _useMultiviewToSingleView: boolean;
  14878. /**
  14879. * @hidden
  14880. * 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)
  14881. */
  14882. _multiviewTexture: Nullable<RenderTargetTexture>;
  14883. /**
  14884. * @hidden
  14885. * ensures the multiview texture of the camera exists and has the specified width/height
  14886. * @param width height to set on the multiview texture
  14887. * @param height width to set on the multiview texture
  14888. */
  14889. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14890. }
  14891. }
  14892. module "babylonjs/scene" {
  14893. interface Scene {
  14894. /** @hidden */
  14895. _transformMatrixR: Matrix;
  14896. /** @hidden */
  14897. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14898. /** @hidden */
  14899. _createMultiviewUbo(): void;
  14900. /** @hidden */
  14901. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14902. /** @hidden */
  14903. _renderMultiviewToSingleView(camera: Camera): void;
  14904. }
  14905. }
  14906. }
  14907. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14908. import { Camera } from "babylonjs/Cameras/camera";
  14909. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14910. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14911. import "babylonjs/Engines/Extensions/engine.multiview";
  14912. /**
  14913. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14914. * This will not be used for webXR as it supports displaying texture arrays directly
  14915. */
  14916. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14917. /**
  14918. * Initializes a VRMultiviewToSingleview
  14919. * @param name name of the post process
  14920. * @param camera camera to be applied to
  14921. * @param scaleFactor scaling factor to the size of the output texture
  14922. */
  14923. constructor(name: string, camera: Camera, scaleFactor: number);
  14924. }
  14925. }
  14926. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14927. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14928. import { Nullable } from "babylonjs/types";
  14929. import { Size } from "babylonjs/Maths/math.size";
  14930. import { Observable } from "babylonjs/Misc/observable";
  14931. module "babylonjs/Engines/engine" {
  14932. interface Engine {
  14933. /** @hidden */
  14934. _vrDisplay: any;
  14935. /** @hidden */
  14936. _vrSupported: boolean;
  14937. /** @hidden */
  14938. _oldSize: Size;
  14939. /** @hidden */
  14940. _oldHardwareScaleFactor: number;
  14941. /** @hidden */
  14942. _vrExclusivePointerMode: boolean;
  14943. /** @hidden */
  14944. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14945. /** @hidden */
  14946. _onVRDisplayPointerRestricted: () => void;
  14947. /** @hidden */
  14948. _onVRDisplayPointerUnrestricted: () => void;
  14949. /** @hidden */
  14950. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14951. /** @hidden */
  14952. _onVrDisplayDisconnect: Nullable<() => void>;
  14953. /** @hidden */
  14954. _onVrDisplayPresentChange: Nullable<() => void>;
  14955. /**
  14956. * Observable signaled when VR display mode changes
  14957. */
  14958. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14959. /**
  14960. * Observable signaled when VR request present is complete
  14961. */
  14962. onVRRequestPresentComplete: Observable<boolean>;
  14963. /**
  14964. * Observable signaled when VR request present starts
  14965. */
  14966. onVRRequestPresentStart: Observable<Engine>;
  14967. /**
  14968. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14969. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14970. */
  14971. isInVRExclusivePointerMode: boolean;
  14972. /**
  14973. * Gets a boolean indicating if a webVR device was detected
  14974. * @returns true if a webVR device was detected
  14975. */
  14976. isVRDevicePresent(): boolean;
  14977. /**
  14978. * Gets the current webVR device
  14979. * @returns the current webVR device (or null)
  14980. */
  14981. getVRDevice(): any;
  14982. /**
  14983. * Initializes a webVR display and starts listening to display change events
  14984. * The onVRDisplayChangedObservable will be notified upon these changes
  14985. * @returns A promise containing a VRDisplay and if vr is supported
  14986. */
  14987. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14988. /** @hidden */
  14989. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14990. /**
  14991. * Call this function to switch to webVR mode
  14992. * Will do nothing if webVR is not supported or if there is no webVR device
  14993. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14994. */
  14995. enableVR(): void;
  14996. /** @hidden */
  14997. _onVRFullScreenTriggered(): void;
  14998. }
  14999. }
  15000. }
  15001. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15002. import { Nullable } from "babylonjs/types";
  15003. import { Observable } from "babylonjs/Misc/observable";
  15004. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15005. import { Scene } from "babylonjs/scene";
  15006. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15007. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15008. import { Node } from "babylonjs/node";
  15009. import { Ray } from "babylonjs/Culling/ray";
  15010. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15011. import "babylonjs/Engines/Extensions/engine.webVR";
  15012. /**
  15013. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15014. * IMPORTANT!! The data is right-hand data.
  15015. * @export
  15016. * @interface DevicePose
  15017. */
  15018. export interface DevicePose {
  15019. /**
  15020. * The position of the device, values in array are [x,y,z].
  15021. */
  15022. readonly position: Nullable<Float32Array>;
  15023. /**
  15024. * The linearVelocity of the device, values in array are [x,y,z].
  15025. */
  15026. readonly linearVelocity: Nullable<Float32Array>;
  15027. /**
  15028. * The linearAcceleration of the device, values in array are [x,y,z].
  15029. */
  15030. readonly linearAcceleration: Nullable<Float32Array>;
  15031. /**
  15032. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15033. */
  15034. readonly orientation: Nullable<Float32Array>;
  15035. /**
  15036. * The angularVelocity of the device, values in array are [x,y,z].
  15037. */
  15038. readonly angularVelocity: Nullable<Float32Array>;
  15039. /**
  15040. * The angularAcceleration of the device, values in array are [x,y,z].
  15041. */
  15042. readonly angularAcceleration: Nullable<Float32Array>;
  15043. }
  15044. /**
  15045. * Interface representing a pose controlled object in Babylon.
  15046. * A pose controlled object has both regular pose values as well as pose values
  15047. * from an external device such as a VR head mounted display
  15048. */
  15049. export interface PoseControlled {
  15050. /**
  15051. * The position of the object in babylon space.
  15052. */
  15053. position: Vector3;
  15054. /**
  15055. * The rotation quaternion of the object in babylon space.
  15056. */
  15057. rotationQuaternion: Quaternion;
  15058. /**
  15059. * The position of the device in babylon space.
  15060. */
  15061. devicePosition?: Vector3;
  15062. /**
  15063. * The rotation quaternion of the device in babylon space.
  15064. */
  15065. deviceRotationQuaternion: Quaternion;
  15066. /**
  15067. * The raw pose coming from the device.
  15068. */
  15069. rawPose: Nullable<DevicePose>;
  15070. /**
  15071. * The scale of the device to be used when translating from device space to babylon space.
  15072. */
  15073. deviceScaleFactor: number;
  15074. /**
  15075. * Updates the poseControlled values based on the input device pose.
  15076. * @param poseData the pose data to update the object with
  15077. */
  15078. updateFromDevice(poseData: DevicePose): void;
  15079. }
  15080. /**
  15081. * Set of options to customize the webVRCamera
  15082. */
  15083. export interface WebVROptions {
  15084. /**
  15085. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15086. */
  15087. trackPosition?: boolean;
  15088. /**
  15089. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15090. */
  15091. positionScale?: number;
  15092. /**
  15093. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15094. */
  15095. displayName?: string;
  15096. /**
  15097. * Should the native controller meshes be initialized. (default: true)
  15098. */
  15099. controllerMeshes?: boolean;
  15100. /**
  15101. * Creating a default HemiLight only on controllers. (default: true)
  15102. */
  15103. defaultLightingOnControllers?: boolean;
  15104. /**
  15105. * If you don't want to use the default VR button of the helper. (default: false)
  15106. */
  15107. useCustomVRButton?: boolean;
  15108. /**
  15109. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15110. */
  15111. customVRButton?: HTMLButtonElement;
  15112. /**
  15113. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15114. */
  15115. rayLength?: number;
  15116. /**
  15117. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15118. */
  15119. defaultHeight?: number;
  15120. /**
  15121. * If multiview should be used if availible (default: false)
  15122. */
  15123. useMultiview?: boolean;
  15124. }
  15125. /**
  15126. * This represents a WebVR camera.
  15127. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15128. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15129. */
  15130. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15131. private webVROptions;
  15132. /**
  15133. * @hidden
  15134. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15135. */
  15136. _vrDevice: any;
  15137. /**
  15138. * The rawPose of the vrDevice.
  15139. */
  15140. rawPose: Nullable<DevicePose>;
  15141. private _onVREnabled;
  15142. private _specsVersion;
  15143. private _attached;
  15144. private _frameData;
  15145. protected _descendants: Array<Node>;
  15146. private _deviceRoomPosition;
  15147. /** @hidden */
  15148. _deviceRoomRotationQuaternion: Quaternion;
  15149. private _standingMatrix;
  15150. /**
  15151. * Represents device position in babylon space.
  15152. */
  15153. devicePosition: Vector3;
  15154. /**
  15155. * Represents device rotation in babylon space.
  15156. */
  15157. deviceRotationQuaternion: Quaternion;
  15158. /**
  15159. * The scale of the device to be used when translating from device space to babylon space.
  15160. */
  15161. deviceScaleFactor: number;
  15162. private _deviceToWorld;
  15163. private _worldToDevice;
  15164. /**
  15165. * References to the webVR controllers for the vrDevice.
  15166. */
  15167. controllers: Array<WebVRController>;
  15168. /**
  15169. * Emits an event when a controller is attached.
  15170. */
  15171. onControllersAttachedObservable: Observable<WebVRController[]>;
  15172. /**
  15173. * Emits an event when a controller's mesh has been loaded;
  15174. */
  15175. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15176. /**
  15177. * Emits an event when the HMD's pose has been updated.
  15178. */
  15179. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15180. private _poseSet;
  15181. /**
  15182. * If the rig cameras be used as parent instead of this camera.
  15183. */
  15184. rigParenting: boolean;
  15185. private _lightOnControllers;
  15186. private _defaultHeight?;
  15187. /**
  15188. * Instantiates a WebVRFreeCamera.
  15189. * @param name The name of the WebVRFreeCamera
  15190. * @param position The starting anchor position for the camera
  15191. * @param scene The scene the camera belongs to
  15192. * @param webVROptions a set of customizable options for the webVRCamera
  15193. */
  15194. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15195. /**
  15196. * Gets the device distance from the ground in meters.
  15197. * @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.
  15198. */
  15199. deviceDistanceToRoomGround(): number;
  15200. /**
  15201. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15202. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15203. */
  15204. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15205. /**
  15206. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15207. * @returns A promise with a boolean set to if the standing matrix is supported.
  15208. */
  15209. useStandingMatrixAsync(): Promise<boolean>;
  15210. /**
  15211. * Disposes the camera
  15212. */
  15213. dispose(): void;
  15214. /**
  15215. * Gets a vrController by name.
  15216. * @param name The name of the controller to retreive
  15217. * @returns the controller matching the name specified or null if not found
  15218. */
  15219. getControllerByName(name: string): Nullable<WebVRController>;
  15220. private _leftController;
  15221. /**
  15222. * The controller corresponding to the users left hand.
  15223. */
  15224. readonly leftController: Nullable<WebVRController>;
  15225. private _rightController;
  15226. /**
  15227. * The controller corresponding to the users right hand.
  15228. */
  15229. readonly rightController: Nullable<WebVRController>;
  15230. /**
  15231. * Casts a ray forward from the vrCamera's gaze.
  15232. * @param length Length of the ray (default: 100)
  15233. * @returns the ray corresponding to the gaze
  15234. */
  15235. getForwardRay(length?: number): Ray;
  15236. /**
  15237. * @hidden
  15238. * Updates the camera based on device's frame data
  15239. */
  15240. _checkInputs(): void;
  15241. /**
  15242. * Updates the poseControlled values based on the input device pose.
  15243. * @param poseData Pose coming from the device
  15244. */
  15245. updateFromDevice(poseData: DevicePose): void;
  15246. private _htmlElementAttached;
  15247. private _detachIfAttached;
  15248. /**
  15249. * WebVR's attach control will start broadcasting frames to the device.
  15250. * Note that in certain browsers (chrome for example) this function must be called
  15251. * within a user-interaction callback. Example:
  15252. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15253. *
  15254. * @param element html element to attach the vrDevice to
  15255. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15256. */
  15257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15258. /**
  15259. * Detaches the camera from the html element and disables VR
  15260. *
  15261. * @param element html element to detach from
  15262. */
  15263. detachControl(element: HTMLElement): void;
  15264. /**
  15265. * @returns the name of this class
  15266. */
  15267. getClassName(): string;
  15268. /**
  15269. * Calls resetPose on the vrDisplay
  15270. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15271. */
  15272. resetToCurrentRotation(): void;
  15273. /**
  15274. * @hidden
  15275. * Updates the rig cameras (left and right eye)
  15276. */
  15277. _updateRigCameras(): void;
  15278. private _workingVector;
  15279. private _oneVector;
  15280. private _workingMatrix;
  15281. private updateCacheCalled;
  15282. private _correctPositionIfNotTrackPosition;
  15283. /**
  15284. * @hidden
  15285. * Updates the cached values of the camera
  15286. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15287. */
  15288. _updateCache(ignoreParentClass?: boolean): void;
  15289. /**
  15290. * @hidden
  15291. * Get current device position in babylon world
  15292. */
  15293. _computeDevicePosition(): void;
  15294. /**
  15295. * Updates the current device position and rotation in the babylon world
  15296. */
  15297. update(): void;
  15298. /**
  15299. * @hidden
  15300. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15301. * @returns an identity matrix
  15302. */
  15303. _getViewMatrix(): Matrix;
  15304. private _tmpMatrix;
  15305. /**
  15306. * This function is called by the two RIG cameras.
  15307. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15308. * @hidden
  15309. */
  15310. _getWebVRViewMatrix(): Matrix;
  15311. /** @hidden */
  15312. _getWebVRProjectionMatrix(): Matrix;
  15313. private _onGamepadConnectedObserver;
  15314. private _onGamepadDisconnectedObserver;
  15315. private _updateCacheWhenTrackingDisabledObserver;
  15316. /**
  15317. * Initializes the controllers and their meshes
  15318. */
  15319. initControllers(): void;
  15320. }
  15321. }
  15322. declare module "babylonjs/PostProcesses/postProcess" {
  15323. import { Nullable } from "babylonjs/types";
  15324. import { SmartArray } from "babylonjs/Misc/smartArray";
  15325. import { Observable } from "babylonjs/Misc/observable";
  15326. import { Vector2 } from "babylonjs/Maths/math.vector";
  15327. import { Camera } from "babylonjs/Cameras/camera";
  15328. import { Effect } from "babylonjs/Materials/effect";
  15329. import "babylonjs/Shaders/postprocess.vertex";
  15330. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15331. import { Engine } from "babylonjs/Engines/engine";
  15332. import { Color4 } from "babylonjs/Maths/math.color";
  15333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15334. /**
  15335. * Size options for a post process
  15336. */
  15337. export type PostProcessOptions = {
  15338. width: number;
  15339. height: number;
  15340. };
  15341. /**
  15342. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15343. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15344. */
  15345. export class PostProcess {
  15346. /** Name of the PostProcess. */
  15347. name: string;
  15348. /**
  15349. * Gets or sets the unique id of the post process
  15350. */
  15351. uniqueId: number;
  15352. /**
  15353. * Width of the texture to apply the post process on
  15354. */
  15355. width: number;
  15356. /**
  15357. * Height of the texture to apply the post process on
  15358. */
  15359. height: number;
  15360. /**
  15361. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15362. * @hidden
  15363. */
  15364. _outputTexture: Nullable<InternalTexture>;
  15365. /**
  15366. * Sampling mode used by the shader
  15367. * See https://doc.babylonjs.com/classes/3.1/texture
  15368. */
  15369. renderTargetSamplingMode: number;
  15370. /**
  15371. * Clear color to use when screen clearing
  15372. */
  15373. clearColor: Color4;
  15374. /**
  15375. * If the buffer needs to be cleared before applying the post process. (default: true)
  15376. * Should be set to false if shader will overwrite all previous pixels.
  15377. */
  15378. autoClear: boolean;
  15379. /**
  15380. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15381. */
  15382. alphaMode: number;
  15383. /**
  15384. * Sets the setAlphaBlendConstants of the babylon engine
  15385. */
  15386. alphaConstants: Color4;
  15387. /**
  15388. * Animations to be used for the post processing
  15389. */
  15390. animations: import("babylonjs/Animations/animation").Animation[];
  15391. /**
  15392. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15393. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15394. */
  15395. enablePixelPerfectMode: boolean;
  15396. /**
  15397. * Force the postprocess to be applied without taking in account viewport
  15398. */
  15399. forceFullscreenViewport: boolean;
  15400. /**
  15401. * List of inspectable custom properties (used by the Inspector)
  15402. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15403. */
  15404. inspectableCustomProperties: IInspectable[];
  15405. /**
  15406. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15407. *
  15408. * | Value | Type | Description |
  15409. * | ----- | ----------------------------------- | ----------- |
  15410. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15411. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15412. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15413. *
  15414. */
  15415. scaleMode: number;
  15416. /**
  15417. * Force textures to be a power of two (default: false)
  15418. */
  15419. alwaysForcePOT: boolean;
  15420. private _samples;
  15421. /**
  15422. * Number of sample textures (default: 1)
  15423. */
  15424. samples: number;
  15425. /**
  15426. * Modify the scale of the post process to be the same as the viewport (default: false)
  15427. */
  15428. adaptScaleToCurrentViewport: boolean;
  15429. private _camera;
  15430. private _scene;
  15431. private _engine;
  15432. private _options;
  15433. private _reusable;
  15434. private _textureType;
  15435. /**
  15436. * Smart array of input and output textures for the post process.
  15437. * @hidden
  15438. */
  15439. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15440. /**
  15441. * The index in _textures that corresponds to the output texture.
  15442. * @hidden
  15443. */
  15444. _currentRenderTextureInd: number;
  15445. private _effect;
  15446. private _samplers;
  15447. private _fragmentUrl;
  15448. private _vertexUrl;
  15449. private _parameters;
  15450. private _scaleRatio;
  15451. protected _indexParameters: any;
  15452. private _shareOutputWithPostProcess;
  15453. private _texelSize;
  15454. private _forcedOutputTexture;
  15455. /**
  15456. * Returns the fragment url or shader name used in the post process.
  15457. * @returns the fragment url or name in the shader store.
  15458. */
  15459. getEffectName(): string;
  15460. /**
  15461. * An event triggered when the postprocess is activated.
  15462. */
  15463. onActivateObservable: Observable<Camera>;
  15464. private _onActivateObserver;
  15465. /**
  15466. * A function that is added to the onActivateObservable
  15467. */
  15468. onActivate: Nullable<(camera: Camera) => void>;
  15469. /**
  15470. * An event triggered when the postprocess changes its size.
  15471. */
  15472. onSizeChangedObservable: Observable<PostProcess>;
  15473. private _onSizeChangedObserver;
  15474. /**
  15475. * A function that is added to the onSizeChangedObservable
  15476. */
  15477. onSizeChanged: (postProcess: PostProcess) => void;
  15478. /**
  15479. * An event triggered when the postprocess applies its effect.
  15480. */
  15481. onApplyObservable: Observable<Effect>;
  15482. private _onApplyObserver;
  15483. /**
  15484. * A function that is added to the onApplyObservable
  15485. */
  15486. onApply: (effect: Effect) => void;
  15487. /**
  15488. * An event triggered before rendering the postprocess
  15489. */
  15490. onBeforeRenderObservable: Observable<Effect>;
  15491. private _onBeforeRenderObserver;
  15492. /**
  15493. * A function that is added to the onBeforeRenderObservable
  15494. */
  15495. onBeforeRender: (effect: Effect) => void;
  15496. /**
  15497. * An event triggered after rendering the postprocess
  15498. */
  15499. onAfterRenderObservable: Observable<Effect>;
  15500. private _onAfterRenderObserver;
  15501. /**
  15502. * A function that is added to the onAfterRenderObservable
  15503. */
  15504. onAfterRender: (efect: Effect) => void;
  15505. /**
  15506. * 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
  15507. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15508. */
  15509. inputTexture: InternalTexture;
  15510. /**
  15511. * Gets the camera which post process is applied to.
  15512. * @returns The camera the post process is applied to.
  15513. */
  15514. getCamera(): Camera;
  15515. /**
  15516. * Gets the texel size of the postprocess.
  15517. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15518. */
  15519. readonly texelSize: Vector2;
  15520. /**
  15521. * Creates a new instance PostProcess
  15522. * @param name The name of the PostProcess.
  15523. * @param fragmentUrl The url of the fragment shader to be used.
  15524. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15525. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15526. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15527. * @param camera The camera to apply the render pass to.
  15528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15529. * @param engine The engine which the post process will be applied. (default: current engine)
  15530. * @param reusable If the post process can be reused on the same frame. (default: false)
  15531. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15532. * @param textureType Type of textures used when performing the post process. (default: 0)
  15533. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15534. * @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
  15535. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15536. */
  15537. constructor(
  15538. /** Name of the PostProcess. */
  15539. 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);
  15540. /**
  15541. * Gets a string idenfifying the name of the class
  15542. * @returns "PostProcess" string
  15543. */
  15544. getClassName(): string;
  15545. /**
  15546. * Gets the engine which this post process belongs to.
  15547. * @returns The engine the post process was enabled with.
  15548. */
  15549. getEngine(): Engine;
  15550. /**
  15551. * The effect that is created when initializing the post process.
  15552. * @returns The created effect corresponding the the postprocess.
  15553. */
  15554. getEffect(): Effect;
  15555. /**
  15556. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15557. * @param postProcess The post process to share the output with.
  15558. * @returns This post process.
  15559. */
  15560. shareOutputWith(postProcess: PostProcess): PostProcess;
  15561. /**
  15562. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15563. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15564. */
  15565. useOwnOutput(): void;
  15566. /**
  15567. * Updates the effect with the current post process compile time values and recompiles the shader.
  15568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15571. * @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
  15572. * @param onCompiled Called when the shader has been compiled.
  15573. * @param onError Called if there is an error when compiling a shader.
  15574. */
  15575. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15576. /**
  15577. * The post process is reusable if it can be used multiple times within one frame.
  15578. * @returns If the post process is reusable
  15579. */
  15580. isReusable(): boolean;
  15581. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15582. markTextureDirty(): void;
  15583. /**
  15584. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15585. * 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.
  15586. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15587. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15588. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15589. * @returns The target texture that was bound to be written to.
  15590. */
  15591. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15592. /**
  15593. * If the post process is supported.
  15594. */
  15595. readonly isSupported: boolean;
  15596. /**
  15597. * The aspect ratio of the output texture.
  15598. */
  15599. readonly aspectRatio: number;
  15600. /**
  15601. * Get a value indicating if the post-process is ready to be used
  15602. * @returns true if the post-process is ready (shader is compiled)
  15603. */
  15604. isReady(): boolean;
  15605. /**
  15606. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15607. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15608. */
  15609. apply(): Nullable<Effect>;
  15610. private _disposeTextures;
  15611. /**
  15612. * Disposes the post process.
  15613. * @param camera The camera to dispose the post process on.
  15614. */
  15615. dispose(camera?: Camera): void;
  15616. }
  15617. }
  15618. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15619. /** @hidden */
  15620. export var kernelBlurVaryingDeclaration: {
  15621. name: string;
  15622. shader: string;
  15623. };
  15624. }
  15625. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15626. /** @hidden */
  15627. export var kernelBlurFragment: {
  15628. name: string;
  15629. shader: string;
  15630. };
  15631. }
  15632. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15633. /** @hidden */
  15634. export var kernelBlurFragment2: {
  15635. name: string;
  15636. shader: string;
  15637. };
  15638. }
  15639. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15640. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15641. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15642. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15643. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15644. /** @hidden */
  15645. export var kernelBlurPixelShader: {
  15646. name: string;
  15647. shader: string;
  15648. };
  15649. }
  15650. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15651. /** @hidden */
  15652. export var kernelBlurVertex: {
  15653. name: string;
  15654. shader: string;
  15655. };
  15656. }
  15657. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15658. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15659. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15660. /** @hidden */
  15661. export var kernelBlurVertexShader: {
  15662. name: string;
  15663. shader: string;
  15664. };
  15665. }
  15666. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15667. import { Vector2 } from "babylonjs/Maths/math.vector";
  15668. import { Nullable } from "babylonjs/types";
  15669. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15670. import { Camera } from "babylonjs/Cameras/camera";
  15671. import { Effect } from "babylonjs/Materials/effect";
  15672. import { Engine } from "babylonjs/Engines/engine";
  15673. import "babylonjs/Shaders/kernelBlur.fragment";
  15674. import "babylonjs/Shaders/kernelBlur.vertex";
  15675. /**
  15676. * The Blur Post Process which blurs an image based on a kernel and direction.
  15677. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15678. */
  15679. export class BlurPostProcess extends PostProcess {
  15680. /** The direction in which to blur the image. */
  15681. direction: Vector2;
  15682. private blockCompilation;
  15683. protected _kernel: number;
  15684. protected _idealKernel: number;
  15685. protected _packedFloat: boolean;
  15686. private _staticDefines;
  15687. /**
  15688. * Sets the length in pixels of the blur sample region
  15689. */
  15690. /**
  15691. * Gets the length in pixels of the blur sample region
  15692. */
  15693. kernel: number;
  15694. /**
  15695. * Sets wether or not the blur needs to unpack/repack floats
  15696. */
  15697. /**
  15698. * Gets wether or not the blur is unpacking/repacking floats
  15699. */
  15700. packedFloat: boolean;
  15701. /**
  15702. * Creates a new instance BlurPostProcess
  15703. * @param name The name of the effect.
  15704. * @param direction The direction in which to blur the image.
  15705. * @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.
  15706. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15707. * @param camera The camera to apply the render pass to.
  15708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15709. * @param engine The engine which the post process will be applied. (default: current engine)
  15710. * @param reusable If the post process can be reused on the same frame. (default: false)
  15711. * @param textureType Type of textures used when performing the post process. (default: 0)
  15712. * @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)
  15713. */
  15714. constructor(name: string,
  15715. /** The direction in which to blur the image. */
  15716. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15717. /**
  15718. * Updates the effect with the current post process compile time values and recompiles the shader.
  15719. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15720. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15721. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15722. * @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
  15723. * @param onCompiled Called when the shader has been compiled.
  15724. * @param onError Called if there is an error when compiling a shader.
  15725. */
  15726. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15727. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15728. /**
  15729. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15730. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15731. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15732. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15733. * The gaps between physical kernels are compensated for in the weighting of the samples
  15734. * @param idealKernel Ideal blur kernel.
  15735. * @return Nearest best kernel.
  15736. */
  15737. protected _nearestBestKernel(idealKernel: number): number;
  15738. /**
  15739. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15740. * @param x The point on the Gaussian distribution to sample.
  15741. * @return the value of the Gaussian function at x.
  15742. */
  15743. protected _gaussianWeight(x: number): number;
  15744. /**
  15745. * Generates a string that can be used as a floating point number in GLSL.
  15746. * @param x Value to print.
  15747. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15748. * @return GLSL float string.
  15749. */
  15750. protected _glslFloat(x: number, decimalFigures?: number): string;
  15751. }
  15752. }
  15753. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15754. import { Scene } from "babylonjs/scene";
  15755. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15756. import { Plane } from "babylonjs/Maths/math.plane";
  15757. /**
  15758. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15759. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15760. * You can then easily use it as a reflectionTexture on a flat surface.
  15761. * In case the surface is not a plane, please consider relying on reflection probes.
  15762. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15763. */
  15764. export class MirrorTexture extends RenderTargetTexture {
  15765. private scene;
  15766. /**
  15767. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15768. * 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.
  15769. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15770. */
  15771. mirrorPlane: Plane;
  15772. /**
  15773. * Define the blur ratio used to blur the reflection if needed.
  15774. */
  15775. blurRatio: number;
  15776. /**
  15777. * Define the adaptive blur kernel used to blur the reflection if needed.
  15778. * This will autocompute the closest best match for the `blurKernel`
  15779. */
  15780. adaptiveBlurKernel: number;
  15781. /**
  15782. * Define the blur kernel used to blur the reflection if needed.
  15783. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15784. */
  15785. blurKernel: number;
  15786. /**
  15787. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15788. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15789. */
  15790. blurKernelX: number;
  15791. /**
  15792. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15793. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15794. */
  15795. blurKernelY: number;
  15796. private _autoComputeBlurKernel;
  15797. protected _onRatioRescale(): void;
  15798. private _updateGammaSpace;
  15799. private _imageProcessingConfigChangeObserver;
  15800. private _transformMatrix;
  15801. private _mirrorMatrix;
  15802. private _savedViewMatrix;
  15803. private _blurX;
  15804. private _blurY;
  15805. private _adaptiveBlurKernel;
  15806. private _blurKernelX;
  15807. private _blurKernelY;
  15808. private _blurRatio;
  15809. /**
  15810. * Instantiates a Mirror Texture.
  15811. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15812. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15813. * You can then easily use it as a reflectionTexture on a flat surface.
  15814. * In case the surface is not a plane, please consider relying on reflection probes.
  15815. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15816. * @param name
  15817. * @param size
  15818. * @param scene
  15819. * @param generateMipMaps
  15820. * @param type
  15821. * @param samplingMode
  15822. * @param generateDepthBuffer
  15823. */
  15824. constructor(name: string, size: number | {
  15825. width: number;
  15826. height: number;
  15827. } | {
  15828. ratio: number;
  15829. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15830. private _preparePostProcesses;
  15831. /**
  15832. * Clone the mirror texture.
  15833. * @returns the cloned texture
  15834. */
  15835. clone(): MirrorTexture;
  15836. /**
  15837. * Serialize the texture to a JSON representation you could use in Parse later on
  15838. * @returns the serialized JSON representation
  15839. */
  15840. serialize(): any;
  15841. /**
  15842. * Dispose the texture and release its associated resources.
  15843. */
  15844. dispose(): void;
  15845. }
  15846. }
  15847. declare module "babylonjs/Materials/Textures/texture" {
  15848. import { Observable } from "babylonjs/Misc/observable";
  15849. import { Nullable } from "babylonjs/types";
  15850. import { Scene } from "babylonjs/scene";
  15851. import { Matrix } from "babylonjs/Maths/math.vector";
  15852. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15853. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15854. import { Engine } from "babylonjs/Engines/engine";
  15855. /**
  15856. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15857. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15858. */
  15859. export class Texture extends BaseTexture {
  15860. /** @hidden */
  15861. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15862. /** @hidden */
  15863. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15864. /** @hidden */
  15865. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15866. /** nearest is mag = nearest and min = nearest and mip = linear */
  15867. static readonly NEAREST_SAMPLINGMODE: number;
  15868. /** nearest is mag = nearest and min = nearest and mip = linear */
  15869. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15870. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15871. static readonly BILINEAR_SAMPLINGMODE: number;
  15872. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15873. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15874. /** Trilinear is mag = linear and min = linear and mip = linear */
  15875. static readonly TRILINEAR_SAMPLINGMODE: number;
  15876. /** Trilinear is mag = linear and min = linear and mip = linear */
  15877. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15878. /** mag = nearest and min = nearest and mip = nearest */
  15879. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15880. /** mag = nearest and min = linear and mip = nearest */
  15881. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15882. /** mag = nearest and min = linear and mip = linear */
  15883. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15884. /** mag = nearest and min = linear and mip = none */
  15885. static readonly NEAREST_LINEAR: number;
  15886. /** mag = nearest and min = nearest and mip = none */
  15887. static readonly NEAREST_NEAREST: number;
  15888. /** mag = linear and min = nearest and mip = nearest */
  15889. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15890. /** mag = linear and min = nearest and mip = linear */
  15891. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15892. /** mag = linear and min = linear and mip = none */
  15893. static readonly LINEAR_LINEAR: number;
  15894. /** mag = linear and min = nearest and mip = none */
  15895. static readonly LINEAR_NEAREST: number;
  15896. /** Explicit coordinates mode */
  15897. static readonly EXPLICIT_MODE: number;
  15898. /** Spherical coordinates mode */
  15899. static readonly SPHERICAL_MODE: number;
  15900. /** Planar coordinates mode */
  15901. static readonly PLANAR_MODE: number;
  15902. /** Cubic coordinates mode */
  15903. static readonly CUBIC_MODE: number;
  15904. /** Projection coordinates mode */
  15905. static readonly PROJECTION_MODE: number;
  15906. /** Inverse Cubic coordinates mode */
  15907. static readonly SKYBOX_MODE: number;
  15908. /** Inverse Cubic coordinates mode */
  15909. static readonly INVCUBIC_MODE: number;
  15910. /** Equirectangular coordinates mode */
  15911. static readonly EQUIRECTANGULAR_MODE: number;
  15912. /** Equirectangular Fixed coordinates mode */
  15913. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15914. /** Equirectangular Fixed Mirrored coordinates mode */
  15915. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15916. /** Texture is not repeating outside of 0..1 UVs */
  15917. static readonly CLAMP_ADDRESSMODE: number;
  15918. /** Texture is repeating outside of 0..1 UVs */
  15919. static readonly WRAP_ADDRESSMODE: number;
  15920. /** Texture is repeating and mirrored */
  15921. static readonly MIRROR_ADDRESSMODE: number;
  15922. /**
  15923. * 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
  15924. */
  15925. static UseSerializedUrlIfAny: boolean;
  15926. /**
  15927. * Define the url of the texture.
  15928. */
  15929. url: Nullable<string>;
  15930. /**
  15931. * Define an offset on the texture to offset the u coordinates of the UVs
  15932. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15933. */
  15934. uOffset: number;
  15935. /**
  15936. * Define an offset on the texture to offset the v coordinates of the UVs
  15937. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15938. */
  15939. vOffset: number;
  15940. /**
  15941. * Define an offset on the texture to scale the u coordinates of the UVs
  15942. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15943. */
  15944. uScale: number;
  15945. /**
  15946. * Define an offset on the texture to scale the v coordinates of the UVs
  15947. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15948. */
  15949. vScale: number;
  15950. /**
  15951. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15952. * @see http://doc.babylonjs.com/how_to/more_materials
  15953. */
  15954. uAng: number;
  15955. /**
  15956. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15957. * @see http://doc.babylonjs.com/how_to/more_materials
  15958. */
  15959. vAng: number;
  15960. /**
  15961. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15962. * @see http://doc.babylonjs.com/how_to/more_materials
  15963. */
  15964. wAng: number;
  15965. /**
  15966. * Defines the center of rotation (U)
  15967. */
  15968. uRotationCenter: number;
  15969. /**
  15970. * Defines the center of rotation (V)
  15971. */
  15972. vRotationCenter: number;
  15973. /**
  15974. * Defines the center of rotation (W)
  15975. */
  15976. wRotationCenter: number;
  15977. /**
  15978. * Are mip maps generated for this texture or not.
  15979. */
  15980. readonly noMipmap: boolean;
  15981. /**
  15982. * List of inspectable custom properties (used by the Inspector)
  15983. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15984. */
  15985. inspectableCustomProperties: Nullable<IInspectable[]>;
  15986. private _noMipmap;
  15987. /** @hidden */
  15988. _invertY: boolean;
  15989. private _rowGenerationMatrix;
  15990. private _cachedTextureMatrix;
  15991. private _projectionModeMatrix;
  15992. private _t0;
  15993. private _t1;
  15994. private _t2;
  15995. private _cachedUOffset;
  15996. private _cachedVOffset;
  15997. private _cachedUScale;
  15998. private _cachedVScale;
  15999. private _cachedUAng;
  16000. private _cachedVAng;
  16001. private _cachedWAng;
  16002. private _cachedProjectionMatrixId;
  16003. private _cachedCoordinatesMode;
  16004. /** @hidden */
  16005. protected _initialSamplingMode: number;
  16006. /** @hidden */
  16007. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16008. private _deleteBuffer;
  16009. protected _format: Nullable<number>;
  16010. private _delayedOnLoad;
  16011. private _delayedOnError;
  16012. /**
  16013. * Observable triggered once the texture has been loaded.
  16014. */
  16015. onLoadObservable: Observable<Texture>;
  16016. protected _isBlocking: boolean;
  16017. /**
  16018. * Is the texture preventing material to render while loading.
  16019. * If false, a default texture will be used instead of the loading one during the preparation step.
  16020. */
  16021. isBlocking: boolean;
  16022. /**
  16023. * Get the current sampling mode associated with the texture.
  16024. */
  16025. readonly samplingMode: number;
  16026. /**
  16027. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16028. */
  16029. readonly invertY: boolean;
  16030. /**
  16031. * Instantiates a new texture.
  16032. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16033. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16034. * @param url define the url of the picture to load as a texture
  16035. * @param scene define the scene or engine the texture will belong to
  16036. * @param noMipmap define if the texture will require mip maps or not
  16037. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16038. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16039. * @param onLoad define a callback triggered when the texture has been loaded
  16040. * @param onError define a callback triggered when an error occurred during the loading session
  16041. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16042. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16043. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16044. */
  16045. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, 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);
  16046. /**
  16047. * Update the url (and optional buffer) of this texture if url was null during construction.
  16048. * @param url the url of the texture
  16049. * @param buffer the buffer of the texture (defaults to null)
  16050. * @param onLoad callback called when the texture is loaded (defaults to null)
  16051. */
  16052. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16053. /**
  16054. * Finish the loading sequence of a texture flagged as delayed load.
  16055. * @hidden
  16056. */
  16057. delayLoad(): void;
  16058. private _prepareRowForTextureGeneration;
  16059. /**
  16060. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16061. * @returns the transform matrix of the texture.
  16062. */
  16063. getTextureMatrix(): Matrix;
  16064. /**
  16065. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16066. * @returns The reflection texture transform
  16067. */
  16068. getReflectionTextureMatrix(): Matrix;
  16069. /**
  16070. * Clones the texture.
  16071. * @returns the cloned texture
  16072. */
  16073. clone(): Texture;
  16074. /**
  16075. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16076. * @returns The JSON representation of the texture
  16077. */
  16078. serialize(): any;
  16079. /**
  16080. * Get the current class name of the texture useful for serialization or dynamic coding.
  16081. * @returns "Texture"
  16082. */
  16083. getClassName(): string;
  16084. /**
  16085. * Dispose the texture and release its associated resources.
  16086. */
  16087. dispose(): void;
  16088. /**
  16089. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16090. * @param parsedTexture Define the JSON representation of the texture
  16091. * @param scene Define the scene the parsed texture should be instantiated in
  16092. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16093. * @returns The parsed texture if successful
  16094. */
  16095. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16096. /**
  16097. * Creates a texture from its base 64 representation.
  16098. * @param data Define the base64 payload without the data: prefix
  16099. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16100. * @param scene Define the scene the texture should belong to
  16101. * @param noMipmap Forces the texture to not create mip map information if true
  16102. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16103. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16104. * @param onLoad define a callback triggered when the texture has been loaded
  16105. * @param onError define a callback triggered when an error occurred during the loading session
  16106. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16107. * @returns the created texture
  16108. */
  16109. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16110. /**
  16111. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16112. * @param data Define the base64 payload without the data: prefix
  16113. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16114. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16115. * @param scene Define the scene the texture should belong to
  16116. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16117. * @param noMipmap Forces the texture to not create mip map information if true
  16118. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16119. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16120. * @param onLoad define a callback triggered when the texture has been loaded
  16121. * @param onError define a callback triggered when an error occurred during the loading session
  16122. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16123. * @returns the created texture
  16124. */
  16125. 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;
  16126. }
  16127. }
  16128. declare module "babylonjs/PostProcesses/postProcessManager" {
  16129. import { Nullable } from "babylonjs/types";
  16130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16131. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16132. import { Scene } from "babylonjs/scene";
  16133. /**
  16134. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16135. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16136. */
  16137. export class PostProcessManager {
  16138. private _scene;
  16139. private _indexBuffer;
  16140. private _vertexBuffers;
  16141. /**
  16142. * Creates a new instance PostProcess
  16143. * @param scene The scene that the post process is associated with.
  16144. */
  16145. constructor(scene: Scene);
  16146. private _prepareBuffers;
  16147. private _buildIndexBuffer;
  16148. /**
  16149. * Rebuilds the vertex buffers of the manager.
  16150. * @hidden
  16151. */
  16152. _rebuild(): void;
  16153. /**
  16154. * Prepares a frame to be run through a post process.
  16155. * @param sourceTexture The input texture to the post procesess. (default: null)
  16156. * @param postProcesses An array of post processes to be run. (default: null)
  16157. * @returns True if the post processes were able to be run.
  16158. * @hidden
  16159. */
  16160. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16161. /**
  16162. * Manually render a set of post processes to a texture.
  16163. * @param postProcesses An array of post processes to be run.
  16164. * @param targetTexture The target texture to render to.
  16165. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16166. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16167. * @param lodLevel defines which lod of the texture to render to
  16168. */
  16169. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16170. /**
  16171. * Finalize the result of the output of the postprocesses.
  16172. * @param doNotPresent If true the result will not be displayed to the screen.
  16173. * @param targetTexture The target texture to render to.
  16174. * @param faceIndex The index of the face to bind the target texture to.
  16175. * @param postProcesses The array of post processes to render.
  16176. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16177. * @hidden
  16178. */
  16179. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16180. /**
  16181. * Disposes of the post process manager.
  16182. */
  16183. dispose(): void;
  16184. }
  16185. }
  16186. declare module "babylonjs/Misc/gradients" {
  16187. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16188. /** Interface used by value gradients (color, factor, ...) */
  16189. export interface IValueGradient {
  16190. /**
  16191. * Gets or sets the gradient value (between 0 and 1)
  16192. */
  16193. gradient: number;
  16194. }
  16195. /** Class used to store color4 gradient */
  16196. export class ColorGradient implements IValueGradient {
  16197. /**
  16198. * Gets or sets the gradient value (between 0 and 1)
  16199. */
  16200. gradient: number;
  16201. /**
  16202. * Gets or sets first associated color
  16203. */
  16204. color1: Color4;
  16205. /**
  16206. * Gets or sets second associated color
  16207. */
  16208. color2?: Color4;
  16209. /**
  16210. * Will get a color picked randomly between color1 and color2.
  16211. * If color2 is undefined then color1 will be used
  16212. * @param result defines the target Color4 to store the result in
  16213. */
  16214. getColorToRef(result: Color4): void;
  16215. }
  16216. /** Class used to store color 3 gradient */
  16217. export class Color3Gradient implements IValueGradient {
  16218. /**
  16219. * Gets or sets the gradient value (between 0 and 1)
  16220. */
  16221. gradient: number;
  16222. /**
  16223. * Gets or sets the associated color
  16224. */
  16225. color: Color3;
  16226. }
  16227. /** Class used to store factor gradient */
  16228. export class FactorGradient implements IValueGradient {
  16229. /**
  16230. * Gets or sets the gradient value (between 0 and 1)
  16231. */
  16232. gradient: number;
  16233. /**
  16234. * Gets or sets first associated factor
  16235. */
  16236. factor1: number;
  16237. /**
  16238. * Gets or sets second associated factor
  16239. */
  16240. factor2?: number;
  16241. /**
  16242. * Will get a number picked randomly between factor1 and factor2.
  16243. * If factor2 is undefined then factor1 will be used
  16244. * @returns the picked number
  16245. */
  16246. getFactor(): number;
  16247. }
  16248. /**
  16249. * Helper used to simplify some generic gradient tasks
  16250. */
  16251. export class GradientHelper {
  16252. /**
  16253. * Gets the current gradient from an array of IValueGradient
  16254. * @param ratio defines the current ratio to get
  16255. * @param gradients defines the array of IValueGradient
  16256. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16257. */
  16258. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16259. }
  16260. }
  16261. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16262. import { Scene } from "babylonjs/scene";
  16263. import { ISceneComponent } from "babylonjs/sceneComponent";
  16264. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16265. module "babylonjs/abstractScene" {
  16266. interface AbstractScene {
  16267. /**
  16268. * The list of procedural textures added to the scene
  16269. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16270. */
  16271. proceduralTextures: Array<ProceduralTexture>;
  16272. }
  16273. }
  16274. /**
  16275. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16276. * in a given scene.
  16277. */
  16278. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16279. /**
  16280. * The component name helpfull to identify the component in the list of scene components.
  16281. */
  16282. readonly name: string;
  16283. /**
  16284. * The scene the component belongs to.
  16285. */
  16286. scene: Scene;
  16287. /**
  16288. * Creates a new instance of the component for the given scene
  16289. * @param scene Defines the scene to register the component in
  16290. */
  16291. constructor(scene: Scene);
  16292. /**
  16293. * Registers the component in a given scene
  16294. */
  16295. register(): void;
  16296. /**
  16297. * Rebuilds the elements related to this component in case of
  16298. * context lost for instance.
  16299. */
  16300. rebuild(): void;
  16301. /**
  16302. * Disposes the component and the associated ressources.
  16303. */
  16304. dispose(): void;
  16305. private _beforeClear;
  16306. }
  16307. }
  16308. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16309. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16310. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16311. module "babylonjs/Engines/engine" {
  16312. interface Engine {
  16313. /**
  16314. * Creates a new render target cube texture
  16315. * @param size defines the size of the texture
  16316. * @param options defines the options used to create the texture
  16317. * @returns a new render target cube texture stored in an InternalTexture
  16318. */
  16319. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16320. }
  16321. }
  16322. }
  16323. declare module "babylonjs/Shaders/procedural.vertex" {
  16324. /** @hidden */
  16325. export var proceduralVertexShader: {
  16326. name: string;
  16327. shader: string;
  16328. };
  16329. }
  16330. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16331. import { Observable } from "babylonjs/Misc/observable";
  16332. import { Nullable } from "babylonjs/types";
  16333. import { Scene } from "babylonjs/scene";
  16334. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16335. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16336. import { Effect } from "babylonjs/Materials/effect";
  16337. import { Texture } from "babylonjs/Materials/Textures/texture";
  16338. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16339. import "babylonjs/Shaders/procedural.vertex";
  16340. /**
  16341. * 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.
  16342. * This is the base class of any Procedural texture and contains most of the shareable code.
  16343. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16344. */
  16345. export class ProceduralTexture extends Texture {
  16346. isCube: boolean;
  16347. /**
  16348. * Define if the texture is enabled or not (disabled texture will not render)
  16349. */
  16350. isEnabled: boolean;
  16351. /**
  16352. * Define if the texture must be cleared before rendering (default is true)
  16353. */
  16354. autoClear: boolean;
  16355. /**
  16356. * Callback called when the texture is generated
  16357. */
  16358. onGenerated: () => void;
  16359. /**
  16360. * Event raised when the texture is generated
  16361. */
  16362. onGeneratedObservable: Observable<ProceduralTexture>;
  16363. /** @hidden */
  16364. _generateMipMaps: boolean;
  16365. /** @hidden **/
  16366. _effect: Effect;
  16367. /** @hidden */
  16368. _textures: {
  16369. [key: string]: Texture;
  16370. };
  16371. private _size;
  16372. private _currentRefreshId;
  16373. private _refreshRate;
  16374. private _vertexBuffers;
  16375. private _indexBuffer;
  16376. private _uniforms;
  16377. private _samplers;
  16378. private _fragment;
  16379. private _floats;
  16380. private _ints;
  16381. private _floatsArrays;
  16382. private _colors3;
  16383. private _colors4;
  16384. private _vectors2;
  16385. private _vectors3;
  16386. private _matrices;
  16387. private _fallbackTexture;
  16388. private _fallbackTextureUsed;
  16389. private _engine;
  16390. private _cachedDefines;
  16391. private _contentUpdateId;
  16392. private _contentData;
  16393. /**
  16394. * Instantiates a new procedural texture.
  16395. * 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.
  16396. * This is the base class of any Procedural texture and contains most of the shareable code.
  16397. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16398. * @param name Define the name of the texture
  16399. * @param size Define the size of the texture to create
  16400. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16401. * @param scene Define the scene the texture belongs to
  16402. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16403. * @param generateMipMaps Define if the texture should creates mip maps or not
  16404. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16405. */
  16406. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16407. /**
  16408. * The effect that is created when initializing the post process.
  16409. * @returns The created effect corresponding the the postprocess.
  16410. */
  16411. getEffect(): Effect;
  16412. /**
  16413. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16414. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16415. */
  16416. getContent(): Nullable<ArrayBufferView>;
  16417. private _createIndexBuffer;
  16418. /** @hidden */
  16419. _rebuild(): void;
  16420. /**
  16421. * Resets the texture in order to recreate its associated resources.
  16422. * This can be called in case of context loss
  16423. */
  16424. reset(): void;
  16425. protected _getDefines(): string;
  16426. /**
  16427. * Is the texture ready to be used ? (rendered at least once)
  16428. * @returns true if ready, otherwise, false.
  16429. */
  16430. isReady(): boolean;
  16431. /**
  16432. * Resets the refresh counter of the texture and start bak from scratch.
  16433. * Could be useful to regenerate the texture if it is setup to render only once.
  16434. */
  16435. resetRefreshCounter(): void;
  16436. /**
  16437. * Set the fragment shader to use in order to render the texture.
  16438. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16439. */
  16440. setFragment(fragment: any): void;
  16441. /**
  16442. * Define the refresh rate of the texture or the rendering frequency.
  16443. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16444. */
  16445. refreshRate: number;
  16446. /** @hidden */
  16447. _shouldRender(): boolean;
  16448. /**
  16449. * Get the size the texture is rendering at.
  16450. * @returns the size (texture is always squared)
  16451. */
  16452. getRenderSize(): number;
  16453. /**
  16454. * Resize the texture to new value.
  16455. * @param size Define the new size the texture should have
  16456. * @param generateMipMaps Define whether the new texture should create mip maps
  16457. */
  16458. resize(size: number, generateMipMaps: boolean): void;
  16459. private _checkUniform;
  16460. /**
  16461. * Set a texture in the shader program used to render.
  16462. * @param name Define the name of the uniform samplers as defined in the shader
  16463. * @param texture Define the texture to bind to this sampler
  16464. * @return the texture itself allowing "fluent" like uniform updates
  16465. */
  16466. setTexture(name: string, texture: Texture): ProceduralTexture;
  16467. /**
  16468. * Set a float in the shader.
  16469. * @param name Define the name of the uniform as defined in the shader
  16470. * @param value Define the value to give to the uniform
  16471. * @return the texture itself allowing "fluent" like uniform updates
  16472. */
  16473. setFloat(name: string, value: number): ProceduralTexture;
  16474. /**
  16475. * Set a int in the shader.
  16476. * @param name Define the name of the uniform as defined in the shader
  16477. * @param value Define the value to give to the uniform
  16478. * @return the texture itself allowing "fluent" like uniform updates
  16479. */
  16480. setInt(name: string, value: number): ProceduralTexture;
  16481. /**
  16482. * Set an array of floats in the shader.
  16483. * @param name Define the name of the uniform as defined in the shader
  16484. * @param value Define the value to give to the uniform
  16485. * @return the texture itself allowing "fluent" like uniform updates
  16486. */
  16487. setFloats(name: string, value: number[]): ProceduralTexture;
  16488. /**
  16489. * Set a vec3 in the shader from a Color3.
  16490. * @param name Define the name of the uniform as defined in the shader
  16491. * @param value Define the value to give to the uniform
  16492. * @return the texture itself allowing "fluent" like uniform updates
  16493. */
  16494. setColor3(name: string, value: Color3): ProceduralTexture;
  16495. /**
  16496. * Set a vec4 in the shader from a Color4.
  16497. * @param name Define the name of the uniform as defined in the shader
  16498. * @param value Define the value to give to the uniform
  16499. * @return the texture itself allowing "fluent" like uniform updates
  16500. */
  16501. setColor4(name: string, value: Color4): ProceduralTexture;
  16502. /**
  16503. * Set a vec2 in the shader from a Vector2.
  16504. * @param name Define the name of the uniform as defined in the shader
  16505. * @param value Define the value to give to the uniform
  16506. * @return the texture itself allowing "fluent" like uniform updates
  16507. */
  16508. setVector2(name: string, value: Vector2): ProceduralTexture;
  16509. /**
  16510. * Set a vec3 in the shader from a Vector3.
  16511. * @param name Define the name of the uniform as defined in the shader
  16512. * @param value Define the value to give to the uniform
  16513. * @return the texture itself allowing "fluent" like uniform updates
  16514. */
  16515. setVector3(name: string, value: Vector3): ProceduralTexture;
  16516. /**
  16517. * Set a mat4 in the shader from a MAtrix.
  16518. * @param name Define the name of the uniform as defined in the shader
  16519. * @param value Define the value to give to the uniform
  16520. * @return the texture itself allowing "fluent" like uniform updates
  16521. */
  16522. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16523. /**
  16524. * Render the texture to its associated render target.
  16525. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16526. */
  16527. render(useCameraPostProcess?: boolean): void;
  16528. /**
  16529. * Clone the texture.
  16530. * @returns the cloned texture
  16531. */
  16532. clone(): ProceduralTexture;
  16533. /**
  16534. * Dispose the texture and release its asoociated resources.
  16535. */
  16536. dispose(): void;
  16537. }
  16538. }
  16539. declare module "babylonjs/Particles/baseParticleSystem" {
  16540. import { Nullable } from "babylonjs/types";
  16541. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16543. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16544. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16545. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16546. import { Scene } from "babylonjs/scene";
  16547. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16548. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16549. import { Texture } from "babylonjs/Materials/Textures/texture";
  16550. import { Color4 } from "babylonjs/Maths/math.color";
  16551. import { Animation } from "babylonjs/Animations/animation";
  16552. /**
  16553. * This represents the base class for particle system in Babylon.
  16554. * 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.
  16555. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16556. * @example https://doc.babylonjs.com/babylon101/particles
  16557. */
  16558. export class BaseParticleSystem {
  16559. /**
  16560. * Source color is added to the destination color without alpha affecting the result
  16561. */
  16562. static BLENDMODE_ONEONE: number;
  16563. /**
  16564. * Blend current color and particle color using particle’s alpha
  16565. */
  16566. static BLENDMODE_STANDARD: number;
  16567. /**
  16568. * Add current color and particle color multiplied by particle’s alpha
  16569. */
  16570. static BLENDMODE_ADD: number;
  16571. /**
  16572. * Multiply current color with particle color
  16573. */
  16574. static BLENDMODE_MULTIPLY: number;
  16575. /**
  16576. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16577. */
  16578. static BLENDMODE_MULTIPLYADD: number;
  16579. /**
  16580. * List of animations used by the particle system.
  16581. */
  16582. animations: Animation[];
  16583. /**
  16584. * The id of the Particle system.
  16585. */
  16586. id: string;
  16587. /**
  16588. * The friendly name of the Particle system.
  16589. */
  16590. name: string;
  16591. /**
  16592. * The rendering group used by the Particle system to chose when to render.
  16593. */
  16594. renderingGroupId: number;
  16595. /**
  16596. * The emitter represents the Mesh or position we are attaching the particle system to.
  16597. */
  16598. emitter: Nullable<AbstractMesh | Vector3>;
  16599. /**
  16600. * The maximum number of particles to emit per frame
  16601. */
  16602. emitRate: number;
  16603. /**
  16604. * If you want to launch only a few particles at once, that can be done, as well.
  16605. */
  16606. manualEmitCount: number;
  16607. /**
  16608. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16609. */
  16610. updateSpeed: number;
  16611. /**
  16612. * The amount of time the particle system is running (depends of the overall update speed).
  16613. */
  16614. targetStopDuration: number;
  16615. /**
  16616. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16617. */
  16618. disposeOnStop: boolean;
  16619. /**
  16620. * Minimum power of emitting particles.
  16621. */
  16622. minEmitPower: number;
  16623. /**
  16624. * Maximum power of emitting particles.
  16625. */
  16626. maxEmitPower: number;
  16627. /**
  16628. * Minimum life time of emitting particles.
  16629. */
  16630. minLifeTime: number;
  16631. /**
  16632. * Maximum life time of emitting particles.
  16633. */
  16634. maxLifeTime: number;
  16635. /**
  16636. * Minimum Size of emitting particles.
  16637. */
  16638. minSize: number;
  16639. /**
  16640. * Maximum Size of emitting particles.
  16641. */
  16642. maxSize: number;
  16643. /**
  16644. * Minimum scale of emitting particles on X axis.
  16645. */
  16646. minScaleX: number;
  16647. /**
  16648. * Maximum scale of emitting particles on X axis.
  16649. */
  16650. maxScaleX: number;
  16651. /**
  16652. * Minimum scale of emitting particles on Y axis.
  16653. */
  16654. minScaleY: number;
  16655. /**
  16656. * Maximum scale of emitting particles on Y axis.
  16657. */
  16658. maxScaleY: number;
  16659. /**
  16660. * Gets or sets the minimal initial rotation in radians.
  16661. */
  16662. minInitialRotation: number;
  16663. /**
  16664. * Gets or sets the maximal initial rotation in radians.
  16665. */
  16666. maxInitialRotation: number;
  16667. /**
  16668. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16669. */
  16670. minAngularSpeed: number;
  16671. /**
  16672. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16673. */
  16674. maxAngularSpeed: number;
  16675. /**
  16676. * The texture used to render each particle. (this can be a spritesheet)
  16677. */
  16678. particleTexture: Nullable<Texture>;
  16679. /**
  16680. * The layer mask we are rendering the particles through.
  16681. */
  16682. layerMask: number;
  16683. /**
  16684. * This can help using your own shader to render the particle system.
  16685. * The according effect will be created
  16686. */
  16687. customShader: any;
  16688. /**
  16689. * By default particle system starts as soon as they are created. This prevents the
  16690. * automatic start to happen and let you decide when to start emitting particles.
  16691. */
  16692. preventAutoStart: boolean;
  16693. private _noiseTexture;
  16694. /**
  16695. * Gets or sets a texture used to add random noise to particle positions
  16696. */
  16697. noiseTexture: Nullable<ProceduralTexture>;
  16698. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16699. noiseStrength: Vector3;
  16700. /**
  16701. * Callback triggered when the particle animation is ending.
  16702. */
  16703. onAnimationEnd: Nullable<() => void>;
  16704. /**
  16705. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16706. */
  16707. blendMode: number;
  16708. /**
  16709. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16710. * to override the particles.
  16711. */
  16712. forceDepthWrite: boolean;
  16713. /** 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 */
  16714. preWarmCycles: number;
  16715. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16716. preWarmStepOffset: number;
  16717. /**
  16718. * 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)
  16719. */
  16720. spriteCellChangeSpeed: number;
  16721. /**
  16722. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16723. */
  16724. startSpriteCellID: number;
  16725. /**
  16726. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16727. */
  16728. endSpriteCellID: number;
  16729. /**
  16730. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16731. */
  16732. spriteCellWidth: number;
  16733. /**
  16734. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16735. */
  16736. spriteCellHeight: number;
  16737. /**
  16738. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16739. */
  16740. spriteRandomStartCell: boolean;
  16741. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16742. translationPivot: Vector2;
  16743. /** @hidden */
  16744. protected _isAnimationSheetEnabled: boolean;
  16745. /**
  16746. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16747. */
  16748. beginAnimationOnStart: boolean;
  16749. /**
  16750. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16751. */
  16752. beginAnimationFrom: number;
  16753. /**
  16754. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16755. */
  16756. beginAnimationTo: number;
  16757. /**
  16758. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16759. */
  16760. beginAnimationLoop: boolean;
  16761. /**
  16762. * Gets or sets a world offset applied to all particles
  16763. */
  16764. worldOffset: Vector3;
  16765. /**
  16766. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16767. */
  16768. isAnimationSheetEnabled: boolean;
  16769. /**
  16770. * Get hosting scene
  16771. * @returns the scene
  16772. */
  16773. getScene(): Scene;
  16774. /**
  16775. * You can use gravity if you want to give an orientation to your particles.
  16776. */
  16777. gravity: Vector3;
  16778. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16779. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16780. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16781. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16782. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16783. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16784. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16785. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16786. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16787. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16788. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16789. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16790. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16791. /**
  16792. * Defines the delay in milliseconds before starting the system (0 by default)
  16793. */
  16794. startDelay: number;
  16795. /**
  16796. * Gets the current list of drag gradients.
  16797. * You must use addDragGradient and removeDragGradient to udpate this list
  16798. * @returns the list of drag gradients
  16799. */
  16800. getDragGradients(): Nullable<Array<FactorGradient>>;
  16801. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16802. limitVelocityDamping: number;
  16803. /**
  16804. * Gets the current list of limit velocity gradients.
  16805. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16806. * @returns the list of limit velocity gradients
  16807. */
  16808. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16809. /**
  16810. * Gets the current list of color gradients.
  16811. * You must use addColorGradient and removeColorGradient to udpate this list
  16812. * @returns the list of color gradients
  16813. */
  16814. getColorGradients(): Nullable<Array<ColorGradient>>;
  16815. /**
  16816. * Gets the current list of size gradients.
  16817. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16818. * @returns the list of size gradients
  16819. */
  16820. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16821. /**
  16822. * Gets the current list of color remap gradients.
  16823. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16824. * @returns the list of color remap gradients
  16825. */
  16826. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16827. /**
  16828. * Gets the current list of alpha remap gradients.
  16829. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16830. * @returns the list of alpha remap gradients
  16831. */
  16832. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16833. /**
  16834. * Gets the current list of life time gradients.
  16835. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16836. * @returns the list of life time gradients
  16837. */
  16838. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16839. /**
  16840. * Gets the current list of angular speed gradients.
  16841. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16842. * @returns the list of angular speed gradients
  16843. */
  16844. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16845. /**
  16846. * Gets the current list of velocity gradients.
  16847. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16848. * @returns the list of velocity gradients
  16849. */
  16850. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16851. /**
  16852. * Gets the current list of start size gradients.
  16853. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16854. * @returns the list of start size gradients
  16855. */
  16856. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16857. /**
  16858. * Gets the current list of emit rate gradients.
  16859. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16860. * @returns the list of emit rate gradients
  16861. */
  16862. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16863. /**
  16864. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16865. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16866. */
  16867. direction1: Vector3;
  16868. /**
  16869. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16870. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16871. */
  16872. direction2: Vector3;
  16873. /**
  16874. * 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.
  16875. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16876. */
  16877. minEmitBox: Vector3;
  16878. /**
  16879. * 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.
  16880. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16881. */
  16882. maxEmitBox: Vector3;
  16883. /**
  16884. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16885. */
  16886. color1: Color4;
  16887. /**
  16888. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16889. */
  16890. color2: Color4;
  16891. /**
  16892. * Color the particle will have at the end of its lifetime
  16893. */
  16894. colorDead: Color4;
  16895. /**
  16896. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16897. */
  16898. textureMask: Color4;
  16899. /**
  16900. * The particle emitter type defines the emitter used by the particle system.
  16901. * It can be for example box, sphere, or cone...
  16902. */
  16903. particleEmitterType: IParticleEmitterType;
  16904. /** @hidden */
  16905. _isSubEmitter: boolean;
  16906. /**
  16907. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16908. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16909. */
  16910. billboardMode: number;
  16911. protected _isBillboardBased: boolean;
  16912. /**
  16913. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16914. */
  16915. isBillboardBased: boolean;
  16916. /**
  16917. * The scene the particle system belongs to.
  16918. */
  16919. protected _scene: Scene;
  16920. /**
  16921. * Local cache of defines for image processing.
  16922. */
  16923. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16924. /**
  16925. * Default configuration related to image processing available in the standard Material.
  16926. */
  16927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16928. /**
  16929. * Gets the image processing configuration used either in this material.
  16930. */
  16931. /**
  16932. * Sets the Default image processing configuration used either in the this material.
  16933. *
  16934. * If sets to null, the scene one is in use.
  16935. */
  16936. imageProcessingConfiguration: ImageProcessingConfiguration;
  16937. /**
  16938. * Attaches a new image processing configuration to the Standard Material.
  16939. * @param configuration
  16940. */
  16941. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16942. /** @hidden */
  16943. protected _reset(): void;
  16944. /** @hidden */
  16945. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16946. /**
  16947. * Instantiates a particle system.
  16948. * 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.
  16949. * @param name The name of the particle system
  16950. */
  16951. constructor(name: string);
  16952. /**
  16953. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16954. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16955. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16956. * @returns the emitter
  16957. */
  16958. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16959. /**
  16960. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16961. * @param radius The radius of the hemisphere to emit from
  16962. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16963. * @returns the emitter
  16964. */
  16965. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16966. /**
  16967. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16968. * @param radius The radius of the sphere to emit from
  16969. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16970. * @returns the emitter
  16971. */
  16972. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16973. /**
  16974. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16975. * @param radius The radius of the sphere to emit from
  16976. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16977. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16978. * @returns the emitter
  16979. */
  16980. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16981. /**
  16982. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16983. * @param radius The radius of the emission cylinder
  16984. * @param height The height of the emission cylinder
  16985. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16986. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16987. * @returns the emitter
  16988. */
  16989. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16990. /**
  16991. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16992. * @param radius The radius of the cylinder to emit from
  16993. * @param height The height of the emission cylinder
  16994. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16995. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16996. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16997. * @returns the emitter
  16998. */
  16999. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17000. /**
  17001. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17002. * @param radius The radius of the cone to emit from
  17003. * @param angle The base angle of the cone
  17004. * @returns the emitter
  17005. */
  17006. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17007. /**
  17008. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17009. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17010. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17011. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17012. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17013. * @returns the emitter
  17014. */
  17015. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17016. }
  17017. }
  17018. declare module "babylonjs/Particles/subEmitter" {
  17019. import { Scene } from "babylonjs/scene";
  17020. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17021. /**
  17022. * Type of sub emitter
  17023. */
  17024. export enum SubEmitterType {
  17025. /**
  17026. * Attached to the particle over it's lifetime
  17027. */
  17028. ATTACHED = 0,
  17029. /**
  17030. * Created when the particle dies
  17031. */
  17032. END = 1
  17033. }
  17034. /**
  17035. * Sub emitter class used to emit particles from an existing particle
  17036. */
  17037. export class SubEmitter {
  17038. /**
  17039. * the particle system to be used by the sub emitter
  17040. */
  17041. particleSystem: ParticleSystem;
  17042. /**
  17043. * Type of the submitter (Default: END)
  17044. */
  17045. type: SubEmitterType;
  17046. /**
  17047. * 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)
  17048. * Note: This only is supported when using an emitter of type Mesh
  17049. */
  17050. inheritDirection: boolean;
  17051. /**
  17052. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17053. */
  17054. inheritedVelocityAmount: number;
  17055. /**
  17056. * Creates a sub emitter
  17057. * @param particleSystem the particle system to be used by the sub emitter
  17058. */
  17059. constructor(
  17060. /**
  17061. * the particle system to be used by the sub emitter
  17062. */
  17063. particleSystem: ParticleSystem);
  17064. /**
  17065. * Clones the sub emitter
  17066. * @returns the cloned sub emitter
  17067. */
  17068. clone(): SubEmitter;
  17069. /**
  17070. * Serialize current object to a JSON object
  17071. * @returns the serialized object
  17072. */
  17073. serialize(): any;
  17074. /** @hidden */
  17075. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17076. /**
  17077. * Creates a new SubEmitter from a serialized JSON version
  17078. * @param serializationObject defines the JSON object to read from
  17079. * @param scene defines the hosting scene
  17080. * @param rootUrl defines the rootUrl for data loading
  17081. * @returns a new SubEmitter
  17082. */
  17083. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17084. /** Release associated resources */
  17085. dispose(): void;
  17086. }
  17087. }
  17088. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17089. /** @hidden */
  17090. export var clipPlaneFragmentDeclaration: {
  17091. name: string;
  17092. shader: string;
  17093. };
  17094. }
  17095. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17096. /** @hidden */
  17097. export var imageProcessingDeclaration: {
  17098. name: string;
  17099. shader: string;
  17100. };
  17101. }
  17102. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17103. /** @hidden */
  17104. export var imageProcessingFunctions: {
  17105. name: string;
  17106. shader: string;
  17107. };
  17108. }
  17109. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17110. /** @hidden */
  17111. export var clipPlaneFragment: {
  17112. name: string;
  17113. shader: string;
  17114. };
  17115. }
  17116. declare module "babylonjs/Shaders/particles.fragment" {
  17117. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17118. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17119. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17120. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17121. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17122. /** @hidden */
  17123. export var particlesPixelShader: {
  17124. name: string;
  17125. shader: string;
  17126. };
  17127. }
  17128. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17129. /** @hidden */
  17130. export var clipPlaneVertexDeclaration: {
  17131. name: string;
  17132. shader: string;
  17133. };
  17134. }
  17135. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17136. /** @hidden */
  17137. export var clipPlaneVertex: {
  17138. name: string;
  17139. shader: string;
  17140. };
  17141. }
  17142. declare module "babylonjs/Shaders/particles.vertex" {
  17143. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17144. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17145. /** @hidden */
  17146. export var particlesVertexShader: {
  17147. name: string;
  17148. shader: string;
  17149. };
  17150. }
  17151. declare module "babylonjs/Particles/particleSystem" {
  17152. import { Nullable } from "babylonjs/types";
  17153. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17154. import { Observable } from "babylonjs/Misc/observable";
  17155. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17156. import { Effect } from "babylonjs/Materials/effect";
  17157. import { Scene, IDisposable } from "babylonjs/scene";
  17158. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17159. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17160. import { Particle } from "babylonjs/Particles/particle";
  17161. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17162. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17163. import "babylonjs/Shaders/particles.fragment";
  17164. import "babylonjs/Shaders/particles.vertex";
  17165. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17166. /**
  17167. * This represents a particle system in Babylon.
  17168. * 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.
  17169. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17170. * @example https://doc.babylonjs.com/babylon101/particles
  17171. */
  17172. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17173. /**
  17174. * Billboard mode will only apply to Y axis
  17175. */
  17176. static readonly BILLBOARDMODE_Y: number;
  17177. /**
  17178. * Billboard mode will apply to all axes
  17179. */
  17180. static readonly BILLBOARDMODE_ALL: number;
  17181. /**
  17182. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17183. */
  17184. static readonly BILLBOARDMODE_STRETCHED: number;
  17185. /**
  17186. * This function can be defined to provide custom update for active particles.
  17187. * This function will be called instead of regular update (age, position, color, etc.).
  17188. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17189. */
  17190. updateFunction: (particles: Particle[]) => void;
  17191. private _emitterWorldMatrix;
  17192. /**
  17193. * This function can be defined to specify initial direction for every new particle.
  17194. * It by default use the emitterType defined function
  17195. */
  17196. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17197. /**
  17198. * This function can be defined to specify initial position for every new particle.
  17199. * It by default use the emitterType defined function
  17200. */
  17201. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17202. /**
  17203. * @hidden
  17204. */
  17205. _inheritedVelocityOffset: Vector3;
  17206. /**
  17207. * An event triggered when the system is disposed
  17208. */
  17209. onDisposeObservable: Observable<ParticleSystem>;
  17210. private _onDisposeObserver;
  17211. /**
  17212. * Sets a callback that will be triggered when the system is disposed
  17213. */
  17214. onDispose: () => void;
  17215. private _particles;
  17216. private _epsilon;
  17217. private _capacity;
  17218. private _stockParticles;
  17219. private _newPartsExcess;
  17220. private _vertexData;
  17221. private _vertexBuffer;
  17222. private _vertexBuffers;
  17223. private _spriteBuffer;
  17224. private _indexBuffer;
  17225. private _effect;
  17226. private _customEffect;
  17227. private _cachedDefines;
  17228. private _scaledColorStep;
  17229. private _colorDiff;
  17230. private _scaledDirection;
  17231. private _scaledGravity;
  17232. private _currentRenderId;
  17233. private _alive;
  17234. private _useInstancing;
  17235. private _started;
  17236. private _stopped;
  17237. private _actualFrame;
  17238. private _scaledUpdateSpeed;
  17239. private _vertexBufferSize;
  17240. /** @hidden */
  17241. _currentEmitRateGradient: Nullable<FactorGradient>;
  17242. /** @hidden */
  17243. _currentEmitRate1: number;
  17244. /** @hidden */
  17245. _currentEmitRate2: number;
  17246. /** @hidden */
  17247. _currentStartSizeGradient: Nullable<FactorGradient>;
  17248. /** @hidden */
  17249. _currentStartSize1: number;
  17250. /** @hidden */
  17251. _currentStartSize2: number;
  17252. private readonly _rawTextureWidth;
  17253. private _rampGradientsTexture;
  17254. private _useRampGradients;
  17255. /** Gets or sets a boolean indicating that ramp gradients must be used
  17256. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17257. */
  17258. useRampGradients: boolean;
  17259. /**
  17260. * 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.
  17261. * 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: [])
  17262. */
  17263. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17264. private _subEmitters;
  17265. /**
  17266. * @hidden
  17267. * If the particle systems emitter should be disposed when the particle system is disposed
  17268. */
  17269. _disposeEmitterOnDispose: boolean;
  17270. /**
  17271. * The current active Sub-systems, this property is used by the root particle system only.
  17272. */
  17273. activeSubSystems: Array<ParticleSystem>;
  17274. private _rootParticleSystem;
  17275. /**
  17276. * Gets the current list of active particles
  17277. */
  17278. readonly particles: Particle[];
  17279. /**
  17280. * Returns the string "ParticleSystem"
  17281. * @returns a string containing the class name
  17282. */
  17283. getClassName(): string;
  17284. /**
  17285. * Instantiates a particle system.
  17286. * 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.
  17287. * @param name The name of the particle system
  17288. * @param capacity The max number of particles alive at the same time
  17289. * @param scene The scene the particle system belongs to
  17290. * @param customEffect a custom effect used to change the way particles are rendered by default
  17291. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17292. * @param epsilon Offset used to render the particles
  17293. */
  17294. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17295. private _addFactorGradient;
  17296. private _removeFactorGradient;
  17297. /**
  17298. * Adds a new life time gradient
  17299. * @param gradient defines the gradient to use (between 0 and 1)
  17300. * @param factor defines the life time factor to affect to the specified gradient
  17301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17302. * @returns the current particle system
  17303. */
  17304. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17305. /**
  17306. * Remove a specific life time gradient
  17307. * @param gradient defines the gradient to remove
  17308. * @returns the current particle system
  17309. */
  17310. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17311. /**
  17312. * Adds a new size gradient
  17313. * @param gradient defines the gradient to use (between 0 and 1)
  17314. * @param factor defines the size factor to affect to the specified gradient
  17315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17316. * @returns the current particle system
  17317. */
  17318. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17319. /**
  17320. * Remove a specific size gradient
  17321. * @param gradient defines the gradient to remove
  17322. * @returns the current particle system
  17323. */
  17324. removeSizeGradient(gradient: number): IParticleSystem;
  17325. /**
  17326. * Adds a new color remap gradient
  17327. * @param gradient defines the gradient to use (between 0 and 1)
  17328. * @param min defines the color remap minimal range
  17329. * @param max defines the color remap maximal range
  17330. * @returns the current particle system
  17331. */
  17332. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17333. /**
  17334. * Remove a specific color remap gradient
  17335. * @param gradient defines the gradient to remove
  17336. * @returns the current particle system
  17337. */
  17338. removeColorRemapGradient(gradient: number): IParticleSystem;
  17339. /**
  17340. * Adds a new alpha remap gradient
  17341. * @param gradient defines the gradient to use (between 0 and 1)
  17342. * @param min defines the alpha remap minimal range
  17343. * @param max defines the alpha remap maximal range
  17344. * @returns the current particle system
  17345. */
  17346. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17347. /**
  17348. * Remove a specific alpha remap gradient
  17349. * @param gradient defines the gradient to remove
  17350. * @returns the current particle system
  17351. */
  17352. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17353. /**
  17354. * Adds a new angular speed gradient
  17355. * @param gradient defines the gradient to use (between 0 and 1)
  17356. * @param factor defines the angular speed to affect to the specified gradient
  17357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17358. * @returns the current particle system
  17359. */
  17360. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17361. /**
  17362. * Remove a specific angular speed gradient
  17363. * @param gradient defines the gradient to remove
  17364. * @returns the current particle system
  17365. */
  17366. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17367. /**
  17368. * Adds a new velocity gradient
  17369. * @param gradient defines the gradient to use (between 0 and 1)
  17370. * @param factor defines the velocity to affect to the specified gradient
  17371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17372. * @returns the current particle system
  17373. */
  17374. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17375. /**
  17376. * Remove a specific velocity gradient
  17377. * @param gradient defines the gradient to remove
  17378. * @returns the current particle system
  17379. */
  17380. removeVelocityGradient(gradient: number): IParticleSystem;
  17381. /**
  17382. * Adds a new limit velocity gradient
  17383. * @param gradient defines the gradient to use (between 0 and 1)
  17384. * @param factor defines the limit velocity value to affect to the specified gradient
  17385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17386. * @returns the current particle system
  17387. */
  17388. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17389. /**
  17390. * Remove a specific limit velocity gradient
  17391. * @param gradient defines the gradient to remove
  17392. * @returns the current particle system
  17393. */
  17394. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17395. /**
  17396. * Adds a new drag gradient
  17397. * @param gradient defines the gradient to use (between 0 and 1)
  17398. * @param factor defines the drag value to affect to the specified gradient
  17399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17400. * @returns the current particle system
  17401. */
  17402. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17403. /**
  17404. * Remove a specific drag gradient
  17405. * @param gradient defines the gradient to remove
  17406. * @returns the current particle system
  17407. */
  17408. removeDragGradient(gradient: number): IParticleSystem;
  17409. /**
  17410. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17411. * @param gradient defines the gradient to use (between 0 and 1)
  17412. * @param factor defines the emit rate value to affect to the specified gradient
  17413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17414. * @returns the current particle system
  17415. */
  17416. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17417. /**
  17418. * Remove a specific emit rate gradient
  17419. * @param gradient defines the gradient to remove
  17420. * @returns the current particle system
  17421. */
  17422. removeEmitRateGradient(gradient: number): IParticleSystem;
  17423. /**
  17424. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17425. * @param gradient defines the gradient to use (between 0 and 1)
  17426. * @param factor defines the start size value to affect to the specified gradient
  17427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17428. * @returns the current particle system
  17429. */
  17430. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17431. /**
  17432. * Remove a specific start size gradient
  17433. * @param gradient defines the gradient to remove
  17434. * @returns the current particle system
  17435. */
  17436. removeStartSizeGradient(gradient: number): IParticleSystem;
  17437. private _createRampGradientTexture;
  17438. /**
  17439. * Gets the current list of ramp gradients.
  17440. * You must use addRampGradient and removeRampGradient to udpate this list
  17441. * @returns the list of ramp gradients
  17442. */
  17443. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17444. /**
  17445. * Adds a new ramp gradient used to remap particle colors
  17446. * @param gradient defines the gradient to use (between 0 and 1)
  17447. * @param color defines the color to affect to the specified gradient
  17448. * @returns the current particle system
  17449. */
  17450. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17451. /**
  17452. * Remove a specific ramp gradient
  17453. * @param gradient defines the gradient to remove
  17454. * @returns the current particle system
  17455. */
  17456. removeRampGradient(gradient: number): ParticleSystem;
  17457. /**
  17458. * Adds a new color gradient
  17459. * @param gradient defines the gradient to use (between 0 and 1)
  17460. * @param color1 defines the color to affect to the specified gradient
  17461. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17462. * @returns this particle system
  17463. */
  17464. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17465. /**
  17466. * Remove a specific color gradient
  17467. * @param gradient defines the gradient to remove
  17468. * @returns this particle system
  17469. */
  17470. removeColorGradient(gradient: number): IParticleSystem;
  17471. private _fetchR;
  17472. protected _reset(): void;
  17473. private _resetEffect;
  17474. private _createVertexBuffers;
  17475. private _createIndexBuffer;
  17476. /**
  17477. * Gets the maximum number of particles active at the same time.
  17478. * @returns The max number of active particles.
  17479. */
  17480. getCapacity(): number;
  17481. /**
  17482. * Gets whether there are still active particles in the system.
  17483. * @returns True if it is alive, otherwise false.
  17484. */
  17485. isAlive(): boolean;
  17486. /**
  17487. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17488. * @returns True if it has been started, otherwise false.
  17489. */
  17490. isStarted(): boolean;
  17491. private _prepareSubEmitterInternalArray;
  17492. /**
  17493. * Starts the particle system and begins to emit
  17494. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17495. */
  17496. start(delay?: number): void;
  17497. /**
  17498. * Stops the particle system.
  17499. * @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.
  17500. */
  17501. stop(stopSubEmitters?: boolean): void;
  17502. /**
  17503. * Remove all active particles
  17504. */
  17505. reset(): void;
  17506. /**
  17507. * @hidden (for internal use only)
  17508. */
  17509. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17510. /**
  17511. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17512. * Its lifetime will start back at 0.
  17513. */
  17514. recycleParticle: (particle: Particle) => void;
  17515. private _stopSubEmitters;
  17516. private _createParticle;
  17517. private _removeFromRoot;
  17518. private _emitFromParticle;
  17519. private _update;
  17520. /** @hidden */
  17521. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17522. /** @hidden */
  17523. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17524. /** @hidden */
  17525. private _getEffect;
  17526. /**
  17527. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17528. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17529. */
  17530. animate(preWarmOnly?: boolean): void;
  17531. private _appendParticleVertices;
  17532. /**
  17533. * Rebuilds the particle system.
  17534. */
  17535. rebuild(): void;
  17536. /**
  17537. * Is this system ready to be used/rendered
  17538. * @return true if the system is ready
  17539. */
  17540. isReady(): boolean;
  17541. private _render;
  17542. /**
  17543. * Renders the particle system in its current state.
  17544. * @returns the current number of particles
  17545. */
  17546. render(): number;
  17547. /**
  17548. * Disposes the particle system and free the associated resources
  17549. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17550. */
  17551. dispose(disposeTexture?: boolean): void;
  17552. /**
  17553. * Clones the particle system.
  17554. * @param name The name of the cloned object
  17555. * @param newEmitter The new emitter to use
  17556. * @returns the cloned particle system
  17557. */
  17558. clone(name: string, newEmitter: any): ParticleSystem;
  17559. /**
  17560. * Serializes the particle system to a JSON object.
  17561. * @returns the JSON object
  17562. */
  17563. serialize(): any;
  17564. /** @hidden */
  17565. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17566. /** @hidden */
  17567. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17568. /**
  17569. * Parses a JSON object to create a particle system.
  17570. * @param parsedParticleSystem The JSON object to parse
  17571. * @param scene The scene to create the particle system in
  17572. * @param rootUrl The root url to use to load external dependencies like texture
  17573. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17574. * @returns the Parsed particle system
  17575. */
  17576. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17577. }
  17578. }
  17579. declare module "babylonjs/Particles/particle" {
  17580. import { Nullable } from "babylonjs/types";
  17581. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17582. import { Color4 } from "babylonjs/Maths/math.color";
  17583. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17584. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17585. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17586. /**
  17587. * A particle represents one of the element emitted by a particle system.
  17588. * This is mainly define by its coordinates, direction, velocity and age.
  17589. */
  17590. export class Particle {
  17591. /**
  17592. * The particle system the particle belongs to.
  17593. */
  17594. particleSystem: ParticleSystem;
  17595. private static _Count;
  17596. /**
  17597. * Unique ID of the particle
  17598. */
  17599. id: number;
  17600. /**
  17601. * The world position of the particle in the scene.
  17602. */
  17603. position: Vector3;
  17604. /**
  17605. * The world direction of the particle in the scene.
  17606. */
  17607. direction: Vector3;
  17608. /**
  17609. * The color of the particle.
  17610. */
  17611. color: Color4;
  17612. /**
  17613. * The color change of the particle per step.
  17614. */
  17615. colorStep: Color4;
  17616. /**
  17617. * Defines how long will the life of the particle be.
  17618. */
  17619. lifeTime: number;
  17620. /**
  17621. * The current age of the particle.
  17622. */
  17623. age: number;
  17624. /**
  17625. * The current size of the particle.
  17626. */
  17627. size: number;
  17628. /**
  17629. * The current scale of the particle.
  17630. */
  17631. scale: Vector2;
  17632. /**
  17633. * The current angle of the particle.
  17634. */
  17635. angle: number;
  17636. /**
  17637. * Defines how fast is the angle changing.
  17638. */
  17639. angularSpeed: number;
  17640. /**
  17641. * Defines the cell index used by the particle to be rendered from a sprite.
  17642. */
  17643. cellIndex: number;
  17644. /**
  17645. * The information required to support color remapping
  17646. */
  17647. remapData: Vector4;
  17648. /** @hidden */
  17649. _randomCellOffset?: number;
  17650. /** @hidden */
  17651. _initialDirection: Nullable<Vector3>;
  17652. /** @hidden */
  17653. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17654. /** @hidden */
  17655. _initialStartSpriteCellID: number;
  17656. /** @hidden */
  17657. _initialEndSpriteCellID: number;
  17658. /** @hidden */
  17659. _currentColorGradient: Nullable<ColorGradient>;
  17660. /** @hidden */
  17661. _currentColor1: Color4;
  17662. /** @hidden */
  17663. _currentColor2: Color4;
  17664. /** @hidden */
  17665. _currentSizeGradient: Nullable<FactorGradient>;
  17666. /** @hidden */
  17667. _currentSize1: number;
  17668. /** @hidden */
  17669. _currentSize2: number;
  17670. /** @hidden */
  17671. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17672. /** @hidden */
  17673. _currentAngularSpeed1: number;
  17674. /** @hidden */
  17675. _currentAngularSpeed2: number;
  17676. /** @hidden */
  17677. _currentVelocityGradient: Nullable<FactorGradient>;
  17678. /** @hidden */
  17679. _currentVelocity1: number;
  17680. /** @hidden */
  17681. _currentVelocity2: number;
  17682. /** @hidden */
  17683. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17684. /** @hidden */
  17685. _currentLimitVelocity1: number;
  17686. /** @hidden */
  17687. _currentLimitVelocity2: number;
  17688. /** @hidden */
  17689. _currentDragGradient: Nullable<FactorGradient>;
  17690. /** @hidden */
  17691. _currentDrag1: number;
  17692. /** @hidden */
  17693. _currentDrag2: number;
  17694. /** @hidden */
  17695. _randomNoiseCoordinates1: Vector3;
  17696. /** @hidden */
  17697. _randomNoiseCoordinates2: Vector3;
  17698. /**
  17699. * Creates a new instance Particle
  17700. * @param particleSystem the particle system the particle belongs to
  17701. */
  17702. constructor(
  17703. /**
  17704. * The particle system the particle belongs to.
  17705. */
  17706. particleSystem: ParticleSystem);
  17707. private updateCellInfoFromSystem;
  17708. /**
  17709. * Defines how the sprite cell index is updated for the particle
  17710. */
  17711. updateCellIndex(): void;
  17712. /** @hidden */
  17713. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17714. /** @hidden */
  17715. _inheritParticleInfoToSubEmitters(): void;
  17716. /** @hidden */
  17717. _reset(): void;
  17718. /**
  17719. * Copy the properties of particle to another one.
  17720. * @param other the particle to copy the information to.
  17721. */
  17722. copyTo(other: Particle): void;
  17723. }
  17724. }
  17725. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17726. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17727. import { Effect } from "babylonjs/Materials/effect";
  17728. import { Particle } from "babylonjs/Particles/particle";
  17729. /**
  17730. * Particle emitter represents a volume emitting particles.
  17731. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17732. */
  17733. export interface IParticleEmitterType {
  17734. /**
  17735. * Called by the particle System when the direction is computed for the created particle.
  17736. * @param worldMatrix is the world matrix of the particle system
  17737. * @param directionToUpdate is the direction vector to update with the result
  17738. * @param particle is the particle we are computed the direction for
  17739. */
  17740. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17741. /**
  17742. * Called by the particle System when the position is computed for the created particle.
  17743. * @param worldMatrix is the world matrix of the particle system
  17744. * @param positionToUpdate is the position vector to update with the result
  17745. * @param particle is the particle we are computed the position for
  17746. */
  17747. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17748. /**
  17749. * Clones the current emitter and returns a copy of it
  17750. * @returns the new emitter
  17751. */
  17752. clone(): IParticleEmitterType;
  17753. /**
  17754. * Called by the GPUParticleSystem to setup the update shader
  17755. * @param effect defines the update shader
  17756. */
  17757. applyToShader(effect: Effect): void;
  17758. /**
  17759. * Returns a string to use to update the GPU particles update shader
  17760. * @returns the effect defines string
  17761. */
  17762. getEffectDefines(): string;
  17763. /**
  17764. * Returns a string representing the class name
  17765. * @returns a string containing the class name
  17766. */
  17767. getClassName(): string;
  17768. /**
  17769. * Serializes the particle system to a JSON object.
  17770. * @returns the JSON object
  17771. */
  17772. serialize(): any;
  17773. /**
  17774. * Parse properties from a JSON object
  17775. * @param serializationObject defines the JSON object
  17776. */
  17777. parse(serializationObject: any): void;
  17778. }
  17779. }
  17780. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17781. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17782. import { Effect } from "babylonjs/Materials/effect";
  17783. import { Particle } from "babylonjs/Particles/particle";
  17784. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17785. /**
  17786. * Particle emitter emitting particles from the inside of a box.
  17787. * It emits the particles randomly between 2 given directions.
  17788. */
  17789. export class BoxParticleEmitter implements IParticleEmitterType {
  17790. /**
  17791. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17792. */
  17793. direction1: Vector3;
  17794. /**
  17795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17796. */
  17797. direction2: Vector3;
  17798. /**
  17799. * 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.
  17800. */
  17801. minEmitBox: Vector3;
  17802. /**
  17803. * 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.
  17804. */
  17805. maxEmitBox: Vector3;
  17806. /**
  17807. * Creates a new instance BoxParticleEmitter
  17808. */
  17809. constructor();
  17810. /**
  17811. * Called by the particle System when the direction is computed for the created particle.
  17812. * @param worldMatrix is the world matrix of the particle system
  17813. * @param directionToUpdate is the direction vector to update with the result
  17814. * @param particle is the particle we are computed the direction for
  17815. */
  17816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17817. /**
  17818. * Called by the particle System when the position is computed for the created particle.
  17819. * @param worldMatrix is the world matrix of the particle system
  17820. * @param positionToUpdate is the position vector to update with the result
  17821. * @param particle is the particle we are computed the position for
  17822. */
  17823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17824. /**
  17825. * Clones the current emitter and returns a copy of it
  17826. * @returns the new emitter
  17827. */
  17828. clone(): BoxParticleEmitter;
  17829. /**
  17830. * Called by the GPUParticleSystem to setup the update shader
  17831. * @param effect defines the update shader
  17832. */
  17833. applyToShader(effect: Effect): void;
  17834. /**
  17835. * Returns a string to use to update the GPU particles update shader
  17836. * @returns a string containng the defines string
  17837. */
  17838. getEffectDefines(): string;
  17839. /**
  17840. * Returns the string "BoxParticleEmitter"
  17841. * @returns a string containing the class name
  17842. */
  17843. getClassName(): string;
  17844. /**
  17845. * Serializes the particle system to a JSON object.
  17846. * @returns the JSON object
  17847. */
  17848. serialize(): any;
  17849. /**
  17850. * Parse properties from a JSON object
  17851. * @param serializationObject defines the JSON object
  17852. */
  17853. parse(serializationObject: any): void;
  17854. }
  17855. }
  17856. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17857. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17858. import { Effect } from "babylonjs/Materials/effect";
  17859. import { Particle } from "babylonjs/Particles/particle";
  17860. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17861. /**
  17862. * Particle emitter emitting particles from the inside of a cone.
  17863. * It emits the particles alongside the cone volume from the base to the particle.
  17864. * The emission direction might be randomized.
  17865. */
  17866. export class ConeParticleEmitter implements IParticleEmitterType {
  17867. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17868. directionRandomizer: number;
  17869. private _radius;
  17870. private _angle;
  17871. private _height;
  17872. /**
  17873. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17874. */
  17875. radiusRange: number;
  17876. /**
  17877. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17878. */
  17879. heightRange: number;
  17880. /**
  17881. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17882. */
  17883. emitFromSpawnPointOnly: boolean;
  17884. /**
  17885. * Gets or sets the radius of the emission cone
  17886. */
  17887. radius: number;
  17888. /**
  17889. * Gets or sets the angle of the emission cone
  17890. */
  17891. angle: number;
  17892. private _buildHeight;
  17893. /**
  17894. * Creates a new instance ConeParticleEmitter
  17895. * @param radius the radius of the emission cone (1 by default)
  17896. * @param angle the cone base angle (PI by default)
  17897. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17898. */
  17899. constructor(radius?: number, angle?: number,
  17900. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17901. directionRandomizer?: number);
  17902. /**
  17903. * Called by the particle System when the direction is computed for the created particle.
  17904. * @param worldMatrix is the world matrix of the particle system
  17905. * @param directionToUpdate is the direction vector to update with the result
  17906. * @param particle is the particle we are computed the direction for
  17907. */
  17908. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17909. /**
  17910. * Called by the particle System when the position is computed for the created particle.
  17911. * @param worldMatrix is the world matrix of the particle system
  17912. * @param positionToUpdate is the position vector to update with the result
  17913. * @param particle is the particle we are computed the position for
  17914. */
  17915. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17916. /**
  17917. * Clones the current emitter and returns a copy of it
  17918. * @returns the new emitter
  17919. */
  17920. clone(): ConeParticleEmitter;
  17921. /**
  17922. * Called by the GPUParticleSystem to setup the update shader
  17923. * @param effect defines the update shader
  17924. */
  17925. applyToShader(effect: Effect): void;
  17926. /**
  17927. * Returns a string to use to update the GPU particles update shader
  17928. * @returns a string containng the defines string
  17929. */
  17930. getEffectDefines(): string;
  17931. /**
  17932. * Returns the string "ConeParticleEmitter"
  17933. * @returns a string containing the class name
  17934. */
  17935. getClassName(): string;
  17936. /**
  17937. * Serializes the particle system to a JSON object.
  17938. * @returns the JSON object
  17939. */
  17940. serialize(): any;
  17941. /**
  17942. * Parse properties from a JSON object
  17943. * @param serializationObject defines the JSON object
  17944. */
  17945. parse(serializationObject: any): void;
  17946. }
  17947. }
  17948. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17949. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17950. import { Effect } from "babylonjs/Materials/effect";
  17951. import { Particle } from "babylonjs/Particles/particle";
  17952. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17953. /**
  17954. * Particle emitter emitting particles from the inside of a cylinder.
  17955. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17956. */
  17957. export class CylinderParticleEmitter implements IParticleEmitterType {
  17958. /**
  17959. * The radius of the emission cylinder.
  17960. */
  17961. radius: number;
  17962. /**
  17963. * The height of the emission cylinder.
  17964. */
  17965. height: number;
  17966. /**
  17967. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17968. */
  17969. radiusRange: number;
  17970. /**
  17971. * How much to randomize the particle direction [0-1].
  17972. */
  17973. directionRandomizer: number;
  17974. /**
  17975. * Creates a new instance CylinderParticleEmitter
  17976. * @param radius the radius of the emission cylinder (1 by default)
  17977. * @param height the height of the emission cylinder (1 by default)
  17978. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17979. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17980. */
  17981. constructor(
  17982. /**
  17983. * The radius of the emission cylinder.
  17984. */
  17985. radius?: number,
  17986. /**
  17987. * The height of the emission cylinder.
  17988. */
  17989. height?: number,
  17990. /**
  17991. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17992. */
  17993. radiusRange?: number,
  17994. /**
  17995. * How much to randomize the particle direction [0-1].
  17996. */
  17997. directionRandomizer?: number);
  17998. /**
  17999. * Called by the particle System when the direction is computed for the created particle.
  18000. * @param worldMatrix is the world matrix of the particle system
  18001. * @param directionToUpdate is the direction vector to update with the result
  18002. * @param particle is the particle we are computed the direction for
  18003. */
  18004. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18005. /**
  18006. * Called by the particle System when the position is computed for the created particle.
  18007. * @param worldMatrix is the world matrix of the particle system
  18008. * @param positionToUpdate is the position vector to update with the result
  18009. * @param particle is the particle we are computed the position for
  18010. */
  18011. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18012. /**
  18013. * Clones the current emitter and returns a copy of it
  18014. * @returns the new emitter
  18015. */
  18016. clone(): CylinderParticleEmitter;
  18017. /**
  18018. * Called by the GPUParticleSystem to setup the update shader
  18019. * @param effect defines the update shader
  18020. */
  18021. applyToShader(effect: Effect): void;
  18022. /**
  18023. * Returns a string to use to update the GPU particles update shader
  18024. * @returns a string containng the defines string
  18025. */
  18026. getEffectDefines(): string;
  18027. /**
  18028. * Returns the string "CylinderParticleEmitter"
  18029. * @returns a string containing the class name
  18030. */
  18031. getClassName(): string;
  18032. /**
  18033. * Serializes the particle system to a JSON object.
  18034. * @returns the JSON object
  18035. */
  18036. serialize(): any;
  18037. /**
  18038. * Parse properties from a JSON object
  18039. * @param serializationObject defines the JSON object
  18040. */
  18041. parse(serializationObject: any): void;
  18042. }
  18043. /**
  18044. * Particle emitter emitting particles from the inside of a cylinder.
  18045. * It emits the particles randomly between two vectors.
  18046. */
  18047. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18048. /**
  18049. * The min limit of the emission direction.
  18050. */
  18051. direction1: Vector3;
  18052. /**
  18053. * The max limit of the emission direction.
  18054. */
  18055. direction2: Vector3;
  18056. /**
  18057. * Creates a new instance CylinderDirectedParticleEmitter
  18058. * @param radius the radius of the emission cylinder (1 by default)
  18059. * @param height the height of the emission cylinder (1 by default)
  18060. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18061. * @param direction1 the min limit of the emission direction (up vector by default)
  18062. * @param direction2 the max limit of the emission direction (up vector by default)
  18063. */
  18064. constructor(radius?: number, height?: number, radiusRange?: number,
  18065. /**
  18066. * The min limit of the emission direction.
  18067. */
  18068. direction1?: Vector3,
  18069. /**
  18070. * The max limit of the emission direction.
  18071. */
  18072. direction2?: Vector3);
  18073. /**
  18074. * Called by the particle System when the direction is computed for the created particle.
  18075. * @param worldMatrix is the world matrix of the particle system
  18076. * @param directionToUpdate is the direction vector to update with the result
  18077. * @param particle is the particle we are computed the direction for
  18078. */
  18079. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18080. /**
  18081. * Clones the current emitter and returns a copy of it
  18082. * @returns the new emitter
  18083. */
  18084. clone(): CylinderDirectedParticleEmitter;
  18085. /**
  18086. * Called by the GPUParticleSystem to setup the update shader
  18087. * @param effect defines the update shader
  18088. */
  18089. applyToShader(effect: Effect): void;
  18090. /**
  18091. * Returns a string to use to update the GPU particles update shader
  18092. * @returns a string containng the defines string
  18093. */
  18094. getEffectDefines(): string;
  18095. /**
  18096. * Returns the string "CylinderDirectedParticleEmitter"
  18097. * @returns a string containing the class name
  18098. */
  18099. getClassName(): string;
  18100. /**
  18101. * Serializes the particle system to a JSON object.
  18102. * @returns the JSON object
  18103. */
  18104. serialize(): any;
  18105. /**
  18106. * Parse properties from a JSON object
  18107. * @param serializationObject defines the JSON object
  18108. */
  18109. parse(serializationObject: any): void;
  18110. }
  18111. }
  18112. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18113. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18114. import { Effect } from "babylonjs/Materials/effect";
  18115. import { Particle } from "babylonjs/Particles/particle";
  18116. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18117. /**
  18118. * Particle emitter emitting particles from the inside of a hemisphere.
  18119. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18120. */
  18121. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18122. /**
  18123. * The radius of the emission hemisphere.
  18124. */
  18125. radius: number;
  18126. /**
  18127. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18128. */
  18129. radiusRange: number;
  18130. /**
  18131. * How much to randomize the particle direction [0-1].
  18132. */
  18133. directionRandomizer: number;
  18134. /**
  18135. * Creates a new instance HemisphericParticleEmitter
  18136. * @param radius the radius of the emission hemisphere (1 by default)
  18137. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18138. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18139. */
  18140. constructor(
  18141. /**
  18142. * The radius of the emission hemisphere.
  18143. */
  18144. radius?: number,
  18145. /**
  18146. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18147. */
  18148. radiusRange?: number,
  18149. /**
  18150. * How much to randomize the particle direction [0-1].
  18151. */
  18152. directionRandomizer?: number);
  18153. /**
  18154. * Called by the particle System when the direction is computed for the created particle.
  18155. * @param worldMatrix is the world matrix of the particle system
  18156. * @param directionToUpdate is the direction vector to update with the result
  18157. * @param particle is the particle we are computed the direction for
  18158. */
  18159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18160. /**
  18161. * Called by the particle System when the position is computed for the created particle.
  18162. * @param worldMatrix is the world matrix of the particle system
  18163. * @param positionToUpdate is the position vector to update with the result
  18164. * @param particle is the particle we are computed the position for
  18165. */
  18166. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18167. /**
  18168. * Clones the current emitter and returns a copy of it
  18169. * @returns the new emitter
  18170. */
  18171. clone(): HemisphericParticleEmitter;
  18172. /**
  18173. * Called by the GPUParticleSystem to setup the update shader
  18174. * @param effect defines the update shader
  18175. */
  18176. applyToShader(effect: Effect): void;
  18177. /**
  18178. * Returns a string to use to update the GPU particles update shader
  18179. * @returns a string containng the defines string
  18180. */
  18181. getEffectDefines(): string;
  18182. /**
  18183. * Returns the string "HemisphericParticleEmitter"
  18184. * @returns a string containing the class name
  18185. */
  18186. getClassName(): string;
  18187. /**
  18188. * Serializes the particle system to a JSON object.
  18189. * @returns the JSON object
  18190. */
  18191. serialize(): any;
  18192. /**
  18193. * Parse properties from a JSON object
  18194. * @param serializationObject defines the JSON object
  18195. */
  18196. parse(serializationObject: any): void;
  18197. }
  18198. }
  18199. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18200. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18201. import { Effect } from "babylonjs/Materials/effect";
  18202. import { Particle } from "babylonjs/Particles/particle";
  18203. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18204. /**
  18205. * Particle emitter emitting particles from a point.
  18206. * It emits the particles randomly between 2 given directions.
  18207. */
  18208. export class PointParticleEmitter implements IParticleEmitterType {
  18209. /**
  18210. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18211. */
  18212. direction1: Vector3;
  18213. /**
  18214. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18215. */
  18216. direction2: Vector3;
  18217. /**
  18218. * Creates a new instance PointParticleEmitter
  18219. */
  18220. constructor();
  18221. /**
  18222. * Called by the particle System when the direction is computed for the created particle.
  18223. * @param worldMatrix is the world matrix of the particle system
  18224. * @param directionToUpdate is the direction vector to update with the result
  18225. * @param particle is the particle we are computed the direction for
  18226. */
  18227. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18228. /**
  18229. * Called by the particle System when the position is computed for the created particle.
  18230. * @param worldMatrix is the world matrix of the particle system
  18231. * @param positionToUpdate is the position vector to update with the result
  18232. * @param particle is the particle we are computed the position for
  18233. */
  18234. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18235. /**
  18236. * Clones the current emitter and returns a copy of it
  18237. * @returns the new emitter
  18238. */
  18239. clone(): PointParticleEmitter;
  18240. /**
  18241. * Called by the GPUParticleSystem to setup the update shader
  18242. * @param effect defines the update shader
  18243. */
  18244. applyToShader(effect: Effect): void;
  18245. /**
  18246. * Returns a string to use to update the GPU particles update shader
  18247. * @returns a string containng the defines string
  18248. */
  18249. getEffectDefines(): string;
  18250. /**
  18251. * Returns the string "PointParticleEmitter"
  18252. * @returns a string containing the class name
  18253. */
  18254. getClassName(): string;
  18255. /**
  18256. * Serializes the particle system to a JSON object.
  18257. * @returns the JSON object
  18258. */
  18259. serialize(): any;
  18260. /**
  18261. * Parse properties from a JSON object
  18262. * @param serializationObject defines the JSON object
  18263. */
  18264. parse(serializationObject: any): void;
  18265. }
  18266. }
  18267. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18268. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18269. import { Effect } from "babylonjs/Materials/effect";
  18270. import { Particle } from "babylonjs/Particles/particle";
  18271. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18272. /**
  18273. * Particle emitter emitting particles from the inside of a sphere.
  18274. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18275. */
  18276. export class SphereParticleEmitter implements IParticleEmitterType {
  18277. /**
  18278. * The radius of the emission sphere.
  18279. */
  18280. radius: number;
  18281. /**
  18282. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18283. */
  18284. radiusRange: number;
  18285. /**
  18286. * How much to randomize the particle direction [0-1].
  18287. */
  18288. directionRandomizer: number;
  18289. /**
  18290. * Creates a new instance SphereParticleEmitter
  18291. * @param radius the radius of the emission sphere (1 by default)
  18292. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18293. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18294. */
  18295. constructor(
  18296. /**
  18297. * The radius of the emission sphere.
  18298. */
  18299. radius?: number,
  18300. /**
  18301. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18302. */
  18303. radiusRange?: number,
  18304. /**
  18305. * How much to randomize the particle direction [0-1].
  18306. */
  18307. directionRandomizer?: number);
  18308. /**
  18309. * Called by the particle System when the direction is computed for the created particle.
  18310. * @param worldMatrix is the world matrix of the particle system
  18311. * @param directionToUpdate is the direction vector to update with the result
  18312. * @param particle is the particle we are computed the direction for
  18313. */
  18314. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18315. /**
  18316. * Called by the particle System when the position is computed for the created particle.
  18317. * @param worldMatrix is the world matrix of the particle system
  18318. * @param positionToUpdate is the position vector to update with the result
  18319. * @param particle is the particle we are computed the position for
  18320. */
  18321. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18322. /**
  18323. * Clones the current emitter and returns a copy of it
  18324. * @returns the new emitter
  18325. */
  18326. clone(): SphereParticleEmitter;
  18327. /**
  18328. * Called by the GPUParticleSystem to setup the update shader
  18329. * @param effect defines the update shader
  18330. */
  18331. applyToShader(effect: Effect): void;
  18332. /**
  18333. * Returns a string to use to update the GPU particles update shader
  18334. * @returns a string containng the defines string
  18335. */
  18336. getEffectDefines(): string;
  18337. /**
  18338. * Returns the string "SphereParticleEmitter"
  18339. * @returns a string containing the class name
  18340. */
  18341. getClassName(): string;
  18342. /**
  18343. * Serializes the particle system to a JSON object.
  18344. * @returns the JSON object
  18345. */
  18346. serialize(): any;
  18347. /**
  18348. * Parse properties from a JSON object
  18349. * @param serializationObject defines the JSON object
  18350. */
  18351. parse(serializationObject: any): void;
  18352. }
  18353. /**
  18354. * Particle emitter emitting particles from the inside of a sphere.
  18355. * It emits the particles randomly between two vectors.
  18356. */
  18357. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18358. /**
  18359. * The min limit of the emission direction.
  18360. */
  18361. direction1: Vector3;
  18362. /**
  18363. * The max limit of the emission direction.
  18364. */
  18365. direction2: Vector3;
  18366. /**
  18367. * Creates a new instance SphereDirectedParticleEmitter
  18368. * @param radius the radius of the emission sphere (1 by default)
  18369. * @param direction1 the min limit of the emission direction (up vector by default)
  18370. * @param direction2 the max limit of the emission direction (up vector by default)
  18371. */
  18372. constructor(radius?: number,
  18373. /**
  18374. * The min limit of the emission direction.
  18375. */
  18376. direction1?: Vector3,
  18377. /**
  18378. * The max limit of the emission direction.
  18379. */
  18380. direction2?: Vector3);
  18381. /**
  18382. * Called by the particle System when the direction is computed for the created particle.
  18383. * @param worldMatrix is the world matrix of the particle system
  18384. * @param directionToUpdate is the direction vector to update with the result
  18385. * @param particle is the particle we are computed the direction for
  18386. */
  18387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18388. /**
  18389. * Clones the current emitter and returns a copy of it
  18390. * @returns the new emitter
  18391. */
  18392. clone(): SphereDirectedParticleEmitter;
  18393. /**
  18394. * Called by the GPUParticleSystem to setup the update shader
  18395. * @param effect defines the update shader
  18396. */
  18397. applyToShader(effect: Effect): void;
  18398. /**
  18399. * Returns a string to use to update the GPU particles update shader
  18400. * @returns a string containng the defines string
  18401. */
  18402. getEffectDefines(): string;
  18403. /**
  18404. * Returns the string "SphereDirectedParticleEmitter"
  18405. * @returns a string containing the class name
  18406. */
  18407. getClassName(): string;
  18408. /**
  18409. * Serializes the particle system to a JSON object.
  18410. * @returns the JSON object
  18411. */
  18412. serialize(): any;
  18413. /**
  18414. * Parse properties from a JSON object
  18415. * @param serializationObject defines the JSON object
  18416. */
  18417. parse(serializationObject: any): void;
  18418. }
  18419. }
  18420. declare module "babylonjs/Particles/EmitterTypes/index" {
  18421. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18422. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18423. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18424. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18425. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18426. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18427. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18428. }
  18429. declare module "babylonjs/Particles/IParticleSystem" {
  18430. import { Nullable } from "babylonjs/types";
  18431. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18432. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18435. import { Texture } from "babylonjs/Materials/Textures/texture";
  18436. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18437. import { Scene } from "babylonjs/scene";
  18438. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18439. import { Animation } from "babylonjs/Animations/animation";
  18440. /**
  18441. * Interface representing a particle system in Babylon.js.
  18442. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18443. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18444. */
  18445. export interface IParticleSystem {
  18446. /**
  18447. * List of animations used by the particle system.
  18448. */
  18449. animations: Animation[];
  18450. /**
  18451. * The id of the Particle system.
  18452. */
  18453. id: string;
  18454. /**
  18455. * The name of the Particle system.
  18456. */
  18457. name: string;
  18458. /**
  18459. * The emitter represents the Mesh or position we are attaching the particle system to.
  18460. */
  18461. emitter: Nullable<AbstractMesh | Vector3>;
  18462. /**
  18463. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18464. */
  18465. isBillboardBased: boolean;
  18466. /**
  18467. * The rendering group used by the Particle system to chose when to render.
  18468. */
  18469. renderingGroupId: number;
  18470. /**
  18471. * The layer mask we are rendering the particles through.
  18472. */
  18473. layerMask: number;
  18474. /**
  18475. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18476. */
  18477. updateSpeed: number;
  18478. /**
  18479. * The amount of time the particle system is running (depends of the overall update speed).
  18480. */
  18481. targetStopDuration: number;
  18482. /**
  18483. * The texture used to render each particle. (this can be a spritesheet)
  18484. */
  18485. particleTexture: Nullable<Texture>;
  18486. /**
  18487. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18488. */
  18489. blendMode: number;
  18490. /**
  18491. * Minimum life time of emitting particles.
  18492. */
  18493. minLifeTime: number;
  18494. /**
  18495. * Maximum life time of emitting particles.
  18496. */
  18497. maxLifeTime: number;
  18498. /**
  18499. * Minimum Size of emitting particles.
  18500. */
  18501. minSize: number;
  18502. /**
  18503. * Maximum Size of emitting particles.
  18504. */
  18505. maxSize: number;
  18506. /**
  18507. * Minimum scale of emitting particles on X axis.
  18508. */
  18509. minScaleX: number;
  18510. /**
  18511. * Maximum scale of emitting particles on X axis.
  18512. */
  18513. maxScaleX: number;
  18514. /**
  18515. * Minimum scale of emitting particles on Y axis.
  18516. */
  18517. minScaleY: number;
  18518. /**
  18519. * Maximum scale of emitting particles on Y axis.
  18520. */
  18521. maxScaleY: number;
  18522. /**
  18523. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18524. */
  18525. color1: Color4;
  18526. /**
  18527. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18528. */
  18529. color2: Color4;
  18530. /**
  18531. * Color the particle will have at the end of its lifetime.
  18532. */
  18533. colorDead: Color4;
  18534. /**
  18535. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18536. */
  18537. emitRate: number;
  18538. /**
  18539. * You can use gravity if you want to give an orientation to your particles.
  18540. */
  18541. gravity: Vector3;
  18542. /**
  18543. * Minimum power of emitting particles.
  18544. */
  18545. minEmitPower: number;
  18546. /**
  18547. * Maximum power of emitting particles.
  18548. */
  18549. maxEmitPower: number;
  18550. /**
  18551. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18552. */
  18553. minAngularSpeed: number;
  18554. /**
  18555. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18556. */
  18557. maxAngularSpeed: number;
  18558. /**
  18559. * Gets or sets the minimal initial rotation in radians.
  18560. */
  18561. minInitialRotation: number;
  18562. /**
  18563. * Gets or sets the maximal initial rotation in radians.
  18564. */
  18565. maxInitialRotation: number;
  18566. /**
  18567. * The particle emitter type defines the emitter used by the particle system.
  18568. * It can be for example box, sphere, or cone...
  18569. */
  18570. particleEmitterType: Nullable<IParticleEmitterType>;
  18571. /**
  18572. * Defines the delay in milliseconds before starting the system (0 by default)
  18573. */
  18574. startDelay: number;
  18575. /**
  18576. * 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
  18577. */
  18578. preWarmCycles: number;
  18579. /**
  18580. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18581. */
  18582. preWarmStepOffset: number;
  18583. /**
  18584. * 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)
  18585. */
  18586. spriteCellChangeSpeed: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18589. */
  18590. startSpriteCellID: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18593. */
  18594. endSpriteCellID: number;
  18595. /**
  18596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18597. */
  18598. spriteCellWidth: number;
  18599. /**
  18600. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18601. */
  18602. spriteCellHeight: number;
  18603. /**
  18604. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18605. */
  18606. spriteRandomStartCell: boolean;
  18607. /**
  18608. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18609. */
  18610. isAnimationSheetEnabled: boolean;
  18611. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18612. translationPivot: Vector2;
  18613. /**
  18614. * Gets or sets a texture used to add random noise to particle positions
  18615. */
  18616. noiseTexture: Nullable<BaseTexture>;
  18617. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18618. noiseStrength: Vector3;
  18619. /**
  18620. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18621. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18622. */
  18623. billboardMode: number;
  18624. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18625. limitVelocityDamping: number;
  18626. /**
  18627. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18628. */
  18629. beginAnimationOnStart: boolean;
  18630. /**
  18631. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationFrom: number;
  18634. /**
  18635. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18636. */
  18637. beginAnimationTo: number;
  18638. /**
  18639. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18640. */
  18641. beginAnimationLoop: boolean;
  18642. /**
  18643. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18644. */
  18645. disposeOnStop: boolean;
  18646. /**
  18647. * Gets the maximum number of particles active at the same time.
  18648. * @returns The max number of active particles.
  18649. */
  18650. getCapacity(): number;
  18651. /**
  18652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18653. * @returns True if it has been started, otherwise false.
  18654. */
  18655. isStarted(): boolean;
  18656. /**
  18657. * Animates the particle system for this frame.
  18658. */
  18659. animate(): void;
  18660. /**
  18661. * Renders the particle system in its current state.
  18662. * @returns the current number of particles
  18663. */
  18664. render(): number;
  18665. /**
  18666. * Dispose the particle system and frees its associated resources.
  18667. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18668. */
  18669. dispose(disposeTexture?: boolean): void;
  18670. /**
  18671. * Clones the particle system.
  18672. * @param name The name of the cloned object
  18673. * @param newEmitter The new emitter to use
  18674. * @returns the cloned particle system
  18675. */
  18676. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18677. /**
  18678. * Serializes the particle system to a JSON object.
  18679. * @returns the JSON object
  18680. */
  18681. serialize(): any;
  18682. /**
  18683. * Rebuild the particle system
  18684. */
  18685. rebuild(): void;
  18686. /**
  18687. * Starts the particle system and begins to emit
  18688. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18689. */
  18690. start(delay?: number): void;
  18691. /**
  18692. * Stops the particle system.
  18693. */
  18694. stop(): void;
  18695. /**
  18696. * Remove all active particles
  18697. */
  18698. reset(): void;
  18699. /**
  18700. * Is this system ready to be used/rendered
  18701. * @return true if the system is ready
  18702. */
  18703. isReady(): boolean;
  18704. /**
  18705. * Adds a new color gradient
  18706. * @param gradient defines the gradient to use (between 0 and 1)
  18707. * @param color1 defines the color to affect to the specified gradient
  18708. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18709. * @returns the current particle system
  18710. */
  18711. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18712. /**
  18713. * Remove a specific color gradient
  18714. * @param gradient defines the gradient to remove
  18715. * @returns the current particle system
  18716. */
  18717. removeColorGradient(gradient: number): IParticleSystem;
  18718. /**
  18719. * Adds a new size gradient
  18720. * @param gradient defines the gradient to use (between 0 and 1)
  18721. * @param factor defines the size factor to affect to the specified gradient
  18722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18723. * @returns the current particle system
  18724. */
  18725. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18726. /**
  18727. * Remove a specific size gradient
  18728. * @param gradient defines the gradient to remove
  18729. * @returns the current particle system
  18730. */
  18731. removeSizeGradient(gradient: number): IParticleSystem;
  18732. /**
  18733. * Gets the current list of color gradients.
  18734. * You must use addColorGradient and removeColorGradient to udpate this list
  18735. * @returns the list of color gradients
  18736. */
  18737. getColorGradients(): Nullable<Array<ColorGradient>>;
  18738. /**
  18739. * Gets the current list of size gradients.
  18740. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18741. * @returns the list of size gradients
  18742. */
  18743. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18744. /**
  18745. * Gets the current list of angular speed gradients.
  18746. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18747. * @returns the list of angular speed gradients
  18748. */
  18749. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18750. /**
  18751. * Adds a new angular speed gradient
  18752. * @param gradient defines the gradient to use (between 0 and 1)
  18753. * @param factor defines the angular speed to affect to the specified gradient
  18754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18755. * @returns the current particle system
  18756. */
  18757. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18758. /**
  18759. * Remove a specific angular speed gradient
  18760. * @param gradient defines the gradient to remove
  18761. * @returns the current particle system
  18762. */
  18763. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18764. /**
  18765. * Gets the current list of velocity gradients.
  18766. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18767. * @returns the list of velocity gradients
  18768. */
  18769. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18770. /**
  18771. * Adds a new velocity gradient
  18772. * @param gradient defines the gradient to use (between 0 and 1)
  18773. * @param factor defines the velocity to affect to the specified gradient
  18774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18775. * @returns the current particle system
  18776. */
  18777. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18778. /**
  18779. * Remove a specific velocity gradient
  18780. * @param gradient defines the gradient to remove
  18781. * @returns the current particle system
  18782. */
  18783. removeVelocityGradient(gradient: number): IParticleSystem;
  18784. /**
  18785. * Gets the current list of limit velocity gradients.
  18786. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18787. * @returns the list of limit velocity gradients
  18788. */
  18789. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18790. /**
  18791. * Adds a new limit velocity gradient
  18792. * @param gradient defines the gradient to use (between 0 and 1)
  18793. * @param factor defines the limit velocity to affect to the specified gradient
  18794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18795. * @returns the current particle system
  18796. */
  18797. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18798. /**
  18799. * Remove a specific limit velocity gradient
  18800. * @param gradient defines the gradient to remove
  18801. * @returns the current particle system
  18802. */
  18803. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18804. /**
  18805. * Adds a new drag gradient
  18806. * @param gradient defines the gradient to use (between 0 and 1)
  18807. * @param factor defines the drag to affect to the specified gradient
  18808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18809. * @returns the current particle system
  18810. */
  18811. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18812. /**
  18813. * Remove a specific drag gradient
  18814. * @param gradient defines the gradient to remove
  18815. * @returns the current particle system
  18816. */
  18817. removeDragGradient(gradient: number): IParticleSystem;
  18818. /**
  18819. * Gets the current list of drag gradients.
  18820. * You must use addDragGradient and removeDragGradient to udpate this list
  18821. * @returns the list of drag gradients
  18822. */
  18823. getDragGradients(): Nullable<Array<FactorGradient>>;
  18824. /**
  18825. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18826. * @param gradient defines the gradient to use (between 0 and 1)
  18827. * @param factor defines the emit rate to affect to the specified gradient
  18828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18829. * @returns the current particle system
  18830. */
  18831. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18832. /**
  18833. * Remove a specific emit rate gradient
  18834. * @param gradient defines the gradient to remove
  18835. * @returns the current particle system
  18836. */
  18837. removeEmitRateGradient(gradient: number): IParticleSystem;
  18838. /**
  18839. * Gets the current list of emit rate gradients.
  18840. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18841. * @returns the list of emit rate gradients
  18842. */
  18843. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18844. /**
  18845. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18846. * @param gradient defines the gradient to use (between 0 and 1)
  18847. * @param factor defines the start size to affect to the specified gradient
  18848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18849. * @returns the current particle system
  18850. */
  18851. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18852. /**
  18853. * Remove a specific start size gradient
  18854. * @param gradient defines the gradient to remove
  18855. * @returns the current particle system
  18856. */
  18857. removeStartSizeGradient(gradient: number): IParticleSystem;
  18858. /**
  18859. * Gets the current list of start size gradients.
  18860. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18861. * @returns the list of start size gradients
  18862. */
  18863. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18864. /**
  18865. * Adds a new life time gradient
  18866. * @param gradient defines the gradient to use (between 0 and 1)
  18867. * @param factor defines the life time factor to affect to the specified gradient
  18868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18869. * @returns the current particle system
  18870. */
  18871. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18872. /**
  18873. * Remove a specific life time gradient
  18874. * @param gradient defines the gradient to remove
  18875. * @returns the current particle system
  18876. */
  18877. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18878. /**
  18879. * Gets the current list of life time gradients.
  18880. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18881. * @returns the list of life time gradients
  18882. */
  18883. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18884. /**
  18885. * Gets the current list of color gradients.
  18886. * You must use addColorGradient and removeColorGradient to udpate this list
  18887. * @returns the list of color gradients
  18888. */
  18889. getColorGradients(): Nullable<Array<ColorGradient>>;
  18890. /**
  18891. * Adds a new ramp gradient used to remap particle colors
  18892. * @param gradient defines the gradient to use (between 0 and 1)
  18893. * @param color defines the color to affect to the specified gradient
  18894. * @returns the current particle system
  18895. */
  18896. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18897. /**
  18898. * Gets the current list of ramp gradients.
  18899. * You must use addRampGradient and removeRampGradient to udpate this list
  18900. * @returns the list of ramp gradients
  18901. */
  18902. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18903. /** Gets or sets a boolean indicating that ramp gradients must be used
  18904. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18905. */
  18906. useRampGradients: boolean;
  18907. /**
  18908. * Adds a new color remap gradient
  18909. * @param gradient defines the gradient to use (between 0 and 1)
  18910. * @param min defines the color remap minimal range
  18911. * @param max defines the color remap maximal range
  18912. * @returns the current particle system
  18913. */
  18914. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18915. /**
  18916. * Gets the current list of color remap gradients.
  18917. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18918. * @returns the list of color remap gradients
  18919. */
  18920. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18921. /**
  18922. * Adds a new alpha remap gradient
  18923. * @param gradient defines the gradient to use (between 0 and 1)
  18924. * @param min defines the alpha remap minimal range
  18925. * @param max defines the alpha remap maximal range
  18926. * @returns the current particle system
  18927. */
  18928. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18929. /**
  18930. * Gets the current list of alpha remap gradients.
  18931. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18932. * @returns the list of alpha remap gradients
  18933. */
  18934. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18935. /**
  18936. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18937. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18938. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18939. * @returns the emitter
  18940. */
  18941. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18942. /**
  18943. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18944. * @param radius The radius of the hemisphere to emit from
  18945. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18946. * @returns the emitter
  18947. */
  18948. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18949. /**
  18950. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18951. * @param radius The radius of the sphere to emit from
  18952. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18953. * @returns the emitter
  18954. */
  18955. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18956. /**
  18957. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18958. * @param radius The radius of the sphere to emit from
  18959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18961. * @returns the emitter
  18962. */
  18963. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18964. /**
  18965. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18966. * @param radius The radius of the emission cylinder
  18967. * @param height The height of the emission cylinder
  18968. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18969. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18970. * @returns the emitter
  18971. */
  18972. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18973. /**
  18974. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18975. * @param radius The radius of the cylinder to emit from
  18976. * @param height The height of the emission cylinder
  18977. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18978. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18979. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18980. * @returns the emitter
  18981. */
  18982. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18983. /**
  18984. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18985. * @param radius The radius of the cone to emit from
  18986. * @param angle The base angle of the cone
  18987. * @returns the emitter
  18988. */
  18989. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18990. /**
  18991. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18992. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18993. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18994. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18995. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18996. * @returns the emitter
  18997. */
  18998. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18999. /**
  19000. * Get hosting scene
  19001. * @returns the scene
  19002. */
  19003. getScene(): Scene;
  19004. }
  19005. }
  19006. declare module "babylonjs/Meshes/instancedMesh" {
  19007. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19008. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19009. import { Camera } from "babylonjs/Cameras/camera";
  19010. import { Node } from "babylonjs/node";
  19011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19012. import { Mesh } from "babylonjs/Meshes/mesh";
  19013. import { Material } from "babylonjs/Materials/material";
  19014. import { Skeleton } from "babylonjs/Bones/skeleton";
  19015. import { Light } from "babylonjs/Lights/light";
  19016. /**
  19017. * Creates an instance based on a source mesh.
  19018. */
  19019. export class InstancedMesh extends AbstractMesh {
  19020. private _sourceMesh;
  19021. private _currentLOD;
  19022. /** @hidden */
  19023. _indexInSourceMeshInstanceArray: number;
  19024. constructor(name: string, source: Mesh);
  19025. /**
  19026. * Returns the string "InstancedMesh".
  19027. */
  19028. getClassName(): string;
  19029. /** Gets the list of lights affecting that mesh */
  19030. readonly lightSources: Light[];
  19031. _resyncLightSources(): void;
  19032. _resyncLighSource(light: Light): void;
  19033. _removeLightSource(light: Light): void;
  19034. /**
  19035. * If the source mesh receives shadows
  19036. */
  19037. readonly receiveShadows: boolean;
  19038. /**
  19039. * The material of the source mesh
  19040. */
  19041. readonly material: Nullable<Material>;
  19042. /**
  19043. * Visibility of the source mesh
  19044. */
  19045. readonly visibility: number;
  19046. /**
  19047. * Skeleton of the source mesh
  19048. */
  19049. readonly skeleton: Nullable<Skeleton>;
  19050. /**
  19051. * Rendering ground id of the source mesh
  19052. */
  19053. renderingGroupId: number;
  19054. /**
  19055. * Returns the total number of vertices (integer).
  19056. */
  19057. getTotalVertices(): number;
  19058. /**
  19059. * Returns a positive integer : the total number of indices in this mesh geometry.
  19060. * @returns the numner of indices or zero if the mesh has no geometry.
  19061. */
  19062. getTotalIndices(): number;
  19063. /**
  19064. * The source mesh of the instance
  19065. */
  19066. readonly sourceMesh: Mesh;
  19067. /**
  19068. * Is this node ready to be used/rendered
  19069. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19070. * @return {boolean} is it ready
  19071. */
  19072. isReady(completeCheck?: boolean): boolean;
  19073. /**
  19074. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19075. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19076. * @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.
  19077. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19078. */
  19079. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19080. /**
  19081. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19082. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19083. * The `data` are either a numeric array either a Float32Array.
  19084. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19085. * 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).
  19086. * Note that a new underlying VertexBuffer object is created each call.
  19087. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19088. *
  19089. * Possible `kind` values :
  19090. * - VertexBuffer.PositionKind
  19091. * - VertexBuffer.UVKind
  19092. * - VertexBuffer.UV2Kind
  19093. * - VertexBuffer.UV3Kind
  19094. * - VertexBuffer.UV4Kind
  19095. * - VertexBuffer.UV5Kind
  19096. * - VertexBuffer.UV6Kind
  19097. * - VertexBuffer.ColorKind
  19098. * - VertexBuffer.MatricesIndicesKind
  19099. * - VertexBuffer.MatricesIndicesExtraKind
  19100. * - VertexBuffer.MatricesWeightsKind
  19101. * - VertexBuffer.MatricesWeightsExtraKind
  19102. *
  19103. * Returns the Mesh.
  19104. */
  19105. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19106. /**
  19107. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19108. * If the mesh has no geometry, it is simply returned as it is.
  19109. * The `data` are either a numeric array either a Float32Array.
  19110. * No new underlying VertexBuffer object is created.
  19111. * 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.
  19112. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19113. *
  19114. * Possible `kind` values :
  19115. * - VertexBuffer.PositionKind
  19116. * - VertexBuffer.UVKind
  19117. * - VertexBuffer.UV2Kind
  19118. * - VertexBuffer.UV3Kind
  19119. * - VertexBuffer.UV4Kind
  19120. * - VertexBuffer.UV5Kind
  19121. * - VertexBuffer.UV6Kind
  19122. * - VertexBuffer.ColorKind
  19123. * - VertexBuffer.MatricesIndicesKind
  19124. * - VertexBuffer.MatricesIndicesExtraKind
  19125. * - VertexBuffer.MatricesWeightsKind
  19126. * - VertexBuffer.MatricesWeightsExtraKind
  19127. *
  19128. * Returns the Mesh.
  19129. */
  19130. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19131. /**
  19132. * Sets the mesh indices.
  19133. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19134. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19135. * This method creates a new index buffer each call.
  19136. * Returns the Mesh.
  19137. */
  19138. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19139. /**
  19140. * Boolean : True if the mesh owns the requested kind of data.
  19141. */
  19142. isVerticesDataPresent(kind: string): boolean;
  19143. /**
  19144. * Returns an array of indices (IndicesArray).
  19145. */
  19146. getIndices(): Nullable<IndicesArray>;
  19147. readonly _positions: Nullable<Vector3[]>;
  19148. /**
  19149. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19150. * This means the mesh underlying bounding box and sphere are recomputed.
  19151. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19152. * @returns the current mesh
  19153. */
  19154. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19155. /** @hidden */
  19156. _preActivate(): InstancedMesh;
  19157. /** @hidden */
  19158. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19159. /** @hidden */
  19160. _postActivate(): void;
  19161. getWorldMatrix(): Matrix;
  19162. readonly isAnInstance: boolean;
  19163. /**
  19164. * Returns the current associated LOD AbstractMesh.
  19165. */
  19166. getLOD(camera: Camera): AbstractMesh;
  19167. /** @hidden */
  19168. _syncSubMeshes(): InstancedMesh;
  19169. /** @hidden */
  19170. _generatePointsArray(): boolean;
  19171. /**
  19172. * Creates a new InstancedMesh from the current mesh.
  19173. * - name (string) : the cloned mesh name
  19174. * - newParent (optional Node) : the optional Node to parent the clone to.
  19175. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19176. *
  19177. * Returns the clone.
  19178. */
  19179. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19180. /**
  19181. * Disposes the InstancedMesh.
  19182. * Returns nothing.
  19183. */
  19184. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19185. }
  19186. }
  19187. declare module "babylonjs/Materials/shaderMaterial" {
  19188. import { Scene } from "babylonjs/scene";
  19189. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19191. import { Mesh } from "babylonjs/Meshes/mesh";
  19192. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19194. import { Texture } from "babylonjs/Materials/Textures/texture";
  19195. import { Material } from "babylonjs/Materials/material";
  19196. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19197. /**
  19198. * Defines the options associated with the creation of a shader material.
  19199. */
  19200. export interface IShaderMaterialOptions {
  19201. /**
  19202. * Does the material work in alpha blend mode
  19203. */
  19204. needAlphaBlending: boolean;
  19205. /**
  19206. * Does the material work in alpha test mode
  19207. */
  19208. needAlphaTesting: boolean;
  19209. /**
  19210. * The list of attribute names used in the shader
  19211. */
  19212. attributes: string[];
  19213. /**
  19214. * The list of unifrom names used in the shader
  19215. */
  19216. uniforms: string[];
  19217. /**
  19218. * The list of UBO names used in the shader
  19219. */
  19220. uniformBuffers: string[];
  19221. /**
  19222. * The list of sampler names used in the shader
  19223. */
  19224. samplers: string[];
  19225. /**
  19226. * The list of defines used in the shader
  19227. */
  19228. defines: string[];
  19229. }
  19230. /**
  19231. * 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.
  19232. *
  19233. * This returned material effects how the mesh will look based on the code in the shaders.
  19234. *
  19235. * @see http://doc.babylonjs.com/how_to/shader_material
  19236. */
  19237. export class ShaderMaterial extends Material {
  19238. private _shaderPath;
  19239. private _options;
  19240. private _textures;
  19241. private _textureArrays;
  19242. private _floats;
  19243. private _ints;
  19244. private _floatsArrays;
  19245. private _colors3;
  19246. private _colors3Arrays;
  19247. private _colors4;
  19248. private _colors4Arrays;
  19249. private _vectors2;
  19250. private _vectors3;
  19251. private _vectors4;
  19252. private _matrices;
  19253. private _matrices3x3;
  19254. private _matrices2x2;
  19255. private _vectors2Arrays;
  19256. private _vectors3Arrays;
  19257. private _vectors4Arrays;
  19258. private _cachedWorldViewMatrix;
  19259. private _cachedWorldViewProjectionMatrix;
  19260. private _renderId;
  19261. /**
  19262. * Instantiate a new shader material.
  19263. * 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.
  19264. * This returned material effects how the mesh will look based on the code in the shaders.
  19265. * @see http://doc.babylonjs.com/how_to/shader_material
  19266. * @param name Define the name of the material in the scene
  19267. * @param scene Define the scene the material belongs to
  19268. * @param shaderPath Defines the route to the shader code in one of three ways:
  19269. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19270. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19271. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19272. * @param options Define the options used to create the shader
  19273. */
  19274. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19275. /**
  19276. * Gets the options used to compile the shader.
  19277. * They can be modified to trigger a new compilation
  19278. */
  19279. readonly options: IShaderMaterialOptions;
  19280. /**
  19281. * Gets the current class name of the material e.g. "ShaderMaterial"
  19282. * Mainly use in serialization.
  19283. * @returns the class name
  19284. */
  19285. getClassName(): string;
  19286. /**
  19287. * Specifies if the material will require alpha blending
  19288. * @returns a boolean specifying if alpha blending is needed
  19289. */
  19290. needAlphaBlending(): boolean;
  19291. /**
  19292. * Specifies if this material should be rendered in alpha test mode
  19293. * @returns a boolean specifying if an alpha test is needed.
  19294. */
  19295. needAlphaTesting(): boolean;
  19296. private _checkUniform;
  19297. /**
  19298. * Set a texture in the shader.
  19299. * @param name Define the name of the uniform samplers as defined in the shader
  19300. * @param texture Define the texture to bind to this sampler
  19301. * @return the material itself allowing "fluent" like uniform updates
  19302. */
  19303. setTexture(name: string, texture: Texture): ShaderMaterial;
  19304. /**
  19305. * Set a texture array in the shader.
  19306. * @param name Define the name of the uniform sampler array as defined in the shader
  19307. * @param textures Define the list of textures to bind to this sampler
  19308. * @return the material itself allowing "fluent" like uniform updates
  19309. */
  19310. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19311. /**
  19312. * Set a float in the shader.
  19313. * @param name Define the name of the uniform as defined in the shader
  19314. * @param value Define the value to give to the uniform
  19315. * @return the material itself allowing "fluent" like uniform updates
  19316. */
  19317. setFloat(name: string, value: number): ShaderMaterial;
  19318. /**
  19319. * Set a int in the shader.
  19320. * @param name Define the name of the uniform as defined in the shader
  19321. * @param value Define the value to give to the uniform
  19322. * @return the material itself allowing "fluent" like uniform updates
  19323. */
  19324. setInt(name: string, value: number): ShaderMaterial;
  19325. /**
  19326. * Set an array of floats in the shader.
  19327. * @param name Define the name of the uniform as defined in the shader
  19328. * @param value Define the value to give to the uniform
  19329. * @return the material itself allowing "fluent" like uniform updates
  19330. */
  19331. setFloats(name: string, value: number[]): ShaderMaterial;
  19332. /**
  19333. * Set a vec3 in the shader from a Color3.
  19334. * @param name Define the name of the uniform as defined in the shader
  19335. * @param value Define the value to give to the uniform
  19336. * @return the material itself allowing "fluent" like uniform updates
  19337. */
  19338. setColor3(name: string, value: Color3): ShaderMaterial;
  19339. /**
  19340. * Set a vec3 array in the shader from a Color3 array.
  19341. * @param name Define the name of the uniform as defined in the shader
  19342. * @param value Define the value to give to the uniform
  19343. * @return the material itself allowing "fluent" like uniform updates
  19344. */
  19345. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19346. /**
  19347. * Set a vec4 in the shader from a Color4.
  19348. * @param name Define the name of the uniform as defined in the shader
  19349. * @param value Define the value to give to the uniform
  19350. * @return the material itself allowing "fluent" like uniform updates
  19351. */
  19352. setColor4(name: string, value: Color4): ShaderMaterial;
  19353. /**
  19354. * Set a vec4 array in the shader from a Color4 array.
  19355. * @param name Define the name of the uniform as defined in the shader
  19356. * @param value Define the value to give to the uniform
  19357. * @return the material itself allowing "fluent" like uniform updates
  19358. */
  19359. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19360. /**
  19361. * Set a vec2 in the shader from a Vector2.
  19362. * @param name Define the name of the uniform as defined in the shader
  19363. * @param value Define the value to give to the uniform
  19364. * @return the material itself allowing "fluent" like uniform updates
  19365. */
  19366. setVector2(name: string, value: Vector2): ShaderMaterial;
  19367. /**
  19368. * Set a vec3 in the shader from a Vector3.
  19369. * @param name Define the name of the uniform as defined in the shader
  19370. * @param value Define the value to give to the uniform
  19371. * @return the material itself allowing "fluent" like uniform updates
  19372. */
  19373. setVector3(name: string, value: Vector3): ShaderMaterial;
  19374. /**
  19375. * Set a vec4 in the shader from a Vector4.
  19376. * @param name Define the name of the uniform as defined in the shader
  19377. * @param value Define the value to give to the uniform
  19378. * @return the material itself allowing "fluent" like uniform updates
  19379. */
  19380. setVector4(name: string, value: Vector4): ShaderMaterial;
  19381. /**
  19382. * Set a mat4 in the shader from a Matrix.
  19383. * @param name Define the name of the uniform as defined in the shader
  19384. * @param value Define the value to give to the uniform
  19385. * @return the material itself allowing "fluent" like uniform updates
  19386. */
  19387. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19388. /**
  19389. * Set a mat3 in the shader from a Float32Array.
  19390. * @param name Define the name of the uniform as defined in the shader
  19391. * @param value Define the value to give to the uniform
  19392. * @return the material itself allowing "fluent" like uniform updates
  19393. */
  19394. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19395. /**
  19396. * Set a mat2 in the shader from a Float32Array.
  19397. * @param name Define the name of the uniform as defined in the shader
  19398. * @param value Define the value to give to the uniform
  19399. * @return the material itself allowing "fluent" like uniform updates
  19400. */
  19401. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19402. /**
  19403. * Set a vec2 array in the shader from a number array.
  19404. * @param name Define the name of the uniform as defined in the shader
  19405. * @param value Define the value to give to the uniform
  19406. * @return the material itself allowing "fluent" like uniform updates
  19407. */
  19408. setArray2(name: string, value: number[]): ShaderMaterial;
  19409. /**
  19410. * Set a vec3 array in the shader from a number array.
  19411. * @param name Define the name of the uniform as defined in the shader
  19412. * @param value Define the value to give to the uniform
  19413. * @return the material itself allowing "fluent" like uniform updates
  19414. */
  19415. setArray3(name: string, value: number[]): ShaderMaterial;
  19416. /**
  19417. * Set a vec4 array in the shader from a number array.
  19418. * @param name Define the name of the uniform as defined in the shader
  19419. * @param value Define the value to give to the uniform
  19420. * @return the material itself allowing "fluent" like uniform updates
  19421. */
  19422. setArray4(name: string, value: number[]): ShaderMaterial;
  19423. private _checkCache;
  19424. /**
  19425. * Specifies that the submesh is ready to be used
  19426. * @param mesh defines the mesh to check
  19427. * @param subMesh defines which submesh to check
  19428. * @param useInstances specifies that instances should be used
  19429. * @returns a boolean indicating that the submesh is ready or not
  19430. */
  19431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19432. /**
  19433. * Checks if the material is ready to render the requested mesh
  19434. * @param mesh Define the mesh to render
  19435. * @param useInstances Define whether or not the material is used with instances
  19436. * @returns true if ready, otherwise false
  19437. */
  19438. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19439. /**
  19440. * Binds the world matrix to the material
  19441. * @param world defines the world transformation matrix
  19442. */
  19443. bindOnlyWorldMatrix(world: Matrix): void;
  19444. /**
  19445. * Binds the material to the mesh
  19446. * @param world defines the world transformation matrix
  19447. * @param mesh defines the mesh to bind the material to
  19448. */
  19449. bind(world: Matrix, mesh?: Mesh): void;
  19450. /**
  19451. * Gets the active textures from the material
  19452. * @returns an array of textures
  19453. */
  19454. getActiveTextures(): BaseTexture[];
  19455. /**
  19456. * Specifies if the material uses a texture
  19457. * @param texture defines the texture to check against the material
  19458. * @returns a boolean specifying if the material uses the texture
  19459. */
  19460. hasTexture(texture: BaseTexture): boolean;
  19461. /**
  19462. * Makes a duplicate of the material, and gives it a new name
  19463. * @param name defines the new name for the duplicated material
  19464. * @returns the cloned material
  19465. */
  19466. clone(name: string): ShaderMaterial;
  19467. /**
  19468. * Disposes the material
  19469. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19470. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19471. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19472. */
  19473. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19474. /**
  19475. * Serializes this material in a JSON representation
  19476. * @returns the serialized material object
  19477. */
  19478. serialize(): any;
  19479. /**
  19480. * Creates a shader material from parsed shader material data
  19481. * @param source defines the JSON represnetation of the material
  19482. * @param scene defines the hosting scene
  19483. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19484. * @returns a new material
  19485. */
  19486. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19487. }
  19488. }
  19489. declare module "babylonjs/Shaders/color.fragment" {
  19490. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19491. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19492. /** @hidden */
  19493. export var colorPixelShader: {
  19494. name: string;
  19495. shader: string;
  19496. };
  19497. }
  19498. declare module "babylonjs/Shaders/color.vertex" {
  19499. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19500. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19501. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19502. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19503. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19504. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19505. /** @hidden */
  19506. export var colorVertexShader: {
  19507. name: string;
  19508. shader: string;
  19509. };
  19510. }
  19511. declare module "babylonjs/Meshes/linesMesh" {
  19512. import { Nullable } from "babylonjs/types";
  19513. import { Scene } from "babylonjs/scene";
  19514. import { Color3 } from "babylonjs/Maths/math.color";
  19515. import { Node } from "babylonjs/node";
  19516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19517. import { Mesh } from "babylonjs/Meshes/mesh";
  19518. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19519. import { Effect } from "babylonjs/Materials/effect";
  19520. import { Material } from "babylonjs/Materials/material";
  19521. import "babylonjs/Shaders/color.fragment";
  19522. import "babylonjs/Shaders/color.vertex";
  19523. /**
  19524. * Line mesh
  19525. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19526. */
  19527. export class LinesMesh extends Mesh {
  19528. /**
  19529. * If vertex color should be applied to the mesh
  19530. */
  19531. readonly useVertexColor?: boolean | undefined;
  19532. /**
  19533. * If vertex alpha should be applied to the mesh
  19534. */
  19535. readonly useVertexAlpha?: boolean | undefined;
  19536. /**
  19537. * Color of the line (Default: White)
  19538. */
  19539. color: Color3;
  19540. /**
  19541. * Alpha of the line (Default: 1)
  19542. */
  19543. alpha: number;
  19544. /**
  19545. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19546. * This margin is expressed in world space coordinates, so its value may vary.
  19547. * Default value is 0.1
  19548. */
  19549. intersectionThreshold: number;
  19550. private _colorShader;
  19551. private color4;
  19552. /**
  19553. * Creates a new LinesMesh
  19554. * @param name defines the name
  19555. * @param scene defines the hosting scene
  19556. * @param parent defines the parent mesh if any
  19557. * @param source defines the optional source LinesMesh used to clone data from
  19558. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19559. * When false, achieved by calling a clone(), also passing False.
  19560. * This will make creation of children, recursive.
  19561. * @param useVertexColor defines if this LinesMesh supports vertex color
  19562. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19563. */
  19564. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19565. /**
  19566. * If vertex color should be applied to the mesh
  19567. */
  19568. useVertexColor?: boolean | undefined,
  19569. /**
  19570. * If vertex alpha should be applied to the mesh
  19571. */
  19572. useVertexAlpha?: boolean | undefined);
  19573. private _addClipPlaneDefine;
  19574. private _removeClipPlaneDefine;
  19575. isReady(): boolean;
  19576. /**
  19577. * Returns the string "LineMesh"
  19578. */
  19579. getClassName(): string;
  19580. /**
  19581. * @hidden
  19582. */
  19583. /**
  19584. * @hidden
  19585. */
  19586. material: Material;
  19587. /**
  19588. * @hidden
  19589. */
  19590. readonly checkCollisions: boolean;
  19591. /** @hidden */
  19592. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19593. /** @hidden */
  19594. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19595. /**
  19596. * Disposes of the line mesh
  19597. * @param doNotRecurse If children should be disposed
  19598. */
  19599. dispose(doNotRecurse?: boolean): void;
  19600. /**
  19601. * Returns a new LineMesh object cloned from the current one.
  19602. */
  19603. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19604. /**
  19605. * Creates a new InstancedLinesMesh object from the mesh model.
  19606. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19607. * @param name defines the name of the new instance
  19608. * @returns a new InstancedLinesMesh
  19609. */
  19610. createInstance(name: string): InstancedLinesMesh;
  19611. }
  19612. /**
  19613. * Creates an instance based on a source LinesMesh
  19614. */
  19615. export class InstancedLinesMesh extends InstancedMesh {
  19616. /**
  19617. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19618. * This margin is expressed in world space coordinates, so its value may vary.
  19619. * Initilized with the intersectionThreshold value of the source LinesMesh
  19620. */
  19621. intersectionThreshold: number;
  19622. constructor(name: string, source: LinesMesh);
  19623. /**
  19624. * Returns the string "InstancedLinesMesh".
  19625. */
  19626. getClassName(): string;
  19627. }
  19628. }
  19629. declare module "babylonjs/Shaders/line.fragment" {
  19630. /** @hidden */
  19631. export var linePixelShader: {
  19632. name: string;
  19633. shader: string;
  19634. };
  19635. }
  19636. declare module "babylonjs/Shaders/line.vertex" {
  19637. /** @hidden */
  19638. export var lineVertexShader: {
  19639. name: string;
  19640. shader: string;
  19641. };
  19642. }
  19643. declare module "babylonjs/Rendering/edgesRenderer" {
  19644. import { Nullable } from "babylonjs/types";
  19645. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19647. import { Vector3 } from "babylonjs/Maths/math.vector";
  19648. import { IDisposable } from "babylonjs/scene";
  19649. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19650. import "babylonjs/Shaders/line.fragment";
  19651. import "babylonjs/Shaders/line.vertex";
  19652. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19653. module "babylonjs/Meshes/abstractMesh" {
  19654. interface AbstractMesh {
  19655. /**
  19656. * Gets the edgesRenderer associated with the mesh
  19657. */
  19658. edgesRenderer: Nullable<EdgesRenderer>;
  19659. }
  19660. }
  19661. module "babylonjs/Meshes/linesMesh" {
  19662. interface LinesMesh {
  19663. /**
  19664. * Enables the edge rendering mode on the mesh.
  19665. * This mode makes the mesh edges visible
  19666. * @param epsilon defines the maximal distance between two angles to detect a face
  19667. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19668. * @returns the currentAbstractMesh
  19669. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19670. */
  19671. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19672. }
  19673. }
  19674. module "babylonjs/Meshes/linesMesh" {
  19675. interface InstancedLinesMesh {
  19676. /**
  19677. * Enables the edge rendering mode on the mesh.
  19678. * This mode makes the mesh edges visible
  19679. * @param epsilon defines the maximal distance between two angles to detect a face
  19680. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19681. * @returns the current InstancedLinesMesh
  19682. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19683. */
  19684. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19685. }
  19686. }
  19687. /**
  19688. * Defines the minimum contract an Edges renderer should follow.
  19689. */
  19690. export interface IEdgesRenderer extends IDisposable {
  19691. /**
  19692. * Gets or sets a boolean indicating if the edgesRenderer is active
  19693. */
  19694. isEnabled: boolean;
  19695. /**
  19696. * Renders the edges of the attached mesh,
  19697. */
  19698. render(): void;
  19699. /**
  19700. * Checks wether or not the edges renderer is ready to render.
  19701. * @return true if ready, otherwise false.
  19702. */
  19703. isReady(): boolean;
  19704. }
  19705. /**
  19706. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19707. */
  19708. export class EdgesRenderer implements IEdgesRenderer {
  19709. /**
  19710. * Define the size of the edges with an orthographic camera
  19711. */
  19712. edgesWidthScalerForOrthographic: number;
  19713. /**
  19714. * Define the size of the edges with a perspective camera
  19715. */
  19716. edgesWidthScalerForPerspective: number;
  19717. protected _source: AbstractMesh;
  19718. protected _linesPositions: number[];
  19719. protected _linesNormals: number[];
  19720. protected _linesIndices: number[];
  19721. protected _epsilon: number;
  19722. protected _indicesCount: number;
  19723. protected _lineShader: ShaderMaterial;
  19724. protected _ib: DataBuffer;
  19725. protected _buffers: {
  19726. [key: string]: Nullable<VertexBuffer>;
  19727. };
  19728. protected _checkVerticesInsteadOfIndices: boolean;
  19729. private _meshRebuildObserver;
  19730. private _meshDisposeObserver;
  19731. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19732. isEnabled: boolean;
  19733. /**
  19734. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19735. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19736. * @param source Mesh used to create edges
  19737. * @param epsilon sum of angles in adjacency to check for edge
  19738. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19739. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19740. */
  19741. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19742. protected _prepareRessources(): void;
  19743. /** @hidden */
  19744. _rebuild(): void;
  19745. /**
  19746. * Releases the required resources for the edges renderer
  19747. */
  19748. dispose(): void;
  19749. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19750. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19751. /**
  19752. * Checks if the pair of p0 and p1 is en edge
  19753. * @param faceIndex
  19754. * @param edge
  19755. * @param faceNormals
  19756. * @param p0
  19757. * @param p1
  19758. * @private
  19759. */
  19760. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19761. /**
  19762. * push line into the position, normal and index buffer
  19763. * @protected
  19764. */
  19765. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19766. /**
  19767. * Generates lines edges from adjacencjes
  19768. * @private
  19769. */
  19770. _generateEdgesLines(): void;
  19771. /**
  19772. * Checks wether or not the edges renderer is ready to render.
  19773. * @return true if ready, otherwise false.
  19774. */
  19775. isReady(): boolean;
  19776. /**
  19777. * Renders the edges of the attached mesh,
  19778. */
  19779. render(): void;
  19780. }
  19781. /**
  19782. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19783. */
  19784. export class LineEdgesRenderer extends EdgesRenderer {
  19785. /**
  19786. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19787. * @param source LineMesh used to generate edges
  19788. * @param epsilon not important (specified angle for edge detection)
  19789. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19790. */
  19791. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19792. /**
  19793. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19794. */
  19795. _generateEdgesLines(): void;
  19796. }
  19797. }
  19798. declare module "babylonjs/Rendering/renderingGroup" {
  19799. import { SmartArray } from "babylonjs/Misc/smartArray";
  19800. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19802. import { Nullable } from "babylonjs/types";
  19803. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19804. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19805. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19806. import { Material } from "babylonjs/Materials/material";
  19807. import { Scene } from "babylonjs/scene";
  19808. /**
  19809. * This represents the object necessary to create a rendering group.
  19810. * This is exclusively used and created by the rendering manager.
  19811. * To modify the behavior, you use the available helpers in your scene or meshes.
  19812. * @hidden
  19813. */
  19814. export class RenderingGroup {
  19815. index: number;
  19816. private static _zeroVector;
  19817. private _scene;
  19818. private _opaqueSubMeshes;
  19819. private _transparentSubMeshes;
  19820. private _alphaTestSubMeshes;
  19821. private _depthOnlySubMeshes;
  19822. private _particleSystems;
  19823. private _spriteManagers;
  19824. private _opaqueSortCompareFn;
  19825. private _alphaTestSortCompareFn;
  19826. private _transparentSortCompareFn;
  19827. private _renderOpaque;
  19828. private _renderAlphaTest;
  19829. private _renderTransparent;
  19830. /** @hidden */
  19831. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19832. onBeforeTransparentRendering: () => void;
  19833. /**
  19834. * Set the opaque sort comparison function.
  19835. * If null the sub meshes will be render in the order they were created
  19836. */
  19837. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19838. /**
  19839. * Set the alpha test sort comparison function.
  19840. * If null the sub meshes will be render in the order they were created
  19841. */
  19842. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19843. /**
  19844. * Set the transparent sort comparison function.
  19845. * If null the sub meshes will be render in the order they were created
  19846. */
  19847. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19848. /**
  19849. * Creates a new rendering group.
  19850. * @param index The rendering group index
  19851. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19852. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19853. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19854. */
  19855. 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>);
  19856. /**
  19857. * Render all the sub meshes contained in the group.
  19858. * @param customRenderFunction Used to override the default render behaviour of the group.
  19859. * @returns true if rendered some submeshes.
  19860. */
  19861. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19862. /**
  19863. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19864. * @param subMeshes The submeshes to render
  19865. */
  19866. private renderOpaqueSorted;
  19867. /**
  19868. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19869. * @param subMeshes The submeshes to render
  19870. */
  19871. private renderAlphaTestSorted;
  19872. /**
  19873. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19874. * @param subMeshes The submeshes to render
  19875. */
  19876. private renderTransparentSorted;
  19877. /**
  19878. * Renders the submeshes in a specified order.
  19879. * @param subMeshes The submeshes to sort before render
  19880. * @param sortCompareFn The comparison function use to sort
  19881. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19882. * @param transparent Specifies to activate blending if true
  19883. */
  19884. private static renderSorted;
  19885. /**
  19886. * Renders the submeshes in the order they were dispatched (no sort applied).
  19887. * @param subMeshes The submeshes to render
  19888. */
  19889. private static renderUnsorted;
  19890. /**
  19891. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19892. * are rendered back to front if in the same alpha index.
  19893. *
  19894. * @param a The first submesh
  19895. * @param b The second submesh
  19896. * @returns The result of the comparison
  19897. */
  19898. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19899. /**
  19900. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19901. * are rendered back to front.
  19902. *
  19903. * @param a The first submesh
  19904. * @param b The second submesh
  19905. * @returns The result of the comparison
  19906. */
  19907. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19908. /**
  19909. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19910. * are rendered front to back (prevent overdraw).
  19911. *
  19912. * @param a The first submesh
  19913. * @param b The second submesh
  19914. * @returns The result of the comparison
  19915. */
  19916. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19917. /**
  19918. * Resets the different lists of submeshes to prepare a new frame.
  19919. */
  19920. prepare(): void;
  19921. dispose(): void;
  19922. /**
  19923. * Inserts the submesh in its correct queue depending on its material.
  19924. * @param subMesh The submesh to dispatch
  19925. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19926. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19927. */
  19928. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19929. dispatchSprites(spriteManager: ISpriteManager): void;
  19930. dispatchParticles(particleSystem: IParticleSystem): void;
  19931. private _renderParticles;
  19932. private _renderSprites;
  19933. }
  19934. }
  19935. declare module "babylonjs/Rendering/renderingManager" {
  19936. import { Nullable } from "babylonjs/types";
  19937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19939. import { SmartArray } from "babylonjs/Misc/smartArray";
  19940. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19941. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19942. import { Material } from "babylonjs/Materials/material";
  19943. import { Scene } from "babylonjs/scene";
  19944. import { Camera } from "babylonjs/Cameras/camera";
  19945. /**
  19946. * Interface describing the different options available in the rendering manager
  19947. * regarding Auto Clear between groups.
  19948. */
  19949. export interface IRenderingManagerAutoClearSetup {
  19950. /**
  19951. * Defines whether or not autoclear is enable.
  19952. */
  19953. autoClear: boolean;
  19954. /**
  19955. * Defines whether or not to autoclear the depth buffer.
  19956. */
  19957. depth: boolean;
  19958. /**
  19959. * Defines whether or not to autoclear the stencil buffer.
  19960. */
  19961. stencil: boolean;
  19962. }
  19963. /**
  19964. * This class is used by the onRenderingGroupObservable
  19965. */
  19966. export class RenderingGroupInfo {
  19967. /**
  19968. * The Scene that being rendered
  19969. */
  19970. scene: Scene;
  19971. /**
  19972. * The camera currently used for the rendering pass
  19973. */
  19974. camera: Nullable<Camera>;
  19975. /**
  19976. * The ID of the renderingGroup being processed
  19977. */
  19978. renderingGroupId: number;
  19979. }
  19980. /**
  19981. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19982. * It is enable to manage the different groups as well as the different necessary sort functions.
  19983. * This should not be used directly aside of the few static configurations
  19984. */
  19985. export class RenderingManager {
  19986. /**
  19987. * The max id used for rendering groups (not included)
  19988. */
  19989. static MAX_RENDERINGGROUPS: number;
  19990. /**
  19991. * The min id used for rendering groups (included)
  19992. */
  19993. static MIN_RENDERINGGROUPS: number;
  19994. /**
  19995. * Used to globally prevent autoclearing scenes.
  19996. */
  19997. static AUTOCLEAR: boolean;
  19998. /**
  19999. * @hidden
  20000. */
  20001. _useSceneAutoClearSetup: boolean;
  20002. private _scene;
  20003. private _renderingGroups;
  20004. private _depthStencilBufferAlreadyCleaned;
  20005. private _autoClearDepthStencil;
  20006. private _customOpaqueSortCompareFn;
  20007. private _customAlphaTestSortCompareFn;
  20008. private _customTransparentSortCompareFn;
  20009. private _renderingGroupInfo;
  20010. /**
  20011. * Instantiates a new rendering group for a particular scene
  20012. * @param scene Defines the scene the groups belongs to
  20013. */
  20014. constructor(scene: Scene);
  20015. private _clearDepthStencilBuffer;
  20016. /**
  20017. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20018. * @hidden
  20019. */
  20020. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20021. /**
  20022. * Resets the different information of the group to prepare a new frame
  20023. * @hidden
  20024. */
  20025. reset(): void;
  20026. /**
  20027. * Dispose and release the group and its associated resources.
  20028. * @hidden
  20029. */
  20030. dispose(): void;
  20031. /**
  20032. * Clear the info related to rendering groups preventing retention points during dispose.
  20033. */
  20034. freeRenderingGroups(): void;
  20035. private _prepareRenderingGroup;
  20036. /**
  20037. * Add a sprite manager to the rendering manager in order to render it this frame.
  20038. * @param spriteManager Define the sprite manager to render
  20039. */
  20040. dispatchSprites(spriteManager: ISpriteManager): void;
  20041. /**
  20042. * Add a particle system to the rendering manager in order to render it this frame.
  20043. * @param particleSystem Define the particle system to render
  20044. */
  20045. dispatchParticles(particleSystem: IParticleSystem): void;
  20046. /**
  20047. * Add a submesh to the manager in order to render it this frame
  20048. * @param subMesh The submesh to dispatch
  20049. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20050. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20051. */
  20052. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20053. /**
  20054. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20055. * This allowed control for front to back rendering or reversly depending of the special needs.
  20056. *
  20057. * @param renderingGroupId The rendering group id corresponding to its index
  20058. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20059. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20060. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20061. */
  20062. 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;
  20063. /**
  20064. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20065. *
  20066. * @param renderingGroupId The rendering group id corresponding to its index
  20067. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20068. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20069. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20070. */
  20071. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20072. /**
  20073. * Gets the current auto clear configuration for one rendering group of the rendering
  20074. * manager.
  20075. * @param index the rendering group index to get the information for
  20076. * @returns The auto clear setup for the requested rendering group
  20077. */
  20078. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20079. }
  20080. }
  20081. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20082. import { Observable } from "babylonjs/Misc/observable";
  20083. import { SmartArray } from "babylonjs/Misc/smartArray";
  20084. import { Nullable } from "babylonjs/types";
  20085. import { Camera } from "babylonjs/Cameras/camera";
  20086. import { Scene } from "babylonjs/scene";
  20087. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20088. import { Color4 } from "babylonjs/Maths/math.color";
  20089. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20091. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20092. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20093. import { Texture } from "babylonjs/Materials/Textures/texture";
  20094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20095. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20096. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20097. import { Engine } from "babylonjs/Engines/engine";
  20098. /**
  20099. * This Helps creating a texture that will be created from a camera in your scene.
  20100. * It is basically a dynamic texture that could be used to create special effects for instance.
  20101. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20102. */
  20103. export class RenderTargetTexture extends Texture {
  20104. isCube: boolean;
  20105. /**
  20106. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20107. */
  20108. static readonly REFRESHRATE_RENDER_ONCE: number;
  20109. /**
  20110. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20111. */
  20112. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20113. /**
  20114. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20115. * the central point of your effect and can save a lot of performances.
  20116. */
  20117. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20118. /**
  20119. * Use this predicate to dynamically define the list of mesh you want to render.
  20120. * If set, the renderList property will be overwritten.
  20121. */
  20122. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20123. private _renderList;
  20124. /**
  20125. * Use this list to define the list of mesh you want to render.
  20126. */
  20127. renderList: Nullable<Array<AbstractMesh>>;
  20128. private _hookArray;
  20129. /**
  20130. * Define if particles should be rendered in your texture.
  20131. */
  20132. renderParticles: boolean;
  20133. /**
  20134. * Define if sprites should be rendered in your texture.
  20135. */
  20136. renderSprites: boolean;
  20137. /**
  20138. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20139. */
  20140. coordinatesMode: number;
  20141. /**
  20142. * Define the camera used to render the texture.
  20143. */
  20144. activeCamera: Nullable<Camera>;
  20145. /**
  20146. * Override the render function of the texture with your own one.
  20147. */
  20148. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20149. /**
  20150. * Define if camera post processes should be use while rendering the texture.
  20151. */
  20152. useCameraPostProcesses: boolean;
  20153. /**
  20154. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20155. */
  20156. ignoreCameraViewport: boolean;
  20157. private _postProcessManager;
  20158. private _postProcesses;
  20159. private _resizeObserver;
  20160. /**
  20161. * An event triggered when the texture is unbind.
  20162. */
  20163. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20164. /**
  20165. * An event triggered when the texture is unbind.
  20166. */
  20167. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20168. private _onAfterUnbindObserver;
  20169. /**
  20170. * Set a after unbind callback in the texture.
  20171. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20172. */
  20173. onAfterUnbind: () => void;
  20174. /**
  20175. * An event triggered before rendering the texture
  20176. */
  20177. onBeforeRenderObservable: Observable<number>;
  20178. private _onBeforeRenderObserver;
  20179. /**
  20180. * Set a before render callback in the texture.
  20181. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20182. */
  20183. onBeforeRender: (faceIndex: number) => void;
  20184. /**
  20185. * An event triggered after rendering the texture
  20186. */
  20187. onAfterRenderObservable: Observable<number>;
  20188. private _onAfterRenderObserver;
  20189. /**
  20190. * Set a after render callback in the texture.
  20191. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20192. */
  20193. onAfterRender: (faceIndex: number) => void;
  20194. /**
  20195. * An event triggered after the texture clear
  20196. */
  20197. onClearObservable: Observable<Engine>;
  20198. private _onClearObserver;
  20199. /**
  20200. * Set a clear callback in the texture.
  20201. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20202. */
  20203. onClear: (Engine: Engine) => void;
  20204. /**
  20205. * An event triggered when the texture is resized.
  20206. */
  20207. onResizeObservable: Observable<RenderTargetTexture>;
  20208. /**
  20209. * Define the clear color of the Render Target if it should be different from the scene.
  20210. */
  20211. clearColor: Color4;
  20212. protected _size: number | {
  20213. width: number;
  20214. height: number;
  20215. };
  20216. protected _initialSizeParameter: number | {
  20217. width: number;
  20218. height: number;
  20219. } | {
  20220. ratio: number;
  20221. };
  20222. protected _sizeRatio: Nullable<number>;
  20223. /** @hidden */
  20224. _generateMipMaps: boolean;
  20225. protected _renderingManager: RenderingManager;
  20226. /** @hidden */
  20227. _waitingRenderList: string[];
  20228. protected _doNotChangeAspectRatio: boolean;
  20229. protected _currentRefreshId: number;
  20230. protected _refreshRate: number;
  20231. protected _textureMatrix: Matrix;
  20232. protected _samples: number;
  20233. protected _renderTargetOptions: RenderTargetCreationOptions;
  20234. /**
  20235. * Gets render target creation options that were used.
  20236. */
  20237. readonly renderTargetOptions: RenderTargetCreationOptions;
  20238. protected _engine: Engine;
  20239. protected _onRatioRescale(): void;
  20240. /**
  20241. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20242. * It must define where the camera used to render the texture is set
  20243. */
  20244. boundingBoxPosition: Vector3;
  20245. private _boundingBoxSize;
  20246. /**
  20247. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20248. * When defined, the cubemap will switch to local mode
  20249. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20250. * @example https://www.babylonjs-playground.com/#RNASML
  20251. */
  20252. boundingBoxSize: Vector3;
  20253. /**
  20254. * In case the RTT has been created with a depth texture, get the associated
  20255. * depth texture.
  20256. * Otherwise, return null.
  20257. */
  20258. depthStencilTexture: Nullable<InternalTexture>;
  20259. /**
  20260. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20261. * or used a shadow, depth texture...
  20262. * @param name The friendly name of the texture
  20263. * @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)
  20264. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20265. * @param generateMipMaps True if mip maps need to be generated after render.
  20266. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20267. * @param type The type of the buffer in the RTT (int, half float, float...)
  20268. * @param isCube True if a cube texture needs to be created
  20269. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20270. * @param generateDepthBuffer True to generate a depth buffer
  20271. * @param generateStencilBuffer True to generate a stencil buffer
  20272. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20273. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20274. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20275. */
  20276. constructor(name: string, size: number | {
  20277. width: number;
  20278. height: number;
  20279. } | {
  20280. ratio: number;
  20281. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20282. /**
  20283. * Creates a depth stencil texture.
  20284. * This is only available in WebGL 2 or with the depth texture extension available.
  20285. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20286. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20287. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20288. */
  20289. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20290. private _processSizeParameter;
  20291. /**
  20292. * Define the number of samples to use in case of MSAA.
  20293. * It defaults to one meaning no MSAA has been enabled.
  20294. */
  20295. samples: number;
  20296. /**
  20297. * Resets the refresh counter of the texture and start bak from scratch.
  20298. * Could be useful to regenerate the texture if it is setup to render only once.
  20299. */
  20300. resetRefreshCounter(): void;
  20301. /**
  20302. * Define the refresh rate of the texture or the rendering frequency.
  20303. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20304. */
  20305. refreshRate: number;
  20306. /**
  20307. * Adds a post process to the render target rendering passes.
  20308. * @param postProcess define the post process to add
  20309. */
  20310. addPostProcess(postProcess: PostProcess): void;
  20311. /**
  20312. * Clear all the post processes attached to the render target
  20313. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20314. */
  20315. clearPostProcesses(dispose?: boolean): void;
  20316. /**
  20317. * Remove one of the post process from the list of attached post processes to the texture
  20318. * @param postProcess define the post process to remove from the list
  20319. */
  20320. removePostProcess(postProcess: PostProcess): void;
  20321. /** @hidden */
  20322. _shouldRender(): boolean;
  20323. /**
  20324. * Gets the actual render size of the texture.
  20325. * @returns the width of the render size
  20326. */
  20327. getRenderSize(): number;
  20328. /**
  20329. * Gets the actual render width of the texture.
  20330. * @returns the width of the render size
  20331. */
  20332. getRenderWidth(): number;
  20333. /**
  20334. * Gets the actual render height of the texture.
  20335. * @returns the height of the render size
  20336. */
  20337. getRenderHeight(): number;
  20338. /**
  20339. * Get if the texture can be rescaled or not.
  20340. */
  20341. readonly canRescale: boolean;
  20342. /**
  20343. * Resize the texture using a ratio.
  20344. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20345. */
  20346. scale(ratio: number): void;
  20347. /**
  20348. * Get the texture reflection matrix used to rotate/transform the reflection.
  20349. * @returns the reflection matrix
  20350. */
  20351. getReflectionTextureMatrix(): Matrix;
  20352. /**
  20353. * Resize the texture to a new desired size.
  20354. * Be carrefull as it will recreate all the data in the new texture.
  20355. * @param size Define the new size. It can be:
  20356. * - a number for squared texture,
  20357. * - an object containing { width: number, height: number }
  20358. * - or an object containing a ratio { ratio: number }
  20359. */
  20360. resize(size: number | {
  20361. width: number;
  20362. height: number;
  20363. } | {
  20364. ratio: number;
  20365. }): void;
  20366. /**
  20367. * Renders all the objects from the render list into the texture.
  20368. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20369. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20370. */
  20371. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20372. private _bestReflectionRenderTargetDimension;
  20373. /**
  20374. * @hidden
  20375. * @param faceIndex face index to bind to if this is a cubetexture
  20376. */
  20377. _bindFrameBuffer(faceIndex?: number): void;
  20378. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20379. private renderToTarget;
  20380. /**
  20381. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20382. * This allowed control for front to back rendering or reversly depending of the special needs.
  20383. *
  20384. * @param renderingGroupId The rendering group id corresponding to its index
  20385. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20386. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20387. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20388. */
  20389. 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;
  20390. /**
  20391. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20392. *
  20393. * @param renderingGroupId The rendering group id corresponding to its index
  20394. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20395. */
  20396. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20397. /**
  20398. * Clones the texture.
  20399. * @returns the cloned texture
  20400. */
  20401. clone(): RenderTargetTexture;
  20402. /**
  20403. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20404. * @returns The JSON representation of the texture
  20405. */
  20406. serialize(): any;
  20407. /**
  20408. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20409. */
  20410. disposeFramebufferObjects(): void;
  20411. /**
  20412. * Dispose the texture and release its associated resources.
  20413. */
  20414. dispose(): void;
  20415. /** @hidden */
  20416. _rebuild(): void;
  20417. /**
  20418. * Clear the info related to rendering groups preventing retention point in material dispose.
  20419. */
  20420. freeRenderingGroups(): void;
  20421. /**
  20422. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20423. * @returns the view count
  20424. */
  20425. getViewCount(): number;
  20426. }
  20427. }
  20428. declare module "babylonjs/Materials/material" {
  20429. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20430. import { SmartArray } from "babylonjs/Misc/smartArray";
  20431. import { Observable } from "babylonjs/Misc/observable";
  20432. import { Nullable } from "babylonjs/types";
  20433. import { Scene } from "babylonjs/scene";
  20434. import { Matrix } from "babylonjs/Maths/math.vector";
  20435. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20437. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20438. import { Effect } from "babylonjs/Materials/effect";
  20439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20440. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20441. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20442. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20443. import { Mesh } from "babylonjs/Meshes/mesh";
  20444. import { Animation } from "babylonjs/Animations/animation";
  20445. /**
  20446. * Base class for the main features of a material in Babylon.js
  20447. */
  20448. export class Material implements IAnimatable {
  20449. /**
  20450. * Returns the triangle fill mode
  20451. */
  20452. static readonly TriangleFillMode: number;
  20453. /**
  20454. * Returns the wireframe mode
  20455. */
  20456. static readonly WireFrameFillMode: number;
  20457. /**
  20458. * Returns the point fill mode
  20459. */
  20460. static readonly PointFillMode: number;
  20461. /**
  20462. * Returns the point list draw mode
  20463. */
  20464. static readonly PointListDrawMode: number;
  20465. /**
  20466. * Returns the line list draw mode
  20467. */
  20468. static readonly LineListDrawMode: number;
  20469. /**
  20470. * Returns the line loop draw mode
  20471. */
  20472. static readonly LineLoopDrawMode: number;
  20473. /**
  20474. * Returns the line strip draw mode
  20475. */
  20476. static readonly LineStripDrawMode: number;
  20477. /**
  20478. * Returns the triangle strip draw mode
  20479. */
  20480. static readonly TriangleStripDrawMode: number;
  20481. /**
  20482. * Returns the triangle fan draw mode
  20483. */
  20484. static readonly TriangleFanDrawMode: number;
  20485. /**
  20486. * Stores the clock-wise side orientation
  20487. */
  20488. static readonly ClockWiseSideOrientation: number;
  20489. /**
  20490. * Stores the counter clock-wise side orientation
  20491. */
  20492. static readonly CounterClockWiseSideOrientation: number;
  20493. /**
  20494. * The dirty texture flag value
  20495. */
  20496. static readonly TextureDirtyFlag: number;
  20497. /**
  20498. * The dirty light flag value
  20499. */
  20500. static readonly LightDirtyFlag: number;
  20501. /**
  20502. * The dirty fresnel flag value
  20503. */
  20504. static readonly FresnelDirtyFlag: number;
  20505. /**
  20506. * The dirty attribute flag value
  20507. */
  20508. static readonly AttributesDirtyFlag: number;
  20509. /**
  20510. * The dirty misc flag value
  20511. */
  20512. static readonly MiscDirtyFlag: number;
  20513. /**
  20514. * The all dirty flag value
  20515. */
  20516. static readonly AllDirtyFlag: number;
  20517. /**
  20518. * The ID of the material
  20519. */
  20520. id: string;
  20521. /**
  20522. * Gets or sets the unique id of the material
  20523. */
  20524. uniqueId: number;
  20525. /**
  20526. * The name of the material
  20527. */
  20528. name: string;
  20529. /**
  20530. * Gets or sets user defined metadata
  20531. */
  20532. metadata: any;
  20533. /**
  20534. * For internal use only. Please do not use.
  20535. */
  20536. reservedDataStore: any;
  20537. /**
  20538. * Specifies if the ready state should be checked on each call
  20539. */
  20540. checkReadyOnEveryCall: boolean;
  20541. /**
  20542. * Specifies if the ready state should be checked once
  20543. */
  20544. checkReadyOnlyOnce: boolean;
  20545. /**
  20546. * The state of the material
  20547. */
  20548. state: string;
  20549. /**
  20550. * The alpha value of the material
  20551. */
  20552. protected _alpha: number;
  20553. /**
  20554. * List of inspectable custom properties (used by the Inspector)
  20555. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20556. */
  20557. inspectableCustomProperties: IInspectable[];
  20558. /**
  20559. * Sets the alpha value of the material
  20560. */
  20561. /**
  20562. * Gets the alpha value of the material
  20563. */
  20564. alpha: number;
  20565. /**
  20566. * Specifies if back face culling is enabled
  20567. */
  20568. protected _backFaceCulling: boolean;
  20569. /**
  20570. * Sets the back-face culling state
  20571. */
  20572. /**
  20573. * Gets the back-face culling state
  20574. */
  20575. backFaceCulling: boolean;
  20576. /**
  20577. * Stores the value for side orientation
  20578. */
  20579. sideOrientation: number;
  20580. /**
  20581. * Callback triggered when the material is compiled
  20582. */
  20583. onCompiled: Nullable<(effect: Effect) => void>;
  20584. /**
  20585. * Callback triggered when an error occurs
  20586. */
  20587. onError: Nullable<(effect: Effect, errors: string) => void>;
  20588. /**
  20589. * Callback triggered to get the render target textures
  20590. */
  20591. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20592. /**
  20593. * Gets a boolean indicating that current material needs to register RTT
  20594. */
  20595. readonly hasRenderTargetTextures: boolean;
  20596. /**
  20597. * Specifies if the material should be serialized
  20598. */
  20599. doNotSerialize: boolean;
  20600. /**
  20601. * @hidden
  20602. */
  20603. _storeEffectOnSubMeshes: boolean;
  20604. /**
  20605. * Stores the animations for the material
  20606. */
  20607. animations: Nullable<Array<Animation>>;
  20608. /**
  20609. * An event triggered when the material is disposed
  20610. */
  20611. onDisposeObservable: Observable<Material>;
  20612. /**
  20613. * An observer which watches for dispose events
  20614. */
  20615. private _onDisposeObserver;
  20616. private _onUnBindObservable;
  20617. /**
  20618. * Called during a dispose event
  20619. */
  20620. onDispose: () => void;
  20621. private _onBindObservable;
  20622. /**
  20623. * An event triggered when the material is bound
  20624. */
  20625. readonly onBindObservable: Observable<AbstractMesh>;
  20626. /**
  20627. * An observer which watches for bind events
  20628. */
  20629. private _onBindObserver;
  20630. /**
  20631. * Called during a bind event
  20632. */
  20633. onBind: (Mesh: AbstractMesh) => void;
  20634. /**
  20635. * An event triggered when the material is unbound
  20636. */
  20637. readonly onUnBindObservable: Observable<Material>;
  20638. /**
  20639. * Stores the value of the alpha mode
  20640. */
  20641. private _alphaMode;
  20642. /**
  20643. * Sets the value of the alpha mode.
  20644. *
  20645. * | Value | Type | Description |
  20646. * | --- | --- | --- |
  20647. * | 0 | ALPHA_DISABLE | |
  20648. * | 1 | ALPHA_ADD | |
  20649. * | 2 | ALPHA_COMBINE | |
  20650. * | 3 | ALPHA_SUBTRACT | |
  20651. * | 4 | ALPHA_MULTIPLY | |
  20652. * | 5 | ALPHA_MAXIMIZED | |
  20653. * | 6 | ALPHA_ONEONE | |
  20654. * | 7 | ALPHA_PREMULTIPLIED | |
  20655. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20656. * | 9 | ALPHA_INTERPOLATE | |
  20657. * | 10 | ALPHA_SCREENMODE | |
  20658. *
  20659. */
  20660. /**
  20661. * Gets the value of the alpha mode
  20662. */
  20663. alphaMode: number;
  20664. /**
  20665. * Stores the state of the need depth pre-pass value
  20666. */
  20667. private _needDepthPrePass;
  20668. /**
  20669. * Sets the need depth pre-pass value
  20670. */
  20671. /**
  20672. * Gets the depth pre-pass value
  20673. */
  20674. needDepthPrePass: boolean;
  20675. /**
  20676. * Specifies if depth writing should be disabled
  20677. */
  20678. disableDepthWrite: boolean;
  20679. /**
  20680. * Specifies if depth writing should be forced
  20681. */
  20682. forceDepthWrite: boolean;
  20683. /**
  20684. * Specifies if there should be a separate pass for culling
  20685. */
  20686. separateCullingPass: boolean;
  20687. /**
  20688. * Stores the state specifing if fog should be enabled
  20689. */
  20690. private _fogEnabled;
  20691. /**
  20692. * Sets the state for enabling fog
  20693. */
  20694. /**
  20695. * Gets the value of the fog enabled state
  20696. */
  20697. fogEnabled: boolean;
  20698. /**
  20699. * Stores the size of points
  20700. */
  20701. pointSize: number;
  20702. /**
  20703. * Stores the z offset value
  20704. */
  20705. zOffset: number;
  20706. /**
  20707. * Gets a value specifying if wireframe mode is enabled
  20708. */
  20709. /**
  20710. * Sets the state of wireframe mode
  20711. */
  20712. wireframe: boolean;
  20713. /**
  20714. * Gets the value specifying if point clouds are enabled
  20715. */
  20716. /**
  20717. * Sets the state of point cloud mode
  20718. */
  20719. pointsCloud: boolean;
  20720. /**
  20721. * Gets the material fill mode
  20722. */
  20723. /**
  20724. * Sets the material fill mode
  20725. */
  20726. fillMode: number;
  20727. /**
  20728. * @hidden
  20729. * Stores the effects for the material
  20730. */
  20731. _effect: Nullable<Effect>;
  20732. /**
  20733. * @hidden
  20734. * Specifies if the material was previously ready
  20735. */
  20736. _wasPreviouslyReady: boolean;
  20737. /**
  20738. * Specifies if uniform buffers should be used
  20739. */
  20740. private _useUBO;
  20741. /**
  20742. * Stores a reference to the scene
  20743. */
  20744. private _scene;
  20745. /**
  20746. * Stores the fill mode state
  20747. */
  20748. private _fillMode;
  20749. /**
  20750. * Specifies if the depth write state should be cached
  20751. */
  20752. private _cachedDepthWriteState;
  20753. /**
  20754. * Stores the uniform buffer
  20755. */
  20756. protected _uniformBuffer: UniformBuffer;
  20757. /** @hidden */
  20758. _indexInSceneMaterialArray: number;
  20759. /** @hidden */
  20760. meshMap: Nullable<{
  20761. [id: string]: AbstractMesh | undefined;
  20762. }>;
  20763. /**
  20764. * Creates a material instance
  20765. * @param name defines the name of the material
  20766. * @param scene defines the scene to reference
  20767. * @param doNotAdd specifies if the material should be added to the scene
  20768. */
  20769. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20770. /**
  20771. * Returns a string representation of the current material
  20772. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20773. * @returns a string with material information
  20774. */
  20775. toString(fullDetails?: boolean): string;
  20776. /**
  20777. * Gets the class name of the material
  20778. * @returns a string with the class name of the material
  20779. */
  20780. getClassName(): string;
  20781. /**
  20782. * Specifies if updates for the material been locked
  20783. */
  20784. readonly isFrozen: boolean;
  20785. /**
  20786. * Locks updates for the material
  20787. */
  20788. freeze(): void;
  20789. /**
  20790. * Unlocks updates for the material
  20791. */
  20792. unfreeze(): void;
  20793. /**
  20794. * Specifies if the material is ready to be used
  20795. * @param mesh defines the mesh to check
  20796. * @param useInstances specifies if instances should be used
  20797. * @returns a boolean indicating if the material is ready to be used
  20798. */
  20799. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20800. /**
  20801. * Specifies that the submesh is ready to be used
  20802. * @param mesh defines the mesh to check
  20803. * @param subMesh defines which submesh to check
  20804. * @param useInstances specifies that instances should be used
  20805. * @returns a boolean indicating that the submesh is ready or not
  20806. */
  20807. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20808. /**
  20809. * Returns the material effect
  20810. * @returns the effect associated with the material
  20811. */
  20812. getEffect(): Nullable<Effect>;
  20813. /**
  20814. * Returns the current scene
  20815. * @returns a Scene
  20816. */
  20817. getScene(): Scene;
  20818. /**
  20819. * Specifies if the material will require alpha blending
  20820. * @returns a boolean specifying if alpha blending is needed
  20821. */
  20822. needAlphaBlending(): boolean;
  20823. /**
  20824. * Specifies if the mesh will require alpha blending
  20825. * @param mesh defines the mesh to check
  20826. * @returns a boolean specifying if alpha blending is needed for the mesh
  20827. */
  20828. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20829. /**
  20830. * Specifies if this material should be rendered in alpha test mode
  20831. * @returns a boolean specifying if an alpha test is needed.
  20832. */
  20833. needAlphaTesting(): boolean;
  20834. /**
  20835. * Gets the texture used for the alpha test
  20836. * @returns the texture to use for alpha testing
  20837. */
  20838. getAlphaTestTexture(): Nullable<BaseTexture>;
  20839. /**
  20840. * Marks the material to indicate that it needs to be re-calculated
  20841. */
  20842. markDirty(): void;
  20843. /** @hidden */
  20844. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20845. /**
  20846. * Binds the material to the mesh
  20847. * @param world defines the world transformation matrix
  20848. * @param mesh defines the mesh to bind the material to
  20849. */
  20850. bind(world: Matrix, mesh?: Mesh): void;
  20851. /**
  20852. * Binds the submesh to the material
  20853. * @param world defines the world transformation matrix
  20854. * @param mesh defines the mesh containing the submesh
  20855. * @param subMesh defines the submesh to bind the material to
  20856. */
  20857. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20858. /**
  20859. * Binds the world matrix to the material
  20860. * @param world defines the world transformation matrix
  20861. */
  20862. bindOnlyWorldMatrix(world: Matrix): void;
  20863. /**
  20864. * Binds the scene's uniform buffer to the effect.
  20865. * @param effect defines the effect to bind to the scene uniform buffer
  20866. * @param sceneUbo defines the uniform buffer storing scene data
  20867. */
  20868. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20869. /**
  20870. * Binds the view matrix to the effect
  20871. * @param effect defines the effect to bind the view matrix to
  20872. */
  20873. bindView(effect: Effect): void;
  20874. /**
  20875. * Binds the view projection matrix to the effect
  20876. * @param effect defines the effect to bind the view projection matrix to
  20877. */
  20878. bindViewProjection(effect: Effect): void;
  20879. /**
  20880. * Specifies if material alpha testing should be turned on for the mesh
  20881. * @param mesh defines the mesh to check
  20882. */
  20883. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20884. /**
  20885. * Processes to execute after binding the material to a mesh
  20886. * @param mesh defines the rendered mesh
  20887. */
  20888. protected _afterBind(mesh?: Mesh): void;
  20889. /**
  20890. * Unbinds the material from the mesh
  20891. */
  20892. unbind(): void;
  20893. /**
  20894. * Gets the active textures from the material
  20895. * @returns an array of textures
  20896. */
  20897. getActiveTextures(): BaseTexture[];
  20898. /**
  20899. * Specifies if the material uses a texture
  20900. * @param texture defines the texture to check against the material
  20901. * @returns a boolean specifying if the material uses the texture
  20902. */
  20903. hasTexture(texture: BaseTexture): boolean;
  20904. /**
  20905. * Makes a duplicate of the material, and gives it a new name
  20906. * @param name defines the new name for the duplicated material
  20907. * @returns the cloned material
  20908. */
  20909. clone(name: string): Nullable<Material>;
  20910. /**
  20911. * Gets the meshes bound to the material
  20912. * @returns an array of meshes bound to the material
  20913. */
  20914. getBindedMeshes(): AbstractMesh[];
  20915. /**
  20916. * Force shader compilation
  20917. * @param mesh defines the mesh associated with this material
  20918. * @param onCompiled defines a function to execute once the material is compiled
  20919. * @param options defines the options to configure the compilation
  20920. */
  20921. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20922. clipPlane: boolean;
  20923. }>): void;
  20924. /**
  20925. * Force shader compilation
  20926. * @param mesh defines the mesh that will use this material
  20927. * @param options defines additional options for compiling the shaders
  20928. * @returns a promise that resolves when the compilation completes
  20929. */
  20930. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20931. clipPlane: boolean;
  20932. }>): Promise<void>;
  20933. private static readonly _AllDirtyCallBack;
  20934. private static readonly _ImageProcessingDirtyCallBack;
  20935. private static readonly _TextureDirtyCallBack;
  20936. private static readonly _FresnelDirtyCallBack;
  20937. private static readonly _MiscDirtyCallBack;
  20938. private static readonly _LightsDirtyCallBack;
  20939. private static readonly _AttributeDirtyCallBack;
  20940. private static _FresnelAndMiscDirtyCallBack;
  20941. private static _TextureAndMiscDirtyCallBack;
  20942. private static readonly _DirtyCallbackArray;
  20943. private static readonly _RunDirtyCallBacks;
  20944. /**
  20945. * Marks a define in the material to indicate that it needs to be re-computed
  20946. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20947. */
  20948. markAsDirty(flag: number): void;
  20949. /**
  20950. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20951. * @param func defines a function which checks material defines against the submeshes
  20952. */
  20953. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20954. /**
  20955. * Indicates that we need to re-calculated for all submeshes
  20956. */
  20957. protected _markAllSubMeshesAsAllDirty(): void;
  20958. /**
  20959. * Indicates that image processing needs to be re-calculated for all submeshes
  20960. */
  20961. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20962. /**
  20963. * Indicates that textures need to be re-calculated for all submeshes
  20964. */
  20965. protected _markAllSubMeshesAsTexturesDirty(): void;
  20966. /**
  20967. * Indicates that fresnel needs to be re-calculated for all submeshes
  20968. */
  20969. protected _markAllSubMeshesAsFresnelDirty(): void;
  20970. /**
  20971. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20972. */
  20973. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20974. /**
  20975. * Indicates that lights need to be re-calculated for all submeshes
  20976. */
  20977. protected _markAllSubMeshesAsLightsDirty(): void;
  20978. /**
  20979. * Indicates that attributes need to be re-calculated for all submeshes
  20980. */
  20981. protected _markAllSubMeshesAsAttributesDirty(): void;
  20982. /**
  20983. * Indicates that misc needs to be re-calculated for all submeshes
  20984. */
  20985. protected _markAllSubMeshesAsMiscDirty(): void;
  20986. /**
  20987. * Indicates that textures and misc need to be re-calculated for all submeshes
  20988. */
  20989. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20990. /**
  20991. * Disposes the material
  20992. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20993. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20994. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20995. */
  20996. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20997. /** @hidden */
  20998. private releaseVertexArrayObject;
  20999. /**
  21000. * Serializes this material
  21001. * @returns the serialized material object
  21002. */
  21003. serialize(): any;
  21004. /**
  21005. * Creates a material from parsed material data
  21006. * @param parsedMaterial defines parsed material data
  21007. * @param scene defines the hosting scene
  21008. * @param rootUrl defines the root URL to use to load textures
  21009. * @returns a new material
  21010. */
  21011. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21012. }
  21013. }
  21014. declare module "babylonjs/Materials/multiMaterial" {
  21015. import { Nullable } from "babylonjs/types";
  21016. import { Scene } from "babylonjs/scene";
  21017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21018. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21020. import { Material } from "babylonjs/Materials/material";
  21021. /**
  21022. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21023. * separate meshes. This can be use to improve performances.
  21024. * @see http://doc.babylonjs.com/how_to/multi_materials
  21025. */
  21026. export class MultiMaterial extends Material {
  21027. private _subMaterials;
  21028. /**
  21029. * Gets or Sets the list of Materials used within the multi material.
  21030. * They need to be ordered according to the submeshes order in the associated mesh
  21031. */
  21032. subMaterials: Nullable<Material>[];
  21033. /**
  21034. * Function used to align with Node.getChildren()
  21035. * @returns the list of Materials used within the multi material
  21036. */
  21037. getChildren(): Nullable<Material>[];
  21038. /**
  21039. * Instantiates a new Multi Material
  21040. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21041. * separate meshes. This can be use to improve performances.
  21042. * @see http://doc.babylonjs.com/how_to/multi_materials
  21043. * @param name Define the name in the scene
  21044. * @param scene Define the scene the material belongs to
  21045. */
  21046. constructor(name: string, scene: Scene);
  21047. private _hookArray;
  21048. /**
  21049. * Get one of the submaterial by its index in the submaterials array
  21050. * @param index The index to look the sub material at
  21051. * @returns The Material if the index has been defined
  21052. */
  21053. getSubMaterial(index: number): Nullable<Material>;
  21054. /**
  21055. * Get the list of active textures for the whole sub materials list.
  21056. * @returns All the textures that will be used during the rendering
  21057. */
  21058. getActiveTextures(): BaseTexture[];
  21059. /**
  21060. * Gets the current class name of the material e.g. "MultiMaterial"
  21061. * Mainly use in serialization.
  21062. * @returns the class name
  21063. */
  21064. getClassName(): string;
  21065. /**
  21066. * Checks if the material is ready to render the requested sub mesh
  21067. * @param mesh Define the mesh the submesh belongs to
  21068. * @param subMesh Define the sub mesh to look readyness for
  21069. * @param useInstances Define whether or not the material is used with instances
  21070. * @returns true if ready, otherwise false
  21071. */
  21072. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21073. /**
  21074. * Clones the current material and its related sub materials
  21075. * @param name Define the name of the newly cloned material
  21076. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21077. * @returns the cloned material
  21078. */
  21079. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21080. /**
  21081. * Serializes the materials into a JSON representation.
  21082. * @returns the JSON representation
  21083. */
  21084. serialize(): any;
  21085. /**
  21086. * Dispose the material and release its associated resources
  21087. * @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)
  21088. * @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)
  21089. * @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)
  21090. */
  21091. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21092. /**
  21093. * Creates a MultiMaterial from parsed MultiMaterial data.
  21094. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21095. * @param scene defines the hosting scene
  21096. * @returns a new MultiMaterial
  21097. */
  21098. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21099. }
  21100. }
  21101. declare module "babylonjs/Meshes/subMesh" {
  21102. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21103. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21104. import { Engine } from "babylonjs/Engines/engine";
  21105. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21106. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21107. import { Effect } from "babylonjs/Materials/effect";
  21108. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21109. import { Plane } from "babylonjs/Maths/math.plane";
  21110. import { Collider } from "babylonjs/Collisions/collider";
  21111. import { Material } from "babylonjs/Materials/material";
  21112. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21114. import { Mesh } from "babylonjs/Meshes/mesh";
  21115. import { Ray } from "babylonjs/Culling/ray";
  21116. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21117. /**
  21118. * Base class for submeshes
  21119. */
  21120. export class BaseSubMesh {
  21121. /** @hidden */
  21122. _materialDefines: Nullable<MaterialDefines>;
  21123. /** @hidden */
  21124. _materialEffect: Nullable<Effect>;
  21125. /**
  21126. * Gets associated effect
  21127. */
  21128. readonly effect: Nullable<Effect>;
  21129. /**
  21130. * Sets associated effect (effect used to render this submesh)
  21131. * @param effect defines the effect to associate with
  21132. * @param defines defines the set of defines used to compile this effect
  21133. */
  21134. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21135. }
  21136. /**
  21137. * Defines a subdivision inside a mesh
  21138. */
  21139. export class SubMesh extends BaseSubMesh implements ICullable {
  21140. /** the material index to use */
  21141. materialIndex: number;
  21142. /** vertex index start */
  21143. verticesStart: number;
  21144. /** vertices count */
  21145. verticesCount: number;
  21146. /** index start */
  21147. indexStart: number;
  21148. /** indices count */
  21149. indexCount: number;
  21150. /** @hidden */
  21151. _linesIndexCount: number;
  21152. private _mesh;
  21153. private _renderingMesh;
  21154. private _boundingInfo;
  21155. private _linesIndexBuffer;
  21156. /** @hidden */
  21157. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21158. /** @hidden */
  21159. _trianglePlanes: Plane[];
  21160. /** @hidden */
  21161. _lastColliderTransformMatrix: Nullable<Matrix>;
  21162. /** @hidden */
  21163. _renderId: number;
  21164. /** @hidden */
  21165. _alphaIndex: number;
  21166. /** @hidden */
  21167. _distanceToCamera: number;
  21168. /** @hidden */
  21169. _id: number;
  21170. private _currentMaterial;
  21171. /**
  21172. * Add a new submesh to a mesh
  21173. * @param materialIndex defines the material index to use
  21174. * @param verticesStart defines vertex index start
  21175. * @param verticesCount defines vertices count
  21176. * @param indexStart defines index start
  21177. * @param indexCount defines indices count
  21178. * @param mesh defines the parent mesh
  21179. * @param renderingMesh defines an optional rendering mesh
  21180. * @param createBoundingBox defines if bounding box should be created for this submesh
  21181. * @returns the new submesh
  21182. */
  21183. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21184. /**
  21185. * Creates a new submesh
  21186. * @param materialIndex defines the material index to use
  21187. * @param verticesStart defines vertex index start
  21188. * @param verticesCount defines vertices count
  21189. * @param indexStart defines index start
  21190. * @param indexCount defines indices count
  21191. * @param mesh defines the parent mesh
  21192. * @param renderingMesh defines an optional rendering mesh
  21193. * @param createBoundingBox defines if bounding box should be created for this submesh
  21194. */
  21195. constructor(
  21196. /** the material index to use */
  21197. materialIndex: number,
  21198. /** vertex index start */
  21199. verticesStart: number,
  21200. /** vertices count */
  21201. verticesCount: number,
  21202. /** index start */
  21203. indexStart: number,
  21204. /** indices count */
  21205. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21206. /**
  21207. * Returns true if this submesh covers the entire parent mesh
  21208. * @ignorenaming
  21209. */
  21210. readonly IsGlobal: boolean;
  21211. /**
  21212. * Returns the submesh BoudingInfo object
  21213. * @returns current bounding info (or mesh's one if the submesh is global)
  21214. */
  21215. getBoundingInfo(): BoundingInfo;
  21216. /**
  21217. * Sets the submesh BoundingInfo
  21218. * @param boundingInfo defines the new bounding info to use
  21219. * @returns the SubMesh
  21220. */
  21221. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21222. /**
  21223. * Returns the mesh of the current submesh
  21224. * @return the parent mesh
  21225. */
  21226. getMesh(): AbstractMesh;
  21227. /**
  21228. * Returns the rendering mesh of the submesh
  21229. * @returns the rendering mesh (could be different from parent mesh)
  21230. */
  21231. getRenderingMesh(): Mesh;
  21232. /**
  21233. * Returns the submesh material
  21234. * @returns null or the current material
  21235. */
  21236. getMaterial(): Nullable<Material>;
  21237. /**
  21238. * Sets a new updated BoundingInfo object to the submesh
  21239. * @param data defines an optional position array to use to determine the bounding info
  21240. * @returns the SubMesh
  21241. */
  21242. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21243. /** @hidden */
  21244. _checkCollision(collider: Collider): boolean;
  21245. /**
  21246. * Updates the submesh BoundingInfo
  21247. * @param world defines the world matrix to use to update the bounding info
  21248. * @returns the submesh
  21249. */
  21250. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21251. /**
  21252. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21253. * @param frustumPlanes defines the frustum planes
  21254. * @returns true if the submesh is intersecting with the frustum
  21255. */
  21256. isInFrustum(frustumPlanes: Plane[]): boolean;
  21257. /**
  21258. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21259. * @param frustumPlanes defines the frustum planes
  21260. * @returns true if the submesh is inside the frustum
  21261. */
  21262. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21263. /**
  21264. * Renders the submesh
  21265. * @param enableAlphaMode defines if alpha needs to be used
  21266. * @returns the submesh
  21267. */
  21268. render(enableAlphaMode: boolean): SubMesh;
  21269. /**
  21270. * @hidden
  21271. */
  21272. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21273. /**
  21274. * Checks if the submesh intersects with a ray
  21275. * @param ray defines the ray to test
  21276. * @returns true is the passed ray intersects the submesh bounding box
  21277. */
  21278. canIntersects(ray: Ray): boolean;
  21279. /**
  21280. * Intersects current submesh with a ray
  21281. * @param ray defines the ray to test
  21282. * @param positions defines mesh's positions array
  21283. * @param indices defines mesh's indices array
  21284. * @param fastCheck defines if only bounding info should be used
  21285. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21286. * @returns intersection info or null if no intersection
  21287. */
  21288. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21289. /** @hidden */
  21290. private _intersectLines;
  21291. /** @hidden */
  21292. private _intersectUnIndexedLines;
  21293. /** @hidden */
  21294. private _intersectTriangles;
  21295. /** @hidden */
  21296. private _intersectUnIndexedTriangles;
  21297. /** @hidden */
  21298. _rebuild(): void;
  21299. /**
  21300. * Creates a new submesh from the passed mesh
  21301. * @param newMesh defines the new hosting mesh
  21302. * @param newRenderingMesh defines an optional rendering mesh
  21303. * @returns the new submesh
  21304. */
  21305. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21306. /**
  21307. * Release associated resources
  21308. */
  21309. dispose(): void;
  21310. /**
  21311. * Gets the class name
  21312. * @returns the string "SubMesh".
  21313. */
  21314. getClassName(): string;
  21315. /**
  21316. * Creates a new submesh from indices data
  21317. * @param materialIndex the index of the main mesh material
  21318. * @param startIndex the index where to start the copy in the mesh indices array
  21319. * @param indexCount the number of indices to copy then from the startIndex
  21320. * @param mesh the main mesh to create the submesh from
  21321. * @param renderingMesh the optional rendering mesh
  21322. * @returns a new submesh
  21323. */
  21324. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21325. }
  21326. }
  21327. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21328. /**
  21329. * Class used to represent data loading progression
  21330. */
  21331. export class SceneLoaderFlags {
  21332. private static _ForceFullSceneLoadingForIncremental;
  21333. private static _ShowLoadingScreen;
  21334. private static _CleanBoneMatrixWeights;
  21335. private static _loggingLevel;
  21336. /**
  21337. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21338. */
  21339. static ForceFullSceneLoadingForIncremental: boolean;
  21340. /**
  21341. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21342. */
  21343. static ShowLoadingScreen: boolean;
  21344. /**
  21345. * Defines the current logging level (while loading the scene)
  21346. * @ignorenaming
  21347. */
  21348. static loggingLevel: number;
  21349. /**
  21350. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21351. */
  21352. static CleanBoneMatrixWeights: boolean;
  21353. }
  21354. }
  21355. declare module "babylonjs/Meshes/geometry" {
  21356. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21357. import { Scene } from "babylonjs/scene";
  21358. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21359. import { Engine } from "babylonjs/Engines/engine";
  21360. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21361. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21362. import { Effect } from "babylonjs/Materials/effect";
  21363. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21364. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21365. import { Mesh } from "babylonjs/Meshes/mesh";
  21366. /**
  21367. * Class used to store geometry data (vertex buffers + index buffer)
  21368. */
  21369. export class Geometry implements IGetSetVerticesData {
  21370. /**
  21371. * Gets or sets the ID of the geometry
  21372. */
  21373. id: string;
  21374. /**
  21375. * Gets or sets the unique ID of the geometry
  21376. */
  21377. uniqueId: number;
  21378. /**
  21379. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21380. */
  21381. delayLoadState: number;
  21382. /**
  21383. * Gets the file containing the data to load when running in delay load state
  21384. */
  21385. delayLoadingFile: Nullable<string>;
  21386. /**
  21387. * Callback called when the geometry is updated
  21388. */
  21389. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21390. private _scene;
  21391. private _engine;
  21392. private _meshes;
  21393. private _totalVertices;
  21394. /** @hidden */
  21395. _indices: IndicesArray;
  21396. /** @hidden */
  21397. _vertexBuffers: {
  21398. [key: string]: VertexBuffer;
  21399. };
  21400. private _isDisposed;
  21401. private _extend;
  21402. private _boundingBias;
  21403. /** @hidden */
  21404. _delayInfo: Array<string>;
  21405. private _indexBuffer;
  21406. private _indexBufferIsUpdatable;
  21407. /** @hidden */
  21408. _boundingInfo: Nullable<BoundingInfo>;
  21409. /** @hidden */
  21410. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21411. /** @hidden */
  21412. _softwareSkinningFrameId: number;
  21413. private _vertexArrayObjects;
  21414. private _updatable;
  21415. /** @hidden */
  21416. _positions: Nullable<Vector3[]>;
  21417. /**
  21418. * 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
  21419. */
  21420. /**
  21421. * 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
  21422. */
  21423. boundingBias: Vector2;
  21424. /**
  21425. * Static function used to attach a new empty geometry to a mesh
  21426. * @param mesh defines the mesh to attach the geometry to
  21427. * @returns the new Geometry
  21428. */
  21429. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21430. /**
  21431. * Creates a new geometry
  21432. * @param id defines the unique ID
  21433. * @param scene defines the hosting scene
  21434. * @param vertexData defines the VertexData used to get geometry data
  21435. * @param updatable defines if geometry must be updatable (false by default)
  21436. * @param mesh defines the mesh that will be associated with the geometry
  21437. */
  21438. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21439. /**
  21440. * Gets the current extend of the geometry
  21441. */
  21442. readonly extend: {
  21443. minimum: Vector3;
  21444. maximum: Vector3;
  21445. };
  21446. /**
  21447. * Gets the hosting scene
  21448. * @returns the hosting Scene
  21449. */
  21450. getScene(): Scene;
  21451. /**
  21452. * Gets the hosting engine
  21453. * @returns the hosting Engine
  21454. */
  21455. getEngine(): Engine;
  21456. /**
  21457. * Defines if the geometry is ready to use
  21458. * @returns true if the geometry is ready to be used
  21459. */
  21460. isReady(): boolean;
  21461. /**
  21462. * Gets a value indicating that the geometry should not be serialized
  21463. */
  21464. readonly doNotSerialize: boolean;
  21465. /** @hidden */
  21466. _rebuild(): void;
  21467. /**
  21468. * Affects all geometry data in one call
  21469. * @param vertexData defines the geometry data
  21470. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21471. */
  21472. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21473. /**
  21474. * Set specific vertex data
  21475. * @param kind defines the data kind (Position, normal, etc...)
  21476. * @param data defines the vertex data to use
  21477. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21478. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21479. */
  21480. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21481. /**
  21482. * Removes a specific vertex data
  21483. * @param kind defines the data kind (Position, normal, etc...)
  21484. */
  21485. removeVerticesData(kind: string): void;
  21486. /**
  21487. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21488. * @param buffer defines the vertex buffer to use
  21489. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21490. */
  21491. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21492. /**
  21493. * Update a specific vertex buffer
  21494. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21495. * It will do nothing if the buffer is not updatable
  21496. * @param kind defines the data kind (Position, normal, etc...)
  21497. * @param data defines the data to use
  21498. * @param offset defines the offset in the target buffer where to store the data
  21499. * @param useBytes set to true if the offset is in bytes
  21500. */
  21501. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21502. /**
  21503. * Update a specific vertex buffer
  21504. * This function will create a new buffer if the current one is not updatable
  21505. * @param kind defines the data kind (Position, normal, etc...)
  21506. * @param data defines the data to use
  21507. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21508. */
  21509. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21510. private _updateBoundingInfo;
  21511. /** @hidden */
  21512. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21513. /**
  21514. * Gets total number of vertices
  21515. * @returns the total number of vertices
  21516. */
  21517. getTotalVertices(): number;
  21518. /**
  21519. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21520. * @param kind defines the data kind (Position, normal, etc...)
  21521. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21522. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21523. * @returns a float array containing vertex data
  21524. */
  21525. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21526. /**
  21527. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21528. * @param kind defines the data kind (Position, normal, etc...)
  21529. * @returns true if the vertex buffer with the specified kind is updatable
  21530. */
  21531. isVertexBufferUpdatable(kind: string): boolean;
  21532. /**
  21533. * Gets a specific vertex buffer
  21534. * @param kind defines the data kind (Position, normal, etc...)
  21535. * @returns a VertexBuffer
  21536. */
  21537. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21538. /**
  21539. * Returns all vertex buffers
  21540. * @return an object holding all vertex buffers indexed by kind
  21541. */
  21542. getVertexBuffers(): Nullable<{
  21543. [key: string]: VertexBuffer;
  21544. }>;
  21545. /**
  21546. * Gets a boolean indicating if specific vertex buffer is present
  21547. * @param kind defines the data kind (Position, normal, etc...)
  21548. * @returns true if data is present
  21549. */
  21550. isVerticesDataPresent(kind: string): boolean;
  21551. /**
  21552. * Gets a list of all attached data kinds (Position, normal, etc...)
  21553. * @returns a list of string containing all kinds
  21554. */
  21555. getVerticesDataKinds(): string[];
  21556. /**
  21557. * Update index buffer
  21558. * @param indices defines the indices to store in the index buffer
  21559. * @param offset defines the offset in the target buffer where to store the data
  21560. * @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)
  21561. */
  21562. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21563. /**
  21564. * Creates a new index buffer
  21565. * @param indices defines the indices to store in the index buffer
  21566. * @param totalVertices defines the total number of vertices (could be null)
  21567. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21568. */
  21569. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21570. /**
  21571. * Return the total number of indices
  21572. * @returns the total number of indices
  21573. */
  21574. getTotalIndices(): number;
  21575. /**
  21576. * Gets the index buffer array
  21577. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21578. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21579. * @returns the index buffer array
  21580. */
  21581. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21582. /**
  21583. * Gets the index buffer
  21584. * @return the index buffer
  21585. */
  21586. getIndexBuffer(): Nullable<DataBuffer>;
  21587. /** @hidden */
  21588. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21589. /**
  21590. * Release the associated resources for a specific mesh
  21591. * @param mesh defines the source mesh
  21592. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21593. */
  21594. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21595. /**
  21596. * Apply current geometry to a given mesh
  21597. * @param mesh defines the mesh to apply geometry to
  21598. */
  21599. applyToMesh(mesh: Mesh): void;
  21600. private _updateExtend;
  21601. private _applyToMesh;
  21602. private notifyUpdate;
  21603. /**
  21604. * Load the geometry if it was flagged as delay loaded
  21605. * @param scene defines the hosting scene
  21606. * @param onLoaded defines a callback called when the geometry is loaded
  21607. */
  21608. load(scene: Scene, onLoaded?: () => void): void;
  21609. private _queueLoad;
  21610. /**
  21611. * Invert the geometry to move from a right handed system to a left handed one.
  21612. */
  21613. toLeftHanded(): void;
  21614. /** @hidden */
  21615. _resetPointsArrayCache(): void;
  21616. /** @hidden */
  21617. _generatePointsArray(): boolean;
  21618. /**
  21619. * Gets a value indicating if the geometry is disposed
  21620. * @returns true if the geometry was disposed
  21621. */
  21622. isDisposed(): boolean;
  21623. private _disposeVertexArrayObjects;
  21624. /**
  21625. * Free all associated resources
  21626. */
  21627. dispose(): void;
  21628. /**
  21629. * Clone the current geometry into a new geometry
  21630. * @param id defines the unique ID of the new geometry
  21631. * @returns a new geometry object
  21632. */
  21633. copy(id: string): Geometry;
  21634. /**
  21635. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21636. * @return a JSON representation of the current geometry data (without the vertices data)
  21637. */
  21638. serialize(): any;
  21639. private toNumberArray;
  21640. /**
  21641. * Serialize all vertices data into a JSON oject
  21642. * @returns a JSON representation of the current geometry data
  21643. */
  21644. serializeVerticeData(): any;
  21645. /**
  21646. * Extracts a clone of a mesh geometry
  21647. * @param mesh defines the source mesh
  21648. * @param id defines the unique ID of the new geometry object
  21649. * @returns the new geometry object
  21650. */
  21651. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21652. /**
  21653. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21654. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21655. * Be aware Math.random() could cause collisions, but:
  21656. * "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"
  21657. * @returns a string containing a new GUID
  21658. */
  21659. static RandomId(): string;
  21660. /** @hidden */
  21661. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21662. private static _CleanMatricesWeights;
  21663. /**
  21664. * Create a new geometry from persisted data (Using .babylon file format)
  21665. * @param parsedVertexData defines the persisted data
  21666. * @param scene defines the hosting scene
  21667. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21668. * @returns the new geometry object
  21669. */
  21670. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21671. }
  21672. }
  21673. declare module "babylonjs/Meshes/mesh.vertexData" {
  21674. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21675. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21676. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21677. import { Geometry } from "babylonjs/Meshes/geometry";
  21678. import { Mesh } from "babylonjs/Meshes/mesh";
  21679. /**
  21680. * Define an interface for all classes that will get and set the data on vertices
  21681. */
  21682. export interface IGetSetVerticesData {
  21683. /**
  21684. * Gets a boolean indicating if specific vertex data is present
  21685. * @param kind defines the vertex data kind to use
  21686. * @returns true is data kind is present
  21687. */
  21688. isVerticesDataPresent(kind: string): boolean;
  21689. /**
  21690. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21691. * @param kind defines the data kind (Position, normal, etc...)
  21692. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21693. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21694. * @returns a float array containing vertex data
  21695. */
  21696. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21697. /**
  21698. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21699. * @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.
  21700. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21701. * @returns the indices array or an empty array if the mesh has no geometry
  21702. */
  21703. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21704. /**
  21705. * Set specific vertex data
  21706. * @param kind defines the data kind (Position, normal, etc...)
  21707. * @param data defines the vertex data to use
  21708. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21709. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21710. */
  21711. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21712. /**
  21713. * Update a specific associated vertex buffer
  21714. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21715. * - VertexBuffer.PositionKind
  21716. * - VertexBuffer.UVKind
  21717. * - VertexBuffer.UV2Kind
  21718. * - VertexBuffer.UV3Kind
  21719. * - VertexBuffer.UV4Kind
  21720. * - VertexBuffer.UV5Kind
  21721. * - VertexBuffer.UV6Kind
  21722. * - VertexBuffer.ColorKind
  21723. * - VertexBuffer.MatricesIndicesKind
  21724. * - VertexBuffer.MatricesIndicesExtraKind
  21725. * - VertexBuffer.MatricesWeightsKind
  21726. * - VertexBuffer.MatricesWeightsExtraKind
  21727. * @param data defines the data source
  21728. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21729. * @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)
  21730. */
  21731. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21732. /**
  21733. * Creates a new index buffer
  21734. * @param indices defines the indices to store in the index buffer
  21735. * @param totalVertices defines the total number of vertices (could be null)
  21736. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21737. */
  21738. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21739. }
  21740. /**
  21741. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21742. */
  21743. export class VertexData {
  21744. /**
  21745. * Mesh side orientation : usually the external or front surface
  21746. */
  21747. static readonly FRONTSIDE: number;
  21748. /**
  21749. * Mesh side orientation : usually the internal or back surface
  21750. */
  21751. static readonly BACKSIDE: number;
  21752. /**
  21753. * Mesh side orientation : both internal and external or front and back surfaces
  21754. */
  21755. static readonly DOUBLESIDE: number;
  21756. /**
  21757. * Mesh side orientation : by default, `FRONTSIDE`
  21758. */
  21759. static readonly DEFAULTSIDE: number;
  21760. /**
  21761. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21762. */
  21763. positions: Nullable<FloatArray>;
  21764. /**
  21765. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21766. */
  21767. normals: Nullable<FloatArray>;
  21768. /**
  21769. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21770. */
  21771. tangents: Nullable<FloatArray>;
  21772. /**
  21773. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21774. */
  21775. uvs: Nullable<FloatArray>;
  21776. /**
  21777. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21778. */
  21779. uvs2: Nullable<FloatArray>;
  21780. /**
  21781. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21782. */
  21783. uvs3: Nullable<FloatArray>;
  21784. /**
  21785. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21786. */
  21787. uvs4: Nullable<FloatArray>;
  21788. /**
  21789. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21790. */
  21791. uvs5: Nullable<FloatArray>;
  21792. /**
  21793. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21794. */
  21795. uvs6: Nullable<FloatArray>;
  21796. /**
  21797. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21798. */
  21799. colors: Nullable<FloatArray>;
  21800. /**
  21801. * 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).
  21802. */
  21803. matricesIndices: Nullable<FloatArray>;
  21804. /**
  21805. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21806. */
  21807. matricesWeights: Nullable<FloatArray>;
  21808. /**
  21809. * An array extending the number of possible indices
  21810. */
  21811. matricesIndicesExtra: Nullable<FloatArray>;
  21812. /**
  21813. * An array extending the number of possible weights when the number of indices is extended
  21814. */
  21815. matricesWeightsExtra: Nullable<FloatArray>;
  21816. /**
  21817. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21818. */
  21819. indices: Nullable<IndicesArray>;
  21820. /**
  21821. * Uses the passed data array to set the set the values for the specified kind of data
  21822. * @param data a linear array of floating numbers
  21823. * @param kind the type of data that is being set, eg positions, colors etc
  21824. */
  21825. set(data: FloatArray, kind: string): void;
  21826. /**
  21827. * Associates the vertexData to the passed Mesh.
  21828. * Sets it as updatable or not (default `false`)
  21829. * @param mesh the mesh the vertexData is applied to
  21830. * @param updatable when used and having the value true allows new data to update the vertexData
  21831. * @returns the VertexData
  21832. */
  21833. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21834. /**
  21835. * Associates the vertexData to the passed Geometry.
  21836. * Sets it as updatable or not (default `false`)
  21837. * @param geometry the geometry the vertexData is applied to
  21838. * @param updatable when used and having the value true allows new data to update the vertexData
  21839. * @returns VertexData
  21840. */
  21841. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21842. /**
  21843. * Updates the associated mesh
  21844. * @param mesh the mesh to be updated
  21845. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21846. * @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
  21847. * @returns VertexData
  21848. */
  21849. updateMesh(mesh: Mesh): VertexData;
  21850. /**
  21851. * Updates the associated geometry
  21852. * @param geometry the geometry to be updated
  21853. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21854. * @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
  21855. * @returns VertexData.
  21856. */
  21857. updateGeometry(geometry: Geometry): VertexData;
  21858. private _applyTo;
  21859. private _update;
  21860. /**
  21861. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21862. * @param matrix the transforming matrix
  21863. * @returns the VertexData
  21864. */
  21865. transform(matrix: Matrix): VertexData;
  21866. /**
  21867. * Merges the passed VertexData into the current one
  21868. * @param other the VertexData to be merged into the current one
  21869. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21870. * @returns the modified VertexData
  21871. */
  21872. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21873. private _mergeElement;
  21874. private _validate;
  21875. /**
  21876. * Serializes the VertexData
  21877. * @returns a serialized object
  21878. */
  21879. serialize(): any;
  21880. /**
  21881. * Extracts the vertexData from a mesh
  21882. * @param mesh the mesh from which to extract the VertexData
  21883. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21884. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21885. * @returns the object VertexData associated to the passed mesh
  21886. */
  21887. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21888. /**
  21889. * Extracts the vertexData from the geometry
  21890. * @param geometry the geometry from which to extract the VertexData
  21891. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21892. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21893. * @returns the object VertexData associated to the passed mesh
  21894. */
  21895. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21896. private static _ExtractFrom;
  21897. /**
  21898. * Creates the VertexData for a Ribbon
  21899. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21900. * * pathArray array of paths, each of which an array of successive Vector3
  21901. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21902. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21903. * * 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
  21904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21905. * * 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)
  21906. * * 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)
  21907. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21908. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21909. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21910. * @returns the VertexData of the ribbon
  21911. */
  21912. static CreateRibbon(options: {
  21913. pathArray: Vector3[][];
  21914. closeArray?: boolean;
  21915. closePath?: boolean;
  21916. offset?: number;
  21917. sideOrientation?: number;
  21918. frontUVs?: Vector4;
  21919. backUVs?: Vector4;
  21920. invertUV?: boolean;
  21921. uvs?: Vector2[];
  21922. colors?: Color4[];
  21923. }): VertexData;
  21924. /**
  21925. * Creates the VertexData for a box
  21926. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21927. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21928. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21929. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21930. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21931. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21932. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21933. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21934. * * 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)
  21935. * * 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)
  21936. * @returns the VertexData of the box
  21937. */
  21938. static CreateBox(options: {
  21939. size?: number;
  21940. width?: number;
  21941. height?: number;
  21942. depth?: number;
  21943. faceUV?: Vector4[];
  21944. faceColors?: Color4[];
  21945. sideOrientation?: number;
  21946. frontUVs?: Vector4;
  21947. backUVs?: Vector4;
  21948. }): VertexData;
  21949. /**
  21950. * Creates the VertexData for a tiled box
  21951. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21952. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21953. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21954. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21955. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21956. * @returns the VertexData of the box
  21957. */
  21958. static CreateTiledBox(options: {
  21959. pattern?: number;
  21960. width?: number;
  21961. height?: number;
  21962. depth?: number;
  21963. tileSize?: number;
  21964. tileWidth?: number;
  21965. tileHeight?: number;
  21966. alignHorizontal?: number;
  21967. alignVertical?: number;
  21968. faceUV?: Vector4[];
  21969. faceColors?: Color4[];
  21970. sideOrientation?: number;
  21971. }): VertexData;
  21972. /**
  21973. * Creates the VertexData for a tiled plane
  21974. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21975. * * pattern a limited pattern arrangement depending on the number
  21976. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21977. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21978. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21980. * * 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)
  21981. * * 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)
  21982. * @returns the VertexData of the tiled plane
  21983. */
  21984. static CreateTiledPlane(options: {
  21985. pattern?: number;
  21986. tileSize?: number;
  21987. tileWidth?: number;
  21988. tileHeight?: number;
  21989. size?: number;
  21990. width?: number;
  21991. height?: number;
  21992. alignHorizontal?: number;
  21993. alignVertical?: number;
  21994. sideOrientation?: number;
  21995. frontUVs?: Vector4;
  21996. backUVs?: Vector4;
  21997. }): VertexData;
  21998. /**
  21999. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22000. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22001. * * segments sets the number of horizontal strips optional, default 32
  22002. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22003. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22004. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22005. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22006. * * 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
  22007. * * 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
  22008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22009. * * 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)
  22010. * * 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)
  22011. * @returns the VertexData of the ellipsoid
  22012. */
  22013. static CreateSphere(options: {
  22014. segments?: number;
  22015. diameter?: number;
  22016. diameterX?: number;
  22017. diameterY?: number;
  22018. diameterZ?: number;
  22019. arc?: number;
  22020. slice?: number;
  22021. sideOrientation?: number;
  22022. frontUVs?: Vector4;
  22023. backUVs?: Vector4;
  22024. }): VertexData;
  22025. /**
  22026. * Creates the VertexData for a cylinder, cone or prism
  22027. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22028. * * height sets the height (y direction) of the cylinder, optional, default 2
  22029. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22030. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22031. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22032. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22033. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22034. * * 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
  22035. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22036. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22037. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22038. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22039. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22040. * * 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)
  22041. * * 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)
  22042. * @returns the VertexData of the cylinder, cone or prism
  22043. */
  22044. static CreateCylinder(options: {
  22045. height?: number;
  22046. diameterTop?: number;
  22047. diameterBottom?: number;
  22048. diameter?: number;
  22049. tessellation?: number;
  22050. subdivisions?: number;
  22051. arc?: number;
  22052. faceColors?: Color4[];
  22053. faceUV?: Vector4[];
  22054. hasRings?: boolean;
  22055. enclose?: boolean;
  22056. sideOrientation?: number;
  22057. frontUVs?: Vector4;
  22058. backUVs?: Vector4;
  22059. }): VertexData;
  22060. /**
  22061. * Creates the VertexData for a torus
  22062. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22063. * * diameter the diameter of the torus, optional default 1
  22064. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22065. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22067. * * 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)
  22068. * * 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)
  22069. * @returns the VertexData of the torus
  22070. */
  22071. static CreateTorus(options: {
  22072. diameter?: number;
  22073. thickness?: number;
  22074. tessellation?: number;
  22075. sideOrientation?: number;
  22076. frontUVs?: Vector4;
  22077. backUVs?: Vector4;
  22078. }): VertexData;
  22079. /**
  22080. * Creates the VertexData of the LineSystem
  22081. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22082. * - lines an array of lines, each line being an array of successive Vector3
  22083. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22084. * @returns the VertexData of the LineSystem
  22085. */
  22086. static CreateLineSystem(options: {
  22087. lines: Vector3[][];
  22088. colors?: Nullable<Color4[][]>;
  22089. }): VertexData;
  22090. /**
  22091. * Create the VertexData for a DashedLines
  22092. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22093. * - points an array successive Vector3
  22094. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22095. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22096. * - dashNb the intended total number of dashes, optional, default 200
  22097. * @returns the VertexData for the DashedLines
  22098. */
  22099. static CreateDashedLines(options: {
  22100. points: Vector3[];
  22101. dashSize?: number;
  22102. gapSize?: number;
  22103. dashNb?: number;
  22104. }): VertexData;
  22105. /**
  22106. * Creates the VertexData for a Ground
  22107. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22108. * - width the width (x direction) of the ground, optional, default 1
  22109. * - height the height (z direction) of the ground, optional, default 1
  22110. * - subdivisions the number of subdivisions per side, optional, default 1
  22111. * @returns the VertexData of the Ground
  22112. */
  22113. static CreateGround(options: {
  22114. width?: number;
  22115. height?: number;
  22116. subdivisions?: number;
  22117. subdivisionsX?: number;
  22118. subdivisionsY?: number;
  22119. }): VertexData;
  22120. /**
  22121. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22122. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22123. * * xmin the ground minimum X coordinate, optional, default -1
  22124. * * zmin the ground minimum Z coordinate, optional, default -1
  22125. * * xmax the ground maximum X coordinate, optional, default 1
  22126. * * zmax the ground maximum Z coordinate, optional, default 1
  22127. * * 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}
  22128. * * 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}
  22129. * @returns the VertexData of the TiledGround
  22130. */
  22131. static CreateTiledGround(options: {
  22132. xmin: number;
  22133. zmin: number;
  22134. xmax: number;
  22135. zmax: number;
  22136. subdivisions?: {
  22137. w: number;
  22138. h: number;
  22139. };
  22140. precision?: {
  22141. w: number;
  22142. h: number;
  22143. };
  22144. }): VertexData;
  22145. /**
  22146. * Creates the VertexData of the Ground designed from a heightmap
  22147. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22148. * * width the width (x direction) of the ground
  22149. * * height the height (z direction) of the ground
  22150. * * subdivisions the number of subdivisions per side
  22151. * * minHeight the minimum altitude on the ground, optional, default 0
  22152. * * maxHeight the maximum altitude on the ground, optional default 1
  22153. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22154. * * buffer the array holding the image color data
  22155. * * bufferWidth the width of image
  22156. * * bufferHeight the height of image
  22157. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22158. * @returns the VertexData of the Ground designed from a heightmap
  22159. */
  22160. static CreateGroundFromHeightMap(options: {
  22161. width: number;
  22162. height: number;
  22163. subdivisions: number;
  22164. minHeight: number;
  22165. maxHeight: number;
  22166. colorFilter: Color3;
  22167. buffer: Uint8Array;
  22168. bufferWidth: number;
  22169. bufferHeight: number;
  22170. alphaFilter: number;
  22171. }): VertexData;
  22172. /**
  22173. * Creates the VertexData for a Plane
  22174. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22175. * * size sets the width and height of the plane to the value of size, optional default 1
  22176. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22177. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22179. * * 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)
  22180. * * 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)
  22181. * @returns the VertexData of the box
  22182. */
  22183. static CreatePlane(options: {
  22184. size?: number;
  22185. width?: number;
  22186. height?: number;
  22187. sideOrientation?: number;
  22188. frontUVs?: Vector4;
  22189. backUVs?: Vector4;
  22190. }): VertexData;
  22191. /**
  22192. * Creates the VertexData of the Disc or regular Polygon
  22193. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22194. * * radius the radius of the disc, optional default 0.5
  22195. * * tessellation the number of polygon sides, optional, default 64
  22196. * * 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
  22197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22198. * * 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)
  22199. * * 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)
  22200. * @returns the VertexData of the box
  22201. */
  22202. static CreateDisc(options: {
  22203. radius?: number;
  22204. tessellation?: number;
  22205. arc?: number;
  22206. sideOrientation?: number;
  22207. frontUVs?: Vector4;
  22208. backUVs?: Vector4;
  22209. }): VertexData;
  22210. /**
  22211. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22212. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22213. * @param polygon a mesh built from polygonTriangulation.build()
  22214. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22215. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22216. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22217. * @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)
  22218. * @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)
  22219. * @returns the VertexData of the Polygon
  22220. */
  22221. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22222. /**
  22223. * Creates the VertexData of the IcoSphere
  22224. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22225. * * radius the radius of the IcoSphere, optional default 1
  22226. * * radiusX allows stretching in the x direction, optional, default radius
  22227. * * radiusY allows stretching in the y direction, optional, default radius
  22228. * * radiusZ allows stretching in the z direction, optional, default radius
  22229. * * flat when true creates a flat shaded mesh, optional, default true
  22230. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22232. * * 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)
  22233. * * 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)
  22234. * @returns the VertexData of the IcoSphere
  22235. */
  22236. static CreateIcoSphere(options: {
  22237. radius?: number;
  22238. radiusX?: number;
  22239. radiusY?: number;
  22240. radiusZ?: number;
  22241. flat?: boolean;
  22242. subdivisions?: number;
  22243. sideOrientation?: number;
  22244. frontUVs?: Vector4;
  22245. backUVs?: Vector4;
  22246. }): VertexData;
  22247. /**
  22248. * Creates the VertexData for a Polyhedron
  22249. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22250. * * type provided types are:
  22251. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22252. * * 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)
  22253. * * size the size of the IcoSphere, optional default 1
  22254. * * sizeX allows stretching in the x direction, optional, default size
  22255. * * sizeY allows stretching in the y direction, optional, default size
  22256. * * sizeZ allows stretching in the z direction, optional, default size
  22257. * * 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
  22258. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22259. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22260. * * flat when true creates a flat shaded mesh, optional, default true
  22261. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22262. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22263. * * 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)
  22264. * * 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)
  22265. * @returns the VertexData of the Polyhedron
  22266. */
  22267. static CreatePolyhedron(options: {
  22268. type?: number;
  22269. size?: number;
  22270. sizeX?: number;
  22271. sizeY?: number;
  22272. sizeZ?: number;
  22273. custom?: any;
  22274. faceUV?: Vector4[];
  22275. faceColors?: Color4[];
  22276. flat?: boolean;
  22277. sideOrientation?: number;
  22278. frontUVs?: Vector4;
  22279. backUVs?: Vector4;
  22280. }): VertexData;
  22281. /**
  22282. * Creates the VertexData for a TorusKnot
  22283. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22284. * * radius the radius of the torus knot, optional, default 2
  22285. * * tube the thickness of the tube, optional, default 0.5
  22286. * * radialSegments the number of sides on each tube segments, optional, default 32
  22287. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22288. * * p the number of windings around the z axis, optional, default 2
  22289. * * q the number of windings around the x axis, optional, default 3
  22290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22291. * * 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)
  22292. * * 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)
  22293. * @returns the VertexData of the Torus Knot
  22294. */
  22295. static CreateTorusKnot(options: {
  22296. radius?: number;
  22297. tube?: number;
  22298. radialSegments?: number;
  22299. tubularSegments?: number;
  22300. p?: number;
  22301. q?: number;
  22302. sideOrientation?: number;
  22303. frontUVs?: Vector4;
  22304. backUVs?: Vector4;
  22305. }): VertexData;
  22306. /**
  22307. * Compute normals for given positions and indices
  22308. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22309. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22310. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22311. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22312. * * facetNormals : optional array of facet normals (vector3)
  22313. * * facetPositions : optional array of facet positions (vector3)
  22314. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22315. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22316. * * bInfo : optional bounding info, required for facetPartitioning computation
  22317. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22318. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22319. * * useRightHandedSystem: optional boolean to for right handed system computation
  22320. * * depthSort : optional boolean to enable the facet depth sort computation
  22321. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22322. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22323. */
  22324. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22325. facetNormals?: any;
  22326. facetPositions?: any;
  22327. facetPartitioning?: any;
  22328. ratio?: number;
  22329. bInfo?: any;
  22330. bbSize?: Vector3;
  22331. subDiv?: any;
  22332. useRightHandedSystem?: boolean;
  22333. depthSort?: boolean;
  22334. distanceTo?: Vector3;
  22335. depthSortedFacets?: any;
  22336. }): void;
  22337. /** @hidden */
  22338. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22339. /**
  22340. * Applies VertexData created from the imported parameters to the geometry
  22341. * @param parsedVertexData the parsed data from an imported file
  22342. * @param geometry the geometry to apply the VertexData to
  22343. */
  22344. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22345. }
  22346. }
  22347. declare module "babylonjs/Morph/morphTarget" {
  22348. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22349. import { Observable } from "babylonjs/Misc/observable";
  22350. import { Nullable, FloatArray } from "babylonjs/types";
  22351. import { Scene } from "babylonjs/scene";
  22352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22353. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22354. /**
  22355. * Defines a target to use with MorphTargetManager
  22356. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22357. */
  22358. export class MorphTarget implements IAnimatable {
  22359. /** defines the name of the target */
  22360. name: string;
  22361. /**
  22362. * Gets or sets the list of animations
  22363. */
  22364. animations: import("babylonjs/Animations/animation").Animation[];
  22365. private _scene;
  22366. private _positions;
  22367. private _normals;
  22368. private _tangents;
  22369. private _uvs;
  22370. private _influence;
  22371. /**
  22372. * Observable raised when the influence changes
  22373. */
  22374. onInfluenceChanged: Observable<boolean>;
  22375. /** @hidden */
  22376. _onDataLayoutChanged: Observable<void>;
  22377. /**
  22378. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22379. */
  22380. influence: number;
  22381. /**
  22382. * Gets or sets the id of the morph Target
  22383. */
  22384. id: string;
  22385. private _animationPropertiesOverride;
  22386. /**
  22387. * Gets or sets the animation properties override
  22388. */
  22389. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22390. /**
  22391. * Creates a new MorphTarget
  22392. * @param name defines the name of the target
  22393. * @param influence defines the influence to use
  22394. * @param scene defines the scene the morphtarget belongs to
  22395. */
  22396. constructor(
  22397. /** defines the name of the target */
  22398. name: string, influence?: number, scene?: Nullable<Scene>);
  22399. /**
  22400. * Gets a boolean defining if the target contains position data
  22401. */
  22402. readonly hasPositions: boolean;
  22403. /**
  22404. * Gets a boolean defining if the target contains normal data
  22405. */
  22406. readonly hasNormals: boolean;
  22407. /**
  22408. * Gets a boolean defining if the target contains tangent data
  22409. */
  22410. readonly hasTangents: boolean;
  22411. /**
  22412. * Gets a boolean defining if the target contains texture coordinates data
  22413. */
  22414. readonly hasUVs: boolean;
  22415. /**
  22416. * Affects position data to this target
  22417. * @param data defines the position data to use
  22418. */
  22419. setPositions(data: Nullable<FloatArray>): void;
  22420. /**
  22421. * Gets the position data stored in this target
  22422. * @returns a FloatArray containing the position data (or null if not present)
  22423. */
  22424. getPositions(): Nullable<FloatArray>;
  22425. /**
  22426. * Affects normal data to this target
  22427. * @param data defines the normal data to use
  22428. */
  22429. setNormals(data: Nullable<FloatArray>): void;
  22430. /**
  22431. * Gets the normal data stored in this target
  22432. * @returns a FloatArray containing the normal data (or null if not present)
  22433. */
  22434. getNormals(): Nullable<FloatArray>;
  22435. /**
  22436. * Affects tangent data to this target
  22437. * @param data defines the tangent data to use
  22438. */
  22439. setTangents(data: Nullable<FloatArray>): void;
  22440. /**
  22441. * Gets the tangent data stored in this target
  22442. * @returns a FloatArray containing the tangent data (or null if not present)
  22443. */
  22444. getTangents(): Nullable<FloatArray>;
  22445. /**
  22446. * Affects texture coordinates data to this target
  22447. * @param data defines the texture coordinates data to use
  22448. */
  22449. setUVs(data: Nullable<FloatArray>): void;
  22450. /**
  22451. * Gets the texture coordinates data stored in this target
  22452. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22453. */
  22454. getUVs(): Nullable<FloatArray>;
  22455. /**
  22456. * Serializes the current target into a Serialization object
  22457. * @returns the serialized object
  22458. */
  22459. serialize(): any;
  22460. /**
  22461. * Returns the string "MorphTarget"
  22462. * @returns "MorphTarget"
  22463. */
  22464. getClassName(): string;
  22465. /**
  22466. * Creates a new target from serialized data
  22467. * @param serializationObject defines the serialized data to use
  22468. * @returns a new MorphTarget
  22469. */
  22470. static Parse(serializationObject: any): MorphTarget;
  22471. /**
  22472. * Creates a MorphTarget from mesh data
  22473. * @param mesh defines the source mesh
  22474. * @param name defines the name to use for the new target
  22475. * @param influence defines the influence to attach to the target
  22476. * @returns a new MorphTarget
  22477. */
  22478. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22479. }
  22480. }
  22481. declare module "babylonjs/Morph/morphTargetManager" {
  22482. import { Nullable } from "babylonjs/types";
  22483. import { Scene } from "babylonjs/scene";
  22484. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22485. /**
  22486. * This class is used to deform meshes using morphing between different targets
  22487. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22488. */
  22489. export class MorphTargetManager {
  22490. private _targets;
  22491. private _targetInfluenceChangedObservers;
  22492. private _targetDataLayoutChangedObservers;
  22493. private _activeTargets;
  22494. private _scene;
  22495. private _influences;
  22496. private _supportsNormals;
  22497. private _supportsTangents;
  22498. private _supportsUVs;
  22499. private _vertexCount;
  22500. private _uniqueId;
  22501. private _tempInfluences;
  22502. /**
  22503. * Gets or sets a boolean indicating if normals must be morphed
  22504. */
  22505. enableNormalMorphing: boolean;
  22506. /**
  22507. * Gets or sets a boolean indicating if tangents must be morphed
  22508. */
  22509. enableTangentMorphing: boolean;
  22510. /**
  22511. * Gets or sets a boolean indicating if UV must be morphed
  22512. */
  22513. enableUVMorphing: boolean;
  22514. /**
  22515. * Creates a new MorphTargetManager
  22516. * @param scene defines the current scene
  22517. */
  22518. constructor(scene?: Nullable<Scene>);
  22519. /**
  22520. * Gets the unique ID of this manager
  22521. */
  22522. readonly uniqueId: number;
  22523. /**
  22524. * Gets the number of vertices handled by this manager
  22525. */
  22526. readonly vertexCount: number;
  22527. /**
  22528. * Gets a boolean indicating if this manager supports morphing of normals
  22529. */
  22530. readonly supportsNormals: boolean;
  22531. /**
  22532. * Gets a boolean indicating if this manager supports morphing of tangents
  22533. */
  22534. readonly supportsTangents: boolean;
  22535. /**
  22536. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22537. */
  22538. readonly supportsUVs: boolean;
  22539. /**
  22540. * Gets the number of targets stored in this manager
  22541. */
  22542. readonly numTargets: number;
  22543. /**
  22544. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22545. */
  22546. readonly numInfluencers: number;
  22547. /**
  22548. * Gets the list of influences (one per target)
  22549. */
  22550. readonly influences: Float32Array;
  22551. /**
  22552. * Gets the active target at specified index. An active target is a target with an influence > 0
  22553. * @param index defines the index to check
  22554. * @returns the requested target
  22555. */
  22556. getActiveTarget(index: number): MorphTarget;
  22557. /**
  22558. * Gets the target at specified index
  22559. * @param index defines the index to check
  22560. * @returns the requested target
  22561. */
  22562. getTarget(index: number): MorphTarget;
  22563. /**
  22564. * Add a new target to this manager
  22565. * @param target defines the target to add
  22566. */
  22567. addTarget(target: MorphTarget): void;
  22568. /**
  22569. * Removes a target from the manager
  22570. * @param target defines the target to remove
  22571. */
  22572. removeTarget(target: MorphTarget): void;
  22573. /**
  22574. * Serializes the current manager into a Serialization object
  22575. * @returns the serialized object
  22576. */
  22577. serialize(): any;
  22578. private _syncActiveTargets;
  22579. /**
  22580. * Syncrhonize the targets with all the meshes using this morph target manager
  22581. */
  22582. synchronize(): void;
  22583. /**
  22584. * Creates a new MorphTargetManager from serialized data
  22585. * @param serializationObject defines the serialized data
  22586. * @param scene defines the hosting scene
  22587. * @returns the new MorphTargetManager
  22588. */
  22589. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22590. }
  22591. }
  22592. declare module "babylonjs/Meshes/meshLODLevel" {
  22593. import { Mesh } from "babylonjs/Meshes/mesh";
  22594. import { Nullable } from "babylonjs/types";
  22595. /**
  22596. * Class used to represent a specific level of detail of a mesh
  22597. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22598. */
  22599. export class MeshLODLevel {
  22600. /** Defines the distance where this level should star being displayed */
  22601. distance: number;
  22602. /** Defines the mesh to use to render this level */
  22603. mesh: Nullable<Mesh>;
  22604. /**
  22605. * Creates a new LOD level
  22606. * @param distance defines the distance where this level should star being displayed
  22607. * @param mesh defines the mesh to use to render this level
  22608. */
  22609. constructor(
  22610. /** Defines the distance where this level should star being displayed */
  22611. distance: number,
  22612. /** Defines the mesh to use to render this level */
  22613. mesh: Nullable<Mesh>);
  22614. }
  22615. }
  22616. declare module "babylonjs/Meshes/groundMesh" {
  22617. import { Scene } from "babylonjs/scene";
  22618. import { Vector3 } from "babylonjs/Maths/math.vector";
  22619. import { Mesh } from "babylonjs/Meshes/mesh";
  22620. /**
  22621. * Mesh representing the gorund
  22622. */
  22623. export class GroundMesh extends Mesh {
  22624. /** If octree should be generated */
  22625. generateOctree: boolean;
  22626. private _heightQuads;
  22627. /** @hidden */
  22628. _subdivisionsX: number;
  22629. /** @hidden */
  22630. _subdivisionsY: number;
  22631. /** @hidden */
  22632. _width: number;
  22633. /** @hidden */
  22634. _height: number;
  22635. /** @hidden */
  22636. _minX: number;
  22637. /** @hidden */
  22638. _maxX: number;
  22639. /** @hidden */
  22640. _minZ: number;
  22641. /** @hidden */
  22642. _maxZ: number;
  22643. constructor(name: string, scene: Scene);
  22644. /**
  22645. * "GroundMesh"
  22646. * @returns "GroundMesh"
  22647. */
  22648. getClassName(): string;
  22649. /**
  22650. * The minimum of x and y subdivisions
  22651. */
  22652. readonly subdivisions: number;
  22653. /**
  22654. * X subdivisions
  22655. */
  22656. readonly subdivisionsX: number;
  22657. /**
  22658. * Y subdivisions
  22659. */
  22660. readonly subdivisionsY: number;
  22661. /**
  22662. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22663. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22664. * @param chunksCount the number of subdivisions for x and y
  22665. * @param octreeBlocksSize (Default: 32)
  22666. */
  22667. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22668. /**
  22669. * Returns a height (y) value in the Worl system :
  22670. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22671. * @param x x coordinate
  22672. * @param z z coordinate
  22673. * @returns the ground y position if (x, z) are outside the ground surface.
  22674. */
  22675. getHeightAtCoordinates(x: number, z: number): number;
  22676. /**
  22677. * Returns a normalized vector (Vector3) orthogonal to the ground
  22678. * at the ground coordinates (x, z) expressed in the World system.
  22679. * @param x x coordinate
  22680. * @param z z coordinate
  22681. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22682. */
  22683. getNormalAtCoordinates(x: number, z: number): Vector3;
  22684. /**
  22685. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22686. * at the ground coordinates (x, z) expressed in the World system.
  22687. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22688. * @param x x coordinate
  22689. * @param z z coordinate
  22690. * @param ref vector to store the result
  22691. * @returns the GroundMesh.
  22692. */
  22693. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22694. /**
  22695. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22696. * if the ground has been updated.
  22697. * This can be used in the render loop.
  22698. * @returns the GroundMesh.
  22699. */
  22700. updateCoordinateHeights(): GroundMesh;
  22701. private _getFacetAt;
  22702. private _initHeightQuads;
  22703. private _computeHeightQuads;
  22704. /**
  22705. * Serializes this ground mesh
  22706. * @param serializationObject object to write serialization to
  22707. */
  22708. serialize(serializationObject: any): void;
  22709. /**
  22710. * Parses a serialized ground mesh
  22711. * @param parsedMesh the serialized mesh
  22712. * @param scene the scene to create the ground mesh in
  22713. * @returns the created ground mesh
  22714. */
  22715. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22716. }
  22717. }
  22718. declare module "babylonjs/Physics/physicsJoint" {
  22719. import { Vector3 } from "babylonjs/Maths/math.vector";
  22720. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22721. /**
  22722. * Interface for Physics-Joint data
  22723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22724. */
  22725. export interface PhysicsJointData {
  22726. /**
  22727. * The main pivot of the joint
  22728. */
  22729. mainPivot?: Vector3;
  22730. /**
  22731. * The connected pivot of the joint
  22732. */
  22733. connectedPivot?: Vector3;
  22734. /**
  22735. * The main axis of the joint
  22736. */
  22737. mainAxis?: Vector3;
  22738. /**
  22739. * The connected axis of the joint
  22740. */
  22741. connectedAxis?: Vector3;
  22742. /**
  22743. * The collision of the joint
  22744. */
  22745. collision?: boolean;
  22746. /**
  22747. * Native Oimo/Cannon/Energy data
  22748. */
  22749. nativeParams?: any;
  22750. }
  22751. /**
  22752. * This is a holder class for the physics joint created by the physics plugin
  22753. * It holds a set of functions to control the underlying joint
  22754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22755. */
  22756. export class PhysicsJoint {
  22757. /**
  22758. * The type of the physics joint
  22759. */
  22760. type: number;
  22761. /**
  22762. * The data for the physics joint
  22763. */
  22764. jointData: PhysicsJointData;
  22765. private _physicsJoint;
  22766. protected _physicsPlugin: IPhysicsEnginePlugin;
  22767. /**
  22768. * Initializes the physics joint
  22769. * @param type The type of the physics joint
  22770. * @param jointData The data for the physics joint
  22771. */
  22772. constructor(
  22773. /**
  22774. * The type of the physics joint
  22775. */
  22776. type: number,
  22777. /**
  22778. * The data for the physics joint
  22779. */
  22780. jointData: PhysicsJointData);
  22781. /**
  22782. * Gets the physics joint
  22783. */
  22784. /**
  22785. * Sets the physics joint
  22786. */
  22787. physicsJoint: any;
  22788. /**
  22789. * Sets the physics plugin
  22790. */
  22791. physicsPlugin: IPhysicsEnginePlugin;
  22792. /**
  22793. * Execute a function that is physics-plugin specific.
  22794. * @param {Function} func the function that will be executed.
  22795. * It accepts two parameters: the physics world and the physics joint
  22796. */
  22797. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22798. /**
  22799. * Distance-Joint type
  22800. */
  22801. static DistanceJoint: number;
  22802. /**
  22803. * Hinge-Joint type
  22804. */
  22805. static HingeJoint: number;
  22806. /**
  22807. * Ball-and-Socket joint type
  22808. */
  22809. static BallAndSocketJoint: number;
  22810. /**
  22811. * Wheel-Joint type
  22812. */
  22813. static WheelJoint: number;
  22814. /**
  22815. * Slider-Joint type
  22816. */
  22817. static SliderJoint: number;
  22818. /**
  22819. * Prismatic-Joint type
  22820. */
  22821. static PrismaticJoint: number;
  22822. /**
  22823. * Universal-Joint type
  22824. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22825. */
  22826. static UniversalJoint: number;
  22827. /**
  22828. * Hinge-Joint 2 type
  22829. */
  22830. static Hinge2Joint: number;
  22831. /**
  22832. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22833. */
  22834. static PointToPointJoint: number;
  22835. /**
  22836. * Spring-Joint type
  22837. */
  22838. static SpringJoint: number;
  22839. /**
  22840. * Lock-Joint type
  22841. */
  22842. static LockJoint: number;
  22843. }
  22844. /**
  22845. * A class representing a physics distance joint
  22846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22847. */
  22848. export class DistanceJoint extends PhysicsJoint {
  22849. /**
  22850. *
  22851. * @param jointData The data for the Distance-Joint
  22852. */
  22853. constructor(jointData: DistanceJointData);
  22854. /**
  22855. * Update the predefined distance.
  22856. * @param maxDistance The maximum preferred distance
  22857. * @param minDistance The minimum preferred distance
  22858. */
  22859. updateDistance(maxDistance: number, minDistance?: number): void;
  22860. }
  22861. /**
  22862. * Represents a Motor-Enabled Joint
  22863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22864. */
  22865. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22866. /**
  22867. * Initializes the Motor-Enabled Joint
  22868. * @param type The type of the joint
  22869. * @param jointData The physica joint data for the joint
  22870. */
  22871. constructor(type: number, jointData: PhysicsJointData);
  22872. /**
  22873. * Set the motor values.
  22874. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22875. * @param force the force to apply
  22876. * @param maxForce max force for this motor.
  22877. */
  22878. setMotor(force?: number, maxForce?: number): void;
  22879. /**
  22880. * Set the motor's limits.
  22881. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22882. * @param upperLimit The upper limit of the motor
  22883. * @param lowerLimit The lower limit of the motor
  22884. */
  22885. setLimit(upperLimit: number, lowerLimit?: number): void;
  22886. }
  22887. /**
  22888. * This class represents a single physics Hinge-Joint
  22889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22890. */
  22891. export class HingeJoint extends MotorEnabledJoint {
  22892. /**
  22893. * Initializes the Hinge-Joint
  22894. * @param jointData The joint data for the Hinge-Joint
  22895. */
  22896. constructor(jointData: PhysicsJointData);
  22897. /**
  22898. * Set the motor values.
  22899. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22900. * @param {number} force the force to apply
  22901. * @param {number} maxForce max force for this motor.
  22902. */
  22903. setMotor(force?: number, maxForce?: number): void;
  22904. /**
  22905. * Set the motor's limits.
  22906. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22907. * @param upperLimit The upper limit of the motor
  22908. * @param lowerLimit The lower limit of the motor
  22909. */
  22910. setLimit(upperLimit: number, lowerLimit?: number): void;
  22911. }
  22912. /**
  22913. * This class represents a dual hinge physics joint (same as wheel joint)
  22914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22915. */
  22916. export class Hinge2Joint extends MotorEnabledJoint {
  22917. /**
  22918. * Initializes the Hinge2-Joint
  22919. * @param jointData The joint data for the Hinge2-Joint
  22920. */
  22921. constructor(jointData: PhysicsJointData);
  22922. /**
  22923. * Set the motor values.
  22924. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22925. * @param {number} targetSpeed the speed the motor is to reach
  22926. * @param {number} maxForce max force for this motor.
  22927. * @param {motorIndex} the motor's index, 0 or 1.
  22928. */
  22929. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22930. /**
  22931. * Set the motor limits.
  22932. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22933. * @param {number} upperLimit the upper limit
  22934. * @param {number} lowerLimit lower limit
  22935. * @param {motorIndex} the motor's index, 0 or 1.
  22936. */
  22937. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22938. }
  22939. /**
  22940. * Interface for a motor enabled joint
  22941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22942. */
  22943. export interface IMotorEnabledJoint {
  22944. /**
  22945. * Physics joint
  22946. */
  22947. physicsJoint: any;
  22948. /**
  22949. * Sets the motor of the motor-enabled joint
  22950. * @param force The force of the motor
  22951. * @param maxForce The maximum force of the motor
  22952. * @param motorIndex The index of the motor
  22953. */
  22954. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22955. /**
  22956. * Sets the limit of the motor
  22957. * @param upperLimit The upper limit of the motor
  22958. * @param lowerLimit The lower limit of the motor
  22959. * @param motorIndex The index of the motor
  22960. */
  22961. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22962. }
  22963. /**
  22964. * Joint data for a Distance-Joint
  22965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22966. */
  22967. export interface DistanceJointData extends PhysicsJointData {
  22968. /**
  22969. * Max distance the 2 joint objects can be apart
  22970. */
  22971. maxDistance: number;
  22972. }
  22973. /**
  22974. * Joint data from a spring joint
  22975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22976. */
  22977. export interface SpringJointData extends PhysicsJointData {
  22978. /**
  22979. * Length of the spring
  22980. */
  22981. length: number;
  22982. /**
  22983. * Stiffness of the spring
  22984. */
  22985. stiffness: number;
  22986. /**
  22987. * Damping of the spring
  22988. */
  22989. damping: number;
  22990. /** this callback will be called when applying the force to the impostors. */
  22991. forceApplicationCallback: () => void;
  22992. }
  22993. }
  22994. declare module "babylonjs/Physics/physicsRaycastResult" {
  22995. import { Vector3 } from "babylonjs/Maths/math.vector";
  22996. /**
  22997. * Holds the data for the raycast result
  22998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22999. */
  23000. export class PhysicsRaycastResult {
  23001. private _hasHit;
  23002. private _hitDistance;
  23003. private _hitNormalWorld;
  23004. private _hitPointWorld;
  23005. private _rayFromWorld;
  23006. private _rayToWorld;
  23007. /**
  23008. * Gets if there was a hit
  23009. */
  23010. readonly hasHit: boolean;
  23011. /**
  23012. * Gets the distance from the hit
  23013. */
  23014. readonly hitDistance: number;
  23015. /**
  23016. * Gets the hit normal/direction in the world
  23017. */
  23018. readonly hitNormalWorld: Vector3;
  23019. /**
  23020. * Gets the hit point in the world
  23021. */
  23022. readonly hitPointWorld: Vector3;
  23023. /**
  23024. * Gets the ray "start point" of the ray in the world
  23025. */
  23026. readonly rayFromWorld: Vector3;
  23027. /**
  23028. * Gets the ray "end point" of the ray in the world
  23029. */
  23030. readonly rayToWorld: Vector3;
  23031. /**
  23032. * Sets the hit data (normal & point in world space)
  23033. * @param hitNormalWorld defines the normal in world space
  23034. * @param hitPointWorld defines the point in world space
  23035. */
  23036. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23037. /**
  23038. * Sets the distance from the start point to the hit point
  23039. * @param distance
  23040. */
  23041. setHitDistance(distance: number): void;
  23042. /**
  23043. * Calculates the distance manually
  23044. */
  23045. calculateHitDistance(): void;
  23046. /**
  23047. * Resets all the values to default
  23048. * @param from The from point on world space
  23049. * @param to The to point on world space
  23050. */
  23051. reset(from?: Vector3, to?: Vector3): void;
  23052. }
  23053. /**
  23054. * Interface for the size containing width and height
  23055. */
  23056. interface IXYZ {
  23057. /**
  23058. * X
  23059. */
  23060. x: number;
  23061. /**
  23062. * Y
  23063. */
  23064. y: number;
  23065. /**
  23066. * Z
  23067. */
  23068. z: number;
  23069. }
  23070. }
  23071. declare module "babylonjs/Physics/IPhysicsEngine" {
  23072. import { Nullable } from "babylonjs/types";
  23073. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23075. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23076. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23077. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23078. /**
  23079. * Interface used to describe a physics joint
  23080. */
  23081. export interface PhysicsImpostorJoint {
  23082. /** Defines the main impostor to which the joint is linked */
  23083. mainImpostor: PhysicsImpostor;
  23084. /** Defines the impostor that is connected to the main impostor using this joint */
  23085. connectedImpostor: PhysicsImpostor;
  23086. /** Defines the joint itself */
  23087. joint: PhysicsJoint;
  23088. }
  23089. /** @hidden */
  23090. export interface IPhysicsEnginePlugin {
  23091. world: any;
  23092. name: string;
  23093. setGravity(gravity: Vector3): void;
  23094. setTimeStep(timeStep: number): void;
  23095. getTimeStep(): number;
  23096. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23097. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23098. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23099. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23100. removePhysicsBody(impostor: PhysicsImpostor): void;
  23101. generateJoint(joint: PhysicsImpostorJoint): void;
  23102. removeJoint(joint: PhysicsImpostorJoint): void;
  23103. isSupported(): boolean;
  23104. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23105. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23106. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23107. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23108. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23109. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23110. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23111. getBodyMass(impostor: PhysicsImpostor): number;
  23112. getBodyFriction(impostor: PhysicsImpostor): number;
  23113. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23114. getBodyRestitution(impostor: PhysicsImpostor): number;
  23115. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23116. getBodyPressure?(impostor: PhysicsImpostor): number;
  23117. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23118. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23119. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23120. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23121. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23122. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23123. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23124. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23125. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23126. sleepBody(impostor: PhysicsImpostor): void;
  23127. wakeUpBody(impostor: PhysicsImpostor): void;
  23128. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23129. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23130. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23131. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23132. getRadius(impostor: PhysicsImpostor): number;
  23133. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23134. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23135. dispose(): void;
  23136. }
  23137. /**
  23138. * Interface used to define a physics engine
  23139. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23140. */
  23141. export interface IPhysicsEngine {
  23142. /**
  23143. * Gets the gravity vector used by the simulation
  23144. */
  23145. gravity: Vector3;
  23146. /**
  23147. * Sets the gravity vector used by the simulation
  23148. * @param gravity defines the gravity vector to use
  23149. */
  23150. setGravity(gravity: Vector3): void;
  23151. /**
  23152. * Set the time step of the physics engine.
  23153. * Default is 1/60.
  23154. * To slow it down, enter 1/600 for example.
  23155. * To speed it up, 1/30
  23156. * @param newTimeStep the new timestep to apply to this world.
  23157. */
  23158. setTimeStep(newTimeStep: number): void;
  23159. /**
  23160. * Get the time step of the physics engine.
  23161. * @returns the current time step
  23162. */
  23163. getTimeStep(): number;
  23164. /**
  23165. * Release all resources
  23166. */
  23167. dispose(): void;
  23168. /**
  23169. * Gets the name of the current physics plugin
  23170. * @returns the name of the plugin
  23171. */
  23172. getPhysicsPluginName(): string;
  23173. /**
  23174. * Adding a new impostor for the impostor tracking.
  23175. * This will be done by the impostor itself.
  23176. * @param impostor the impostor to add
  23177. */
  23178. addImpostor(impostor: PhysicsImpostor): void;
  23179. /**
  23180. * Remove an impostor from the engine.
  23181. * This impostor and its mesh will not longer be updated by the physics engine.
  23182. * @param impostor the impostor to remove
  23183. */
  23184. removeImpostor(impostor: PhysicsImpostor): void;
  23185. /**
  23186. * Add a joint to the physics engine
  23187. * @param mainImpostor defines the main impostor to which the joint is added.
  23188. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23189. * @param joint defines the joint that will connect both impostors.
  23190. */
  23191. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23192. /**
  23193. * Removes a joint from the simulation
  23194. * @param mainImpostor defines the impostor used with the joint
  23195. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23196. * @param joint defines the joint to remove
  23197. */
  23198. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23199. /**
  23200. * Gets the current plugin used to run the simulation
  23201. * @returns current plugin
  23202. */
  23203. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23204. /**
  23205. * Gets the list of physic impostors
  23206. * @returns an array of PhysicsImpostor
  23207. */
  23208. getImpostors(): Array<PhysicsImpostor>;
  23209. /**
  23210. * Gets the impostor for a physics enabled object
  23211. * @param object defines the object impersonated by the impostor
  23212. * @returns the PhysicsImpostor or null if not found
  23213. */
  23214. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23215. /**
  23216. * Gets the impostor for a physics body object
  23217. * @param body defines physics body used by the impostor
  23218. * @returns the PhysicsImpostor or null if not found
  23219. */
  23220. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23221. /**
  23222. * Does a raycast in the physics world
  23223. * @param from when should the ray start?
  23224. * @param to when should the ray end?
  23225. * @returns PhysicsRaycastResult
  23226. */
  23227. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23228. /**
  23229. * Called by the scene. No need to call it.
  23230. * @param delta defines the timespam between frames
  23231. */
  23232. _step(delta: number): void;
  23233. }
  23234. }
  23235. declare module "babylonjs/Physics/physicsImpostor" {
  23236. import { Nullable, IndicesArray } from "babylonjs/types";
  23237. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23238. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23240. import { Scene } from "babylonjs/scene";
  23241. import { Bone } from "babylonjs/Bones/bone";
  23242. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23243. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23244. import { Space } from "babylonjs/Maths/math.axis";
  23245. /**
  23246. * The interface for the physics imposter parameters
  23247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23248. */
  23249. export interface PhysicsImpostorParameters {
  23250. /**
  23251. * The mass of the physics imposter
  23252. */
  23253. mass: number;
  23254. /**
  23255. * The friction of the physics imposter
  23256. */
  23257. friction?: number;
  23258. /**
  23259. * The coefficient of restitution of the physics imposter
  23260. */
  23261. restitution?: number;
  23262. /**
  23263. * The native options of the physics imposter
  23264. */
  23265. nativeOptions?: any;
  23266. /**
  23267. * Specifies if the parent should be ignored
  23268. */
  23269. ignoreParent?: boolean;
  23270. /**
  23271. * Specifies if bi-directional transformations should be disabled
  23272. */
  23273. disableBidirectionalTransformation?: boolean;
  23274. /**
  23275. * The pressure inside the physics imposter, soft object only
  23276. */
  23277. pressure?: number;
  23278. /**
  23279. * The stiffness the physics imposter, soft object only
  23280. */
  23281. stiffness?: number;
  23282. /**
  23283. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23284. */
  23285. velocityIterations?: number;
  23286. /**
  23287. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23288. */
  23289. positionIterations?: number;
  23290. /**
  23291. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23292. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23293. * Add to fix multiple points
  23294. */
  23295. fixedPoints?: number;
  23296. /**
  23297. * The collision margin around a soft object
  23298. */
  23299. margin?: number;
  23300. /**
  23301. * The collision margin around a soft object
  23302. */
  23303. damping?: number;
  23304. /**
  23305. * The path for a rope based on an extrusion
  23306. */
  23307. path?: any;
  23308. /**
  23309. * The shape of an extrusion used for a rope based on an extrusion
  23310. */
  23311. shape?: any;
  23312. }
  23313. /**
  23314. * Interface for a physics-enabled object
  23315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23316. */
  23317. export interface IPhysicsEnabledObject {
  23318. /**
  23319. * The position of the physics-enabled object
  23320. */
  23321. position: Vector3;
  23322. /**
  23323. * The rotation of the physics-enabled object
  23324. */
  23325. rotationQuaternion: Nullable<Quaternion>;
  23326. /**
  23327. * The scale of the physics-enabled object
  23328. */
  23329. scaling: Vector3;
  23330. /**
  23331. * The rotation of the physics-enabled object
  23332. */
  23333. rotation?: Vector3;
  23334. /**
  23335. * The parent of the physics-enabled object
  23336. */
  23337. parent?: any;
  23338. /**
  23339. * The bounding info of the physics-enabled object
  23340. * @returns The bounding info of the physics-enabled object
  23341. */
  23342. getBoundingInfo(): BoundingInfo;
  23343. /**
  23344. * Computes the world matrix
  23345. * @param force Specifies if the world matrix should be computed by force
  23346. * @returns A world matrix
  23347. */
  23348. computeWorldMatrix(force: boolean): Matrix;
  23349. /**
  23350. * Gets the world matrix
  23351. * @returns A world matrix
  23352. */
  23353. getWorldMatrix?(): Matrix;
  23354. /**
  23355. * Gets the child meshes
  23356. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23357. * @returns An array of abstract meshes
  23358. */
  23359. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23360. /**
  23361. * Gets the vertex data
  23362. * @param kind The type of vertex data
  23363. * @returns A nullable array of numbers, or a float32 array
  23364. */
  23365. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23366. /**
  23367. * Gets the indices from the mesh
  23368. * @returns A nullable array of index arrays
  23369. */
  23370. getIndices?(): Nullable<IndicesArray>;
  23371. /**
  23372. * Gets the scene from the mesh
  23373. * @returns the indices array or null
  23374. */
  23375. getScene?(): Scene;
  23376. /**
  23377. * Gets the absolute position from the mesh
  23378. * @returns the absolute position
  23379. */
  23380. getAbsolutePosition(): Vector3;
  23381. /**
  23382. * Gets the absolute pivot point from the mesh
  23383. * @returns the absolute pivot point
  23384. */
  23385. getAbsolutePivotPoint(): Vector3;
  23386. /**
  23387. * Rotates the mesh
  23388. * @param axis The axis of rotation
  23389. * @param amount The amount of rotation
  23390. * @param space The space of the rotation
  23391. * @returns The rotation transform node
  23392. */
  23393. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23394. /**
  23395. * Translates the mesh
  23396. * @param axis The axis of translation
  23397. * @param distance The distance of translation
  23398. * @param space The space of the translation
  23399. * @returns The transform node
  23400. */
  23401. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23402. /**
  23403. * Sets the absolute position of the mesh
  23404. * @param absolutePosition The absolute position of the mesh
  23405. * @returns The transform node
  23406. */
  23407. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23408. /**
  23409. * Gets the class name of the mesh
  23410. * @returns The class name
  23411. */
  23412. getClassName(): string;
  23413. }
  23414. /**
  23415. * Represents a physics imposter
  23416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23417. */
  23418. export class PhysicsImpostor {
  23419. /**
  23420. * The physics-enabled object used as the physics imposter
  23421. */
  23422. object: IPhysicsEnabledObject;
  23423. /**
  23424. * The type of the physics imposter
  23425. */
  23426. type: number;
  23427. private _options;
  23428. private _scene?;
  23429. /**
  23430. * The default object size of the imposter
  23431. */
  23432. static DEFAULT_OBJECT_SIZE: Vector3;
  23433. /**
  23434. * The identity quaternion of the imposter
  23435. */
  23436. static IDENTITY_QUATERNION: Quaternion;
  23437. /** @hidden */
  23438. _pluginData: any;
  23439. private _physicsEngine;
  23440. private _physicsBody;
  23441. private _bodyUpdateRequired;
  23442. private _onBeforePhysicsStepCallbacks;
  23443. private _onAfterPhysicsStepCallbacks;
  23444. /** @hidden */
  23445. _onPhysicsCollideCallbacks: Array<{
  23446. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23447. otherImpostors: Array<PhysicsImpostor>;
  23448. }>;
  23449. private _deltaPosition;
  23450. private _deltaRotation;
  23451. private _deltaRotationConjugated;
  23452. /** @hidden */
  23453. _isFromLine: boolean;
  23454. private _parent;
  23455. private _isDisposed;
  23456. private static _tmpVecs;
  23457. private static _tmpQuat;
  23458. /**
  23459. * Specifies if the physics imposter is disposed
  23460. */
  23461. readonly isDisposed: boolean;
  23462. /**
  23463. * Gets the mass of the physics imposter
  23464. */
  23465. mass: number;
  23466. /**
  23467. * Gets the coefficient of friction
  23468. */
  23469. /**
  23470. * Sets the coefficient of friction
  23471. */
  23472. friction: number;
  23473. /**
  23474. * Gets the coefficient of restitution
  23475. */
  23476. /**
  23477. * Sets the coefficient of restitution
  23478. */
  23479. restitution: number;
  23480. /**
  23481. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23482. */
  23483. /**
  23484. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23485. */
  23486. pressure: number;
  23487. /**
  23488. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23489. */
  23490. /**
  23491. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23492. */
  23493. stiffness: number;
  23494. /**
  23495. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23496. */
  23497. /**
  23498. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23499. */
  23500. velocityIterations: number;
  23501. /**
  23502. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23503. */
  23504. /**
  23505. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23506. */
  23507. positionIterations: number;
  23508. /**
  23509. * The unique id of the physics imposter
  23510. * set by the physics engine when adding this impostor to the array
  23511. */
  23512. uniqueId: number;
  23513. /**
  23514. * @hidden
  23515. */
  23516. soft: boolean;
  23517. /**
  23518. * @hidden
  23519. */
  23520. segments: number;
  23521. private _joints;
  23522. /**
  23523. * Initializes the physics imposter
  23524. * @param object The physics-enabled object used as the physics imposter
  23525. * @param type The type of the physics imposter
  23526. * @param _options The options for the physics imposter
  23527. * @param _scene The Babylon scene
  23528. */
  23529. constructor(
  23530. /**
  23531. * The physics-enabled object used as the physics imposter
  23532. */
  23533. object: IPhysicsEnabledObject,
  23534. /**
  23535. * The type of the physics imposter
  23536. */
  23537. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23538. /**
  23539. * This function will completly initialize this impostor.
  23540. * It will create a new body - but only if this mesh has no parent.
  23541. * If it has, this impostor will not be used other than to define the impostor
  23542. * of the child mesh.
  23543. * @hidden
  23544. */
  23545. _init(): void;
  23546. private _getPhysicsParent;
  23547. /**
  23548. * Should a new body be generated.
  23549. * @returns boolean specifying if body initialization is required
  23550. */
  23551. isBodyInitRequired(): boolean;
  23552. /**
  23553. * Sets the updated scaling
  23554. * @param updated Specifies if the scaling is updated
  23555. */
  23556. setScalingUpdated(): void;
  23557. /**
  23558. * Force a regeneration of this or the parent's impostor's body.
  23559. * Use under cautious - This will remove all joints already implemented.
  23560. */
  23561. forceUpdate(): void;
  23562. /**
  23563. * Gets the body that holds this impostor. Either its own, or its parent.
  23564. */
  23565. /**
  23566. * Set the physics body. Used mainly by the physics engine/plugin
  23567. */
  23568. physicsBody: any;
  23569. /**
  23570. * Get the parent of the physics imposter
  23571. * @returns Physics imposter or null
  23572. */
  23573. /**
  23574. * Sets the parent of the physics imposter
  23575. */
  23576. parent: Nullable<PhysicsImpostor>;
  23577. /**
  23578. * Resets the update flags
  23579. */
  23580. resetUpdateFlags(): void;
  23581. /**
  23582. * Gets the object extend size
  23583. * @returns the object extend size
  23584. */
  23585. getObjectExtendSize(): Vector3;
  23586. /**
  23587. * Gets the object center
  23588. * @returns The object center
  23589. */
  23590. getObjectCenter(): Vector3;
  23591. /**
  23592. * Get a specific parametes from the options parameter
  23593. * @param paramName The object parameter name
  23594. * @returns The object parameter
  23595. */
  23596. getParam(paramName: string): any;
  23597. /**
  23598. * Sets a specific parameter in the options given to the physics plugin
  23599. * @param paramName The parameter name
  23600. * @param value The value of the parameter
  23601. */
  23602. setParam(paramName: string, value: number): void;
  23603. /**
  23604. * Specifically change the body's mass option. Won't recreate the physics body object
  23605. * @param mass The mass of the physics imposter
  23606. */
  23607. setMass(mass: number): void;
  23608. /**
  23609. * Gets the linear velocity
  23610. * @returns linear velocity or null
  23611. */
  23612. getLinearVelocity(): Nullable<Vector3>;
  23613. /**
  23614. * Sets the linear velocity
  23615. * @param velocity linear velocity or null
  23616. */
  23617. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23618. /**
  23619. * Gets the angular velocity
  23620. * @returns angular velocity or null
  23621. */
  23622. getAngularVelocity(): Nullable<Vector3>;
  23623. /**
  23624. * Sets the angular velocity
  23625. * @param velocity The velocity or null
  23626. */
  23627. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23628. /**
  23629. * Execute a function with the physics plugin native code
  23630. * Provide a function the will have two variables - the world object and the physics body object
  23631. * @param func The function to execute with the physics plugin native code
  23632. */
  23633. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23634. /**
  23635. * Register a function that will be executed before the physics world is stepping forward
  23636. * @param func The function to execute before the physics world is stepped forward
  23637. */
  23638. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23639. /**
  23640. * Unregister a function that will be executed before the physics world is stepping forward
  23641. * @param func The function to execute before the physics world is stepped forward
  23642. */
  23643. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23644. /**
  23645. * Register a function that will be executed after the physics step
  23646. * @param func The function to execute after physics step
  23647. */
  23648. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23649. /**
  23650. * Unregisters a function that will be executed after the physics step
  23651. * @param func The function to execute after physics step
  23652. */
  23653. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23654. /**
  23655. * register a function that will be executed when this impostor collides against a different body
  23656. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23657. * @param func Callback that is executed on collision
  23658. */
  23659. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23660. /**
  23661. * Unregisters the physics imposter on contact
  23662. * @param collideAgainst The physics object to collide against
  23663. * @param func Callback to execute on collision
  23664. */
  23665. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23666. private _tmpQuat;
  23667. private _tmpQuat2;
  23668. /**
  23669. * Get the parent rotation
  23670. * @returns The parent rotation
  23671. */
  23672. getParentsRotation(): Quaternion;
  23673. /**
  23674. * this function is executed by the physics engine.
  23675. */
  23676. beforeStep: () => void;
  23677. /**
  23678. * this function is executed by the physics engine
  23679. */
  23680. afterStep: () => void;
  23681. /**
  23682. * Legacy collision detection event support
  23683. */
  23684. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23685. /**
  23686. * event and body object due to cannon's event-based architecture.
  23687. */
  23688. onCollide: (e: {
  23689. body: any;
  23690. }) => void;
  23691. /**
  23692. * Apply a force
  23693. * @param force The force to apply
  23694. * @param contactPoint The contact point for the force
  23695. * @returns The physics imposter
  23696. */
  23697. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23698. /**
  23699. * Apply an impulse
  23700. * @param force The impulse force
  23701. * @param contactPoint The contact point for the impulse force
  23702. * @returns The physics imposter
  23703. */
  23704. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23705. /**
  23706. * A help function to create a joint
  23707. * @param otherImpostor A physics imposter used to create a joint
  23708. * @param jointType The type of joint
  23709. * @param jointData The data for the joint
  23710. * @returns The physics imposter
  23711. */
  23712. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23713. /**
  23714. * Add a joint to this impostor with a different impostor
  23715. * @param otherImpostor A physics imposter used to add a joint
  23716. * @param joint The joint to add
  23717. * @returns The physics imposter
  23718. */
  23719. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23720. /**
  23721. * Add an anchor to a cloth impostor
  23722. * @param otherImpostor rigid impostor to anchor to
  23723. * @param width ratio across width from 0 to 1
  23724. * @param height ratio up height from 0 to 1
  23725. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23726. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23727. * @returns impostor the soft imposter
  23728. */
  23729. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23730. /**
  23731. * Add a hook to a rope impostor
  23732. * @param otherImpostor rigid impostor to anchor to
  23733. * @param length ratio across rope from 0 to 1
  23734. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23735. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23736. * @returns impostor the rope imposter
  23737. */
  23738. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23739. /**
  23740. * Will keep this body still, in a sleep mode.
  23741. * @returns the physics imposter
  23742. */
  23743. sleep(): PhysicsImpostor;
  23744. /**
  23745. * Wake the body up.
  23746. * @returns The physics imposter
  23747. */
  23748. wakeUp(): PhysicsImpostor;
  23749. /**
  23750. * Clones the physics imposter
  23751. * @param newObject The physics imposter clones to this physics-enabled object
  23752. * @returns A nullable physics imposter
  23753. */
  23754. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23755. /**
  23756. * Disposes the physics imposter
  23757. */
  23758. dispose(): void;
  23759. /**
  23760. * Sets the delta position
  23761. * @param position The delta position amount
  23762. */
  23763. setDeltaPosition(position: Vector3): void;
  23764. /**
  23765. * Sets the delta rotation
  23766. * @param rotation The delta rotation amount
  23767. */
  23768. setDeltaRotation(rotation: Quaternion): void;
  23769. /**
  23770. * Gets the box size of the physics imposter and stores the result in the input parameter
  23771. * @param result Stores the box size
  23772. * @returns The physics imposter
  23773. */
  23774. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23775. /**
  23776. * Gets the radius of the physics imposter
  23777. * @returns Radius of the physics imposter
  23778. */
  23779. getRadius(): number;
  23780. /**
  23781. * Sync a bone with this impostor
  23782. * @param bone The bone to sync to the impostor.
  23783. * @param boneMesh The mesh that the bone is influencing.
  23784. * @param jointPivot The pivot of the joint / bone in local space.
  23785. * @param distToJoint Optional distance from the impostor to the joint.
  23786. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23787. */
  23788. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23789. /**
  23790. * Sync impostor to a bone
  23791. * @param bone The bone that the impostor will be synced to.
  23792. * @param boneMesh The mesh that the bone is influencing.
  23793. * @param jointPivot The pivot of the joint / bone in local space.
  23794. * @param distToJoint Optional distance from the impostor to the joint.
  23795. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23796. * @param boneAxis Optional vector3 axis the bone is aligned with
  23797. */
  23798. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23799. /**
  23800. * No-Imposter type
  23801. */
  23802. static NoImpostor: number;
  23803. /**
  23804. * Sphere-Imposter type
  23805. */
  23806. static SphereImpostor: number;
  23807. /**
  23808. * Box-Imposter type
  23809. */
  23810. static BoxImpostor: number;
  23811. /**
  23812. * Plane-Imposter type
  23813. */
  23814. static PlaneImpostor: number;
  23815. /**
  23816. * Mesh-imposter type
  23817. */
  23818. static MeshImpostor: number;
  23819. /**
  23820. * Capsule-Impostor type (Ammo.js plugin only)
  23821. */
  23822. static CapsuleImpostor: number;
  23823. /**
  23824. * Cylinder-Imposter type
  23825. */
  23826. static CylinderImpostor: number;
  23827. /**
  23828. * Particle-Imposter type
  23829. */
  23830. static ParticleImpostor: number;
  23831. /**
  23832. * Heightmap-Imposter type
  23833. */
  23834. static HeightmapImpostor: number;
  23835. /**
  23836. * ConvexHull-Impostor type (Ammo.js plugin only)
  23837. */
  23838. static ConvexHullImpostor: number;
  23839. /**
  23840. * Rope-Imposter type
  23841. */
  23842. static RopeImpostor: number;
  23843. /**
  23844. * Cloth-Imposter type
  23845. */
  23846. static ClothImpostor: number;
  23847. /**
  23848. * Softbody-Imposter type
  23849. */
  23850. static SoftbodyImpostor: number;
  23851. }
  23852. }
  23853. declare module "babylonjs/Meshes/mesh" {
  23854. import { Observable } from "babylonjs/Misc/observable";
  23855. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23856. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23857. import { Camera } from "babylonjs/Cameras/camera";
  23858. import { Scene } from "babylonjs/scene";
  23859. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23860. import { Color4 } from "babylonjs/Maths/math.color";
  23861. import { Engine } from "babylonjs/Engines/engine";
  23862. import { Node } from "babylonjs/node";
  23863. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23864. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23865. import { Buffer } from "babylonjs/Meshes/buffer";
  23866. import { Geometry } from "babylonjs/Meshes/geometry";
  23867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23868. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23869. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23870. import { Effect } from "babylonjs/Materials/effect";
  23871. import { Material } from "babylonjs/Materials/material";
  23872. import { Skeleton } from "babylonjs/Bones/skeleton";
  23873. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23874. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23875. import { Path3D } from "babylonjs/Maths/math.path";
  23876. import { Plane } from "babylonjs/Maths/math.plane";
  23877. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23878. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23879. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23880. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23881. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23882. /**
  23883. * @hidden
  23884. **/
  23885. export class _CreationDataStorage {
  23886. closePath?: boolean;
  23887. closeArray?: boolean;
  23888. idx: number[];
  23889. dashSize: number;
  23890. gapSize: number;
  23891. path3D: Path3D;
  23892. pathArray: Vector3[][];
  23893. arc: number;
  23894. radius: number;
  23895. cap: number;
  23896. tessellation: number;
  23897. }
  23898. /**
  23899. * @hidden
  23900. **/
  23901. class _InstanceDataStorage {
  23902. visibleInstances: any;
  23903. batchCache: _InstancesBatch;
  23904. instancesBufferSize: number;
  23905. instancesBuffer: Nullable<Buffer>;
  23906. instancesData: Float32Array;
  23907. overridenInstanceCount: number;
  23908. isFrozen: boolean;
  23909. previousBatch: Nullable<_InstancesBatch>;
  23910. hardwareInstancedRendering: boolean;
  23911. sideOrientation: number;
  23912. }
  23913. /**
  23914. * @hidden
  23915. **/
  23916. export class _InstancesBatch {
  23917. mustReturn: boolean;
  23918. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23919. renderSelf: boolean[];
  23920. hardwareInstancedRendering: boolean[];
  23921. }
  23922. /**
  23923. * Class used to represent renderable models
  23924. */
  23925. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23926. /**
  23927. * Mesh side orientation : usually the external or front surface
  23928. */
  23929. static readonly FRONTSIDE: number;
  23930. /**
  23931. * Mesh side orientation : usually the internal or back surface
  23932. */
  23933. static readonly BACKSIDE: number;
  23934. /**
  23935. * Mesh side orientation : both internal and external or front and back surfaces
  23936. */
  23937. static readonly DOUBLESIDE: number;
  23938. /**
  23939. * Mesh side orientation : by default, `FRONTSIDE`
  23940. */
  23941. static readonly DEFAULTSIDE: number;
  23942. /**
  23943. * Mesh cap setting : no cap
  23944. */
  23945. static readonly NO_CAP: number;
  23946. /**
  23947. * Mesh cap setting : one cap at the beginning of the mesh
  23948. */
  23949. static readonly CAP_START: number;
  23950. /**
  23951. * Mesh cap setting : one cap at the end of the mesh
  23952. */
  23953. static readonly CAP_END: number;
  23954. /**
  23955. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23956. */
  23957. static readonly CAP_ALL: number;
  23958. /**
  23959. * Mesh pattern setting : no flip or rotate
  23960. */
  23961. static readonly NO_FLIP: number;
  23962. /**
  23963. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23964. */
  23965. static readonly FLIP_TILE: number;
  23966. /**
  23967. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23968. */
  23969. static readonly ROTATE_TILE: number;
  23970. /**
  23971. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23972. */
  23973. static readonly FLIP_ROW: number;
  23974. /**
  23975. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23976. */
  23977. static readonly ROTATE_ROW: number;
  23978. /**
  23979. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23980. */
  23981. static readonly FLIP_N_ROTATE_TILE: number;
  23982. /**
  23983. * Mesh pattern setting : rotate pattern and rotate
  23984. */
  23985. static readonly FLIP_N_ROTATE_ROW: number;
  23986. /**
  23987. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23988. */
  23989. static readonly CENTER: number;
  23990. /**
  23991. * Mesh tile positioning : part tiles on left
  23992. */
  23993. static readonly LEFT: number;
  23994. /**
  23995. * Mesh tile positioning : part tiles on right
  23996. */
  23997. static readonly RIGHT: number;
  23998. /**
  23999. * Mesh tile positioning : part tiles on top
  24000. */
  24001. static readonly TOP: number;
  24002. /**
  24003. * Mesh tile positioning : part tiles on bottom
  24004. */
  24005. static readonly BOTTOM: number;
  24006. /**
  24007. * Gets the default side orientation.
  24008. * @param orientation the orientation to value to attempt to get
  24009. * @returns the default orientation
  24010. * @hidden
  24011. */
  24012. static _GetDefaultSideOrientation(orientation?: number): number;
  24013. private _internalMeshDataInfo;
  24014. /**
  24015. * An event triggered before rendering the mesh
  24016. */
  24017. readonly onBeforeRenderObservable: Observable<Mesh>;
  24018. /**
  24019. * An event triggered before binding the mesh
  24020. */
  24021. readonly onBeforeBindObservable: Observable<Mesh>;
  24022. /**
  24023. * An event triggered after rendering the mesh
  24024. */
  24025. readonly onAfterRenderObservable: Observable<Mesh>;
  24026. /**
  24027. * An event triggered before drawing the mesh
  24028. */
  24029. readonly onBeforeDrawObservable: Observable<Mesh>;
  24030. private _onBeforeDrawObserver;
  24031. /**
  24032. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24033. */
  24034. onBeforeDraw: () => void;
  24035. /**
  24036. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24037. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24038. */
  24039. delayLoadState: number;
  24040. /**
  24041. * Gets the list of instances created from this mesh
  24042. * it is not supposed to be modified manually.
  24043. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24044. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24045. */
  24046. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24047. /**
  24048. * Gets the file containing delay loading data for this mesh
  24049. */
  24050. delayLoadingFile: string;
  24051. /** @hidden */
  24052. _binaryInfo: any;
  24053. /**
  24054. * User defined function used to change how LOD level selection is done
  24055. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24056. */
  24057. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24058. /**
  24059. * Gets or sets the morph target manager
  24060. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24061. */
  24062. morphTargetManager: Nullable<MorphTargetManager>;
  24063. /** @hidden */
  24064. _creationDataStorage: Nullable<_CreationDataStorage>;
  24065. /** @hidden */
  24066. _geometry: Nullable<Geometry>;
  24067. /** @hidden */
  24068. _delayInfo: Array<string>;
  24069. /** @hidden */
  24070. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24071. /** @hidden */
  24072. _instanceDataStorage: _InstanceDataStorage;
  24073. private _effectiveMaterial;
  24074. /** @hidden */
  24075. _shouldGenerateFlatShading: boolean;
  24076. /** @hidden */
  24077. _originalBuilderSideOrientation: number;
  24078. /**
  24079. * Use this property to change the original side orientation defined at construction time
  24080. */
  24081. overrideMaterialSideOrientation: Nullable<number>;
  24082. /**
  24083. * Gets the source mesh (the one used to clone this one from)
  24084. */
  24085. readonly source: Nullable<Mesh>;
  24086. /**
  24087. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24088. */
  24089. isUnIndexed: boolean;
  24090. /**
  24091. * @constructor
  24092. * @param name The value used by scene.getMeshByName() to do a lookup.
  24093. * @param scene The scene to add this mesh to.
  24094. * @param parent The parent of this mesh, if it has one
  24095. * @param source An optional Mesh from which geometry is shared, cloned.
  24096. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24097. * When false, achieved by calling a clone(), also passing False.
  24098. * This will make creation of children, recursive.
  24099. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24100. */
  24101. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24102. /**
  24103. * Gets the class name
  24104. * @returns the string "Mesh".
  24105. */
  24106. getClassName(): string;
  24107. /** @hidden */
  24108. readonly _isMesh: boolean;
  24109. /**
  24110. * Returns a description of this mesh
  24111. * @param fullDetails define if full details about this mesh must be used
  24112. * @returns a descriptive string representing this mesh
  24113. */
  24114. toString(fullDetails?: boolean): string;
  24115. /** @hidden */
  24116. _unBindEffect(): void;
  24117. /**
  24118. * Gets a boolean indicating if this mesh has LOD
  24119. */
  24120. readonly hasLODLevels: boolean;
  24121. /**
  24122. * Gets the list of MeshLODLevel associated with the current mesh
  24123. * @returns an array of MeshLODLevel
  24124. */
  24125. getLODLevels(): MeshLODLevel[];
  24126. private _sortLODLevels;
  24127. /**
  24128. * Add a mesh as LOD level triggered at the given distance.
  24129. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24130. * @param distance The distance from the center of the object to show this level
  24131. * @param mesh The mesh to be added as LOD level (can be null)
  24132. * @return This mesh (for chaining)
  24133. */
  24134. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24135. /**
  24136. * Returns the LOD level mesh at the passed distance or null if not found.
  24137. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24138. * @param distance The distance from the center of the object to show this level
  24139. * @returns a Mesh or `null`
  24140. */
  24141. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24142. /**
  24143. * Remove a mesh from the LOD array
  24144. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24145. * @param mesh defines the mesh to be removed
  24146. * @return This mesh (for chaining)
  24147. */
  24148. removeLODLevel(mesh: Mesh): Mesh;
  24149. /**
  24150. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24151. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24152. * @param camera defines the camera to use to compute distance
  24153. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24154. * @return This mesh (for chaining)
  24155. */
  24156. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24157. /**
  24158. * Gets the mesh internal Geometry object
  24159. */
  24160. readonly geometry: Nullable<Geometry>;
  24161. /**
  24162. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24163. * @returns the total number of vertices
  24164. */
  24165. getTotalVertices(): number;
  24166. /**
  24167. * Returns the content of an associated vertex buffer
  24168. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24169. * - VertexBuffer.PositionKind
  24170. * - VertexBuffer.UVKind
  24171. * - VertexBuffer.UV2Kind
  24172. * - VertexBuffer.UV3Kind
  24173. * - VertexBuffer.UV4Kind
  24174. * - VertexBuffer.UV5Kind
  24175. * - VertexBuffer.UV6Kind
  24176. * - VertexBuffer.ColorKind
  24177. * - VertexBuffer.MatricesIndicesKind
  24178. * - VertexBuffer.MatricesIndicesExtraKind
  24179. * - VertexBuffer.MatricesWeightsKind
  24180. * - VertexBuffer.MatricesWeightsExtraKind
  24181. * @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
  24182. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24183. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24184. */
  24185. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24186. /**
  24187. * Returns the mesh VertexBuffer object from the requested `kind`
  24188. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24189. * - VertexBuffer.PositionKind
  24190. * - VertexBuffer.NormalKind
  24191. * - VertexBuffer.UVKind
  24192. * - VertexBuffer.UV2Kind
  24193. * - VertexBuffer.UV3Kind
  24194. * - VertexBuffer.UV4Kind
  24195. * - VertexBuffer.UV5Kind
  24196. * - VertexBuffer.UV6Kind
  24197. * - VertexBuffer.ColorKind
  24198. * - VertexBuffer.MatricesIndicesKind
  24199. * - VertexBuffer.MatricesIndicesExtraKind
  24200. * - VertexBuffer.MatricesWeightsKind
  24201. * - VertexBuffer.MatricesWeightsExtraKind
  24202. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24203. */
  24204. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24205. /**
  24206. * Tests if a specific vertex buffer is associated with this mesh
  24207. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24208. * - VertexBuffer.PositionKind
  24209. * - VertexBuffer.NormalKind
  24210. * - VertexBuffer.UVKind
  24211. * - VertexBuffer.UV2Kind
  24212. * - VertexBuffer.UV3Kind
  24213. * - VertexBuffer.UV4Kind
  24214. * - VertexBuffer.UV5Kind
  24215. * - VertexBuffer.UV6Kind
  24216. * - VertexBuffer.ColorKind
  24217. * - VertexBuffer.MatricesIndicesKind
  24218. * - VertexBuffer.MatricesIndicesExtraKind
  24219. * - VertexBuffer.MatricesWeightsKind
  24220. * - VertexBuffer.MatricesWeightsExtraKind
  24221. * @returns a boolean
  24222. */
  24223. isVerticesDataPresent(kind: string): boolean;
  24224. /**
  24225. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24226. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24227. * - VertexBuffer.PositionKind
  24228. * - VertexBuffer.UVKind
  24229. * - VertexBuffer.UV2Kind
  24230. * - VertexBuffer.UV3Kind
  24231. * - VertexBuffer.UV4Kind
  24232. * - VertexBuffer.UV5Kind
  24233. * - VertexBuffer.UV6Kind
  24234. * - VertexBuffer.ColorKind
  24235. * - VertexBuffer.MatricesIndicesKind
  24236. * - VertexBuffer.MatricesIndicesExtraKind
  24237. * - VertexBuffer.MatricesWeightsKind
  24238. * - VertexBuffer.MatricesWeightsExtraKind
  24239. * @returns a boolean
  24240. */
  24241. isVertexBufferUpdatable(kind: string): boolean;
  24242. /**
  24243. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24244. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24245. * - VertexBuffer.PositionKind
  24246. * - VertexBuffer.NormalKind
  24247. * - VertexBuffer.UVKind
  24248. * - VertexBuffer.UV2Kind
  24249. * - VertexBuffer.UV3Kind
  24250. * - VertexBuffer.UV4Kind
  24251. * - VertexBuffer.UV5Kind
  24252. * - VertexBuffer.UV6Kind
  24253. * - VertexBuffer.ColorKind
  24254. * - VertexBuffer.MatricesIndicesKind
  24255. * - VertexBuffer.MatricesIndicesExtraKind
  24256. * - VertexBuffer.MatricesWeightsKind
  24257. * - VertexBuffer.MatricesWeightsExtraKind
  24258. * @returns an array of strings
  24259. */
  24260. getVerticesDataKinds(): string[];
  24261. /**
  24262. * Returns a positive integer : the total number of indices in this mesh geometry.
  24263. * @returns the numner of indices or zero if the mesh has no geometry.
  24264. */
  24265. getTotalIndices(): number;
  24266. /**
  24267. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24268. * @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.
  24269. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24270. * @returns the indices array or an empty array if the mesh has no geometry
  24271. */
  24272. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24273. readonly isBlocked: boolean;
  24274. /**
  24275. * Determine if the current mesh is ready to be rendered
  24276. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24277. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24278. * @returns true if all associated assets are ready (material, textures, shaders)
  24279. */
  24280. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24281. /**
  24282. * 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.
  24283. */
  24284. readonly areNormalsFrozen: boolean;
  24285. /**
  24286. * 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.
  24287. * @returns the current mesh
  24288. */
  24289. freezeNormals(): Mesh;
  24290. /**
  24291. * 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
  24292. * @returns the current mesh
  24293. */
  24294. unfreezeNormals(): Mesh;
  24295. /**
  24296. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24297. */
  24298. overridenInstanceCount: number;
  24299. /** @hidden */
  24300. _preActivate(): Mesh;
  24301. /** @hidden */
  24302. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24303. /** @hidden */
  24304. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24305. /**
  24306. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24307. * This means the mesh underlying bounding box and sphere are recomputed.
  24308. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24309. * @returns the current mesh
  24310. */
  24311. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24312. /** @hidden */
  24313. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24314. /**
  24315. * This function will subdivide the mesh into multiple submeshes
  24316. * @param count defines the expected number of submeshes
  24317. */
  24318. subdivide(count: number): void;
  24319. /**
  24320. * Copy a FloatArray into a specific associated vertex buffer
  24321. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24322. * - VertexBuffer.PositionKind
  24323. * - VertexBuffer.UVKind
  24324. * - VertexBuffer.UV2Kind
  24325. * - VertexBuffer.UV3Kind
  24326. * - VertexBuffer.UV4Kind
  24327. * - VertexBuffer.UV5Kind
  24328. * - VertexBuffer.UV6Kind
  24329. * - VertexBuffer.ColorKind
  24330. * - VertexBuffer.MatricesIndicesKind
  24331. * - VertexBuffer.MatricesIndicesExtraKind
  24332. * - VertexBuffer.MatricesWeightsKind
  24333. * - VertexBuffer.MatricesWeightsExtraKind
  24334. * @param data defines the data source
  24335. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24336. * @param stride defines the data stride size (can be null)
  24337. * @returns the current mesh
  24338. */
  24339. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24340. /**
  24341. * Flags an associated vertex buffer as updatable
  24342. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24343. * - VertexBuffer.PositionKind
  24344. * - VertexBuffer.UVKind
  24345. * - VertexBuffer.UV2Kind
  24346. * - VertexBuffer.UV3Kind
  24347. * - VertexBuffer.UV4Kind
  24348. * - VertexBuffer.UV5Kind
  24349. * - VertexBuffer.UV6Kind
  24350. * - VertexBuffer.ColorKind
  24351. * - VertexBuffer.MatricesIndicesKind
  24352. * - VertexBuffer.MatricesIndicesExtraKind
  24353. * - VertexBuffer.MatricesWeightsKind
  24354. * - VertexBuffer.MatricesWeightsExtraKind
  24355. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24356. */
  24357. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24358. /**
  24359. * Sets the mesh global Vertex Buffer
  24360. * @param buffer defines the buffer to use
  24361. * @returns the current mesh
  24362. */
  24363. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24364. /**
  24365. * Update a specific associated vertex buffer
  24366. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24367. * - VertexBuffer.PositionKind
  24368. * - VertexBuffer.UVKind
  24369. * - VertexBuffer.UV2Kind
  24370. * - VertexBuffer.UV3Kind
  24371. * - VertexBuffer.UV4Kind
  24372. * - VertexBuffer.UV5Kind
  24373. * - VertexBuffer.UV6Kind
  24374. * - VertexBuffer.ColorKind
  24375. * - VertexBuffer.MatricesIndicesKind
  24376. * - VertexBuffer.MatricesIndicesExtraKind
  24377. * - VertexBuffer.MatricesWeightsKind
  24378. * - VertexBuffer.MatricesWeightsExtraKind
  24379. * @param data defines the data source
  24380. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24381. * @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)
  24382. * @returns the current mesh
  24383. */
  24384. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24385. /**
  24386. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24387. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24388. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24389. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24390. * @returns the current mesh
  24391. */
  24392. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24393. /**
  24394. * Creates a un-shared specific occurence of the geometry for the mesh.
  24395. * @returns the current mesh
  24396. */
  24397. makeGeometryUnique(): Mesh;
  24398. /**
  24399. * Set the index buffer of this mesh
  24400. * @param indices defines the source data
  24401. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24402. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24403. * @returns the current mesh
  24404. */
  24405. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24406. /**
  24407. * Update the current index buffer
  24408. * @param indices defines the source data
  24409. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24410. * @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)
  24411. * @returns the current mesh
  24412. */
  24413. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24414. /**
  24415. * Invert the geometry to move from a right handed system to a left handed one.
  24416. * @returns the current mesh
  24417. */
  24418. toLeftHanded(): Mesh;
  24419. /** @hidden */
  24420. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24421. /** @hidden */
  24422. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24423. /**
  24424. * Registers for this mesh a javascript function called just before the rendering process
  24425. * @param func defines the function to call before rendering this mesh
  24426. * @returns the current mesh
  24427. */
  24428. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24429. /**
  24430. * Disposes a previously registered javascript function called before the rendering
  24431. * @param func defines the function to remove
  24432. * @returns the current mesh
  24433. */
  24434. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24435. /**
  24436. * Registers for this mesh a javascript function called just after the rendering is complete
  24437. * @param func defines the function to call after rendering this mesh
  24438. * @returns the current mesh
  24439. */
  24440. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24441. /**
  24442. * Disposes a previously registered javascript function called after the rendering.
  24443. * @param func defines the function to remove
  24444. * @returns the current mesh
  24445. */
  24446. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24447. /** @hidden */
  24448. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24449. /** @hidden */
  24450. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24451. /** @hidden */
  24452. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24453. /** @hidden */
  24454. _rebuild(): void;
  24455. /** @hidden */
  24456. _freeze(): void;
  24457. /** @hidden */
  24458. _unFreeze(): void;
  24459. /**
  24460. * 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
  24461. * @param subMesh defines the subMesh to render
  24462. * @param enableAlphaMode defines if alpha mode can be changed
  24463. * @returns the current mesh
  24464. */
  24465. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24466. private _onBeforeDraw;
  24467. /**
  24468. * Renormalize the mesh and patch it up if there are no weights
  24469. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24470. * However in the case of zero weights then we set just a single influence to 1.
  24471. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24472. */
  24473. cleanMatrixWeights(): void;
  24474. private normalizeSkinFourWeights;
  24475. private normalizeSkinWeightsAndExtra;
  24476. /**
  24477. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24478. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24479. * the user know there was an issue with importing the mesh
  24480. * @returns a validation object with skinned, valid and report string
  24481. */
  24482. validateSkinning(): {
  24483. skinned: boolean;
  24484. valid: boolean;
  24485. report: string;
  24486. };
  24487. /** @hidden */
  24488. _checkDelayState(): Mesh;
  24489. private _queueLoad;
  24490. /**
  24491. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24492. * A mesh is in the frustum if its bounding box intersects the frustum
  24493. * @param frustumPlanes defines the frustum to test
  24494. * @returns true if the mesh is in the frustum planes
  24495. */
  24496. isInFrustum(frustumPlanes: Plane[]): boolean;
  24497. /**
  24498. * Sets the mesh material by the material or multiMaterial `id` property
  24499. * @param id is a string identifying the material or the multiMaterial
  24500. * @returns the current mesh
  24501. */
  24502. setMaterialByID(id: string): Mesh;
  24503. /**
  24504. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24505. * @returns an array of IAnimatable
  24506. */
  24507. getAnimatables(): IAnimatable[];
  24508. /**
  24509. * Modifies the mesh geometry according to the passed transformation matrix.
  24510. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24511. * The mesh normals are modified using the same transformation.
  24512. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24513. * @param transform defines the transform matrix to use
  24514. * @see http://doc.babylonjs.com/resources/baking_transformations
  24515. * @returns the current mesh
  24516. */
  24517. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24518. /**
  24519. * Modifies the mesh geometry according to its own current World Matrix.
  24520. * The mesh World Matrix is then reset.
  24521. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24522. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24523. * @see http://doc.babylonjs.com/resources/baking_transformations
  24524. * @returns the current mesh
  24525. */
  24526. bakeCurrentTransformIntoVertices(): Mesh;
  24527. /** @hidden */
  24528. readonly _positions: Nullable<Vector3[]>;
  24529. /** @hidden */
  24530. _resetPointsArrayCache(): Mesh;
  24531. /** @hidden */
  24532. _generatePointsArray(): boolean;
  24533. /**
  24534. * Returns a new Mesh object generated from the current mesh properties.
  24535. * This method must not get confused with createInstance()
  24536. * @param name is a string, the name given to the new mesh
  24537. * @param newParent can be any Node object (default `null`)
  24538. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24539. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24540. * @returns a new mesh
  24541. */
  24542. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24543. /**
  24544. * Releases resources associated with this mesh.
  24545. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24546. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24547. */
  24548. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24549. /**
  24550. * Modifies the mesh geometry according to a displacement map.
  24551. * 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.
  24552. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24553. * @param url is a string, the URL from the image file is to be downloaded.
  24554. * @param minHeight is the lower limit of the displacement.
  24555. * @param maxHeight is the upper limit of the displacement.
  24556. * @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.
  24557. * @param uvOffset is an optional vector2 used to offset UV.
  24558. * @param uvScale is an optional vector2 used to scale UV.
  24559. * @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.
  24560. * @returns the Mesh.
  24561. */
  24562. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24563. /**
  24564. * Modifies the mesh geometry according to a displacementMap buffer.
  24565. * 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.
  24566. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24567. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24568. * @param heightMapWidth is the width of the buffer image.
  24569. * @param heightMapHeight is the height of the buffer image.
  24570. * @param minHeight is the lower limit of the displacement.
  24571. * @param maxHeight is the upper limit of the displacement.
  24572. * @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.
  24573. * @param uvOffset is an optional vector2 used to offset UV.
  24574. * @param uvScale is an optional vector2 used to scale UV.
  24575. * @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.
  24576. * @returns the Mesh.
  24577. */
  24578. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24579. /**
  24580. * Modify the mesh to get a flat shading rendering.
  24581. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24582. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24583. * @returns current mesh
  24584. */
  24585. convertToFlatShadedMesh(): Mesh;
  24586. /**
  24587. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24588. * In other words, more vertices, no more indices and a single bigger VBO.
  24589. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24590. * @returns current mesh
  24591. */
  24592. convertToUnIndexedMesh(): Mesh;
  24593. /**
  24594. * Inverses facet orientations.
  24595. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24596. * @param flipNormals will also inverts the normals
  24597. * @returns current mesh
  24598. */
  24599. flipFaces(flipNormals?: boolean): Mesh;
  24600. /**
  24601. * Increase the number of facets and hence vertices in a mesh
  24602. * Vertex normals are interpolated from existing vertex normals
  24603. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24604. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24605. */
  24606. increaseVertices(numberPerEdge: number): void;
  24607. /**
  24608. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24609. * This will undo any application of covertToFlatShadedMesh
  24610. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24611. */
  24612. forceSharedVertices(): void;
  24613. /** @hidden */
  24614. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24615. /** @hidden */
  24616. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24617. /**
  24618. * Creates a new InstancedMesh object from the mesh model.
  24619. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24620. * @param name defines the name of the new instance
  24621. * @returns a new InstancedMesh
  24622. */
  24623. createInstance(name: string): InstancedMesh;
  24624. /**
  24625. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24626. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24627. * @returns the current mesh
  24628. */
  24629. synchronizeInstances(): Mesh;
  24630. /**
  24631. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24632. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24633. * This should be used together with the simplification to avoid disappearing triangles.
  24634. * @param successCallback an optional success callback to be called after the optimization finished.
  24635. * @returns the current mesh
  24636. */
  24637. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24638. /**
  24639. * Serialize current mesh
  24640. * @param serializationObject defines the object which will receive the serialization data
  24641. */
  24642. serialize(serializationObject: any): void;
  24643. /** @hidden */
  24644. _syncGeometryWithMorphTargetManager(): void;
  24645. /** @hidden */
  24646. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24647. /**
  24648. * Returns a new Mesh object parsed from the source provided.
  24649. * @param parsedMesh is the source
  24650. * @param scene defines the hosting scene
  24651. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24652. * @returns a new Mesh
  24653. */
  24654. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24655. /**
  24656. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24657. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24658. * @param name defines the name of the mesh to create
  24659. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24660. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24661. * @param closePath creates a seam between the first and the last points of each path of the path array
  24662. * @param offset is taken in account only if the `pathArray` is containing a single path
  24663. * @param scene defines the hosting scene
  24664. * @param updatable defines if the mesh must be flagged as updatable
  24665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24666. * @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)
  24667. * @returns a new Mesh
  24668. */
  24669. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24670. /**
  24671. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24672. * @param name defines the name of the mesh to create
  24673. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24674. * @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
  24675. * @param scene defines the hosting scene
  24676. * @param updatable defines if the mesh must be flagged as updatable
  24677. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24678. * @returns a new Mesh
  24679. */
  24680. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24681. /**
  24682. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24683. * @param name defines the name of the mesh to create
  24684. * @param size sets the size (float) of each box side (default 1)
  24685. * @param scene defines the hosting scene
  24686. * @param updatable defines if the mesh must be flagged as updatable
  24687. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24688. * @returns a new Mesh
  24689. */
  24690. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24691. /**
  24692. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24693. * @param name defines the name of the mesh to create
  24694. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24695. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24696. * @param scene defines the hosting scene
  24697. * @param updatable defines if the mesh must be flagged as updatable
  24698. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24699. * @returns a new Mesh
  24700. */
  24701. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24702. /**
  24703. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24704. * @param name defines the name of the mesh to create
  24705. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24706. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24707. * @param scene defines the hosting scene
  24708. * @returns a new Mesh
  24709. */
  24710. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24711. /**
  24712. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24713. * @param name defines the name of the mesh to create
  24714. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24715. * @param diameterTop set the top cap diameter (floats, default 1)
  24716. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24717. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24718. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24719. * @param scene defines the hosting scene
  24720. * @param updatable defines if the mesh must be flagged as updatable
  24721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24722. * @returns a new Mesh
  24723. */
  24724. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24725. /**
  24726. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24727. * @param name defines the name of the mesh to create
  24728. * @param diameter sets the diameter size (float) of the torus (default 1)
  24729. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24730. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24731. * @param scene defines the hosting scene
  24732. * @param updatable defines if the mesh must be flagged as updatable
  24733. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24734. * @returns a new Mesh
  24735. */
  24736. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24737. /**
  24738. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24739. * @param name defines the name of the mesh to create
  24740. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24741. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24742. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24743. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24744. * @param p the number of windings on X axis (positive integers, default 2)
  24745. * @param q the number of windings on Y axis (positive integers, default 3)
  24746. * @param scene defines the hosting scene
  24747. * @param updatable defines if the mesh must be flagged as updatable
  24748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24749. * @returns a new Mesh
  24750. */
  24751. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24752. /**
  24753. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24754. * @param name defines the name of the mesh to create
  24755. * @param points is an array successive Vector3
  24756. * @param scene defines the hosting scene
  24757. * @param updatable defines if the mesh must be flagged as updatable
  24758. * @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).
  24759. * @returns a new Mesh
  24760. */
  24761. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24762. /**
  24763. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24764. * @param name defines the name of the mesh to create
  24765. * @param points is an array successive Vector3
  24766. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24767. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24768. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24769. * @param scene defines the hosting scene
  24770. * @param updatable defines if the mesh must be flagged as updatable
  24771. * @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)
  24772. * @returns a new Mesh
  24773. */
  24774. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24775. /**
  24776. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24777. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24778. * 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.
  24779. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24780. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24781. * Remember you can only change the shape positions, not their number when updating a polygon.
  24782. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24783. * @param name defines the name of the mesh to create
  24784. * @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
  24785. * @param scene defines the hosting scene
  24786. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24787. * @param updatable defines if the mesh must be flagged as updatable
  24788. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24789. * @param earcutInjection can be used to inject your own earcut reference
  24790. * @returns a new Mesh
  24791. */
  24792. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24793. /**
  24794. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24795. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24796. * @param name defines the name of the mesh to create
  24797. * @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
  24798. * @param depth defines the height of extrusion
  24799. * @param scene defines the hosting scene
  24800. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24801. * @param updatable defines if the mesh must be flagged as updatable
  24802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24803. * @param earcutInjection can be used to inject your own earcut reference
  24804. * @returns a new Mesh
  24805. */
  24806. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24807. /**
  24808. * Creates an extruded shape mesh.
  24809. * 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
  24810. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24811. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24812. * @param name defines the name of the mesh to create
  24813. * @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
  24814. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24815. * @param scale is the value to scale the shape
  24816. * @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
  24817. * @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
  24818. * @param scene defines the hosting scene
  24819. * @param updatable defines if the mesh must be flagged as updatable
  24820. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24821. * @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)
  24822. * @returns a new Mesh
  24823. */
  24824. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24825. /**
  24826. * Creates an custom extruded shape mesh.
  24827. * The custom extrusion is a parametric shape.
  24828. * It has no predefined shape. Its final shape will depend on the input parameters.
  24829. * Please consider using the same method from the MeshBuilder class instead
  24830. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24831. * @param name defines the name of the mesh to create
  24832. * @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
  24833. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24834. * @param scaleFunction is a custom Javascript function called on each path point
  24835. * @param rotationFunction is a custom Javascript function called on each path point
  24836. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24837. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24838. * @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
  24839. * @param scene defines the hosting scene
  24840. * @param updatable defines if the mesh must be flagged as updatable
  24841. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24842. * @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)
  24843. * @returns a new Mesh
  24844. */
  24845. 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;
  24846. /**
  24847. * Creates lathe mesh.
  24848. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24849. * Please consider using the same method from the MeshBuilder class instead
  24850. * @param name defines the name of the mesh to create
  24851. * @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
  24852. * @param radius is the radius value of the lathe
  24853. * @param tessellation is the side number of the lathe.
  24854. * @param scene defines the hosting scene
  24855. * @param updatable defines if the mesh must be flagged as updatable
  24856. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24857. * @returns a new Mesh
  24858. */
  24859. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24860. /**
  24861. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24862. * @param name defines the name of the mesh to create
  24863. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24864. * @param scene defines the hosting scene
  24865. * @param updatable defines if the mesh must be flagged as updatable
  24866. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24867. * @returns a new Mesh
  24868. */
  24869. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24870. /**
  24871. * Creates a ground mesh.
  24872. * Please consider using the same method from the MeshBuilder class instead
  24873. * @param name defines the name of the mesh to create
  24874. * @param width set the width of the ground
  24875. * @param height set the height of the ground
  24876. * @param subdivisions sets the number of subdivisions per side
  24877. * @param scene defines the hosting scene
  24878. * @param updatable defines if the mesh must be flagged as updatable
  24879. * @returns a new Mesh
  24880. */
  24881. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24882. /**
  24883. * Creates a tiled ground mesh.
  24884. * Please consider using the same method from the MeshBuilder class instead
  24885. * @param name defines the name of the mesh to create
  24886. * @param xmin set the ground minimum X coordinate
  24887. * @param zmin set the ground minimum Y coordinate
  24888. * @param xmax set the ground maximum X coordinate
  24889. * @param zmax set the ground maximum Z coordinate
  24890. * @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
  24891. * @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
  24892. * @param scene defines the hosting scene
  24893. * @param updatable defines if the mesh must be flagged as updatable
  24894. * @returns a new Mesh
  24895. */
  24896. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24897. w: number;
  24898. h: number;
  24899. }, precision: {
  24900. w: number;
  24901. h: number;
  24902. }, scene: Scene, updatable?: boolean): Mesh;
  24903. /**
  24904. * Creates a ground mesh from a height map.
  24905. * Please consider using the same method from the MeshBuilder class instead
  24906. * @see http://doc.babylonjs.com/babylon101/height_map
  24907. * @param name defines the name of the mesh to create
  24908. * @param url sets the URL of the height map image resource
  24909. * @param width set the ground width size
  24910. * @param height set the ground height size
  24911. * @param subdivisions sets the number of subdivision per side
  24912. * @param minHeight is the minimum altitude on the ground
  24913. * @param maxHeight is the maximum altitude on the ground
  24914. * @param scene defines the hosting scene
  24915. * @param updatable defines if the mesh must be flagged as updatable
  24916. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24917. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24918. * @returns a new Mesh
  24919. */
  24920. 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;
  24921. /**
  24922. * Creates a tube mesh.
  24923. * The tube is a parametric shape.
  24924. * It has no predefined shape. Its final shape will depend on the input parameters.
  24925. * Please consider using the same method from the MeshBuilder class instead
  24926. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24927. * @param name defines the name of the mesh to create
  24928. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24929. * @param radius sets the tube radius size
  24930. * @param tessellation is the number of sides on the tubular surface
  24931. * @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
  24932. * @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
  24933. * @param scene defines the hosting scene
  24934. * @param updatable defines if the mesh must be flagged as updatable
  24935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24936. * @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)
  24937. * @returns a new Mesh
  24938. */
  24939. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24940. (i: number, distance: number): number;
  24941. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24942. /**
  24943. * Creates a polyhedron mesh.
  24944. * Please consider using the same method from the MeshBuilder class instead.
  24945. * * 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
  24946. * * The parameter `size` (positive float, default 1) sets the polygon size
  24947. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24948. * * 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`
  24949. * * 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
  24950. * * 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)`)
  24951. * * 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
  24952. * * 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
  24953. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24954. * * If you create a double-sided mesh, you can choose what parts of 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
  24955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24956. * @param name defines the name of the mesh to create
  24957. * @param options defines the options used to create the mesh
  24958. * @param scene defines the hosting scene
  24959. * @returns a new Mesh
  24960. */
  24961. static CreatePolyhedron(name: string, options: {
  24962. type?: number;
  24963. size?: number;
  24964. sizeX?: number;
  24965. sizeY?: number;
  24966. sizeZ?: number;
  24967. custom?: any;
  24968. faceUV?: Vector4[];
  24969. faceColors?: Color4[];
  24970. updatable?: boolean;
  24971. sideOrientation?: number;
  24972. }, scene: Scene): Mesh;
  24973. /**
  24974. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24975. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24976. * * 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`)
  24977. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24978. * * 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
  24979. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24980. * * If you create a double-sided mesh, you can choose what parts of 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
  24981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24982. * @param name defines the name of the mesh
  24983. * @param options defines the options used to create the mesh
  24984. * @param scene defines the hosting scene
  24985. * @returns a new Mesh
  24986. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24987. */
  24988. static CreateIcoSphere(name: string, options: {
  24989. radius?: number;
  24990. flat?: boolean;
  24991. subdivisions?: number;
  24992. sideOrientation?: number;
  24993. updatable?: boolean;
  24994. }, scene: Scene): Mesh;
  24995. /**
  24996. * Creates a decal mesh.
  24997. * Please consider using the same method from the MeshBuilder class instead.
  24998. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24999. * @param name defines the name of the mesh
  25000. * @param sourceMesh defines the mesh receiving the decal
  25001. * @param position sets the position of the decal in world coordinates
  25002. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25003. * @param size sets the decal scaling
  25004. * @param angle sets the angle to rotate the decal
  25005. * @returns a new Mesh
  25006. */
  25007. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25008. /**
  25009. * Prepare internal position array for software CPU skinning
  25010. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25011. */
  25012. setPositionsForCPUSkinning(): Float32Array;
  25013. /**
  25014. * Prepare internal normal array for software CPU skinning
  25015. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25016. */
  25017. setNormalsForCPUSkinning(): Float32Array;
  25018. /**
  25019. * Updates the vertex buffer by applying transformation from the bones
  25020. * @param skeleton defines the skeleton to apply to current mesh
  25021. * @returns the current mesh
  25022. */
  25023. applySkeleton(skeleton: Skeleton): Mesh;
  25024. /**
  25025. * 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
  25026. * @param meshes defines the list of meshes to scan
  25027. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25028. */
  25029. static MinMax(meshes: AbstractMesh[]): {
  25030. min: Vector3;
  25031. max: Vector3;
  25032. };
  25033. /**
  25034. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25035. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25036. * @returns a vector3
  25037. */
  25038. static Center(meshesOrMinMaxVector: {
  25039. min: Vector3;
  25040. max: Vector3;
  25041. } | AbstractMesh[]): Vector3;
  25042. /**
  25043. * Merge the array of meshes into a single mesh for performance reasons.
  25044. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25045. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25046. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25047. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25048. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25049. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25050. * @returns a new mesh
  25051. */
  25052. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25053. /** @hidden */
  25054. addInstance(instance: InstancedMesh): void;
  25055. /** @hidden */
  25056. removeInstance(instance: InstancedMesh): void;
  25057. }
  25058. }
  25059. declare module "babylonjs/Cameras/camera" {
  25060. import { SmartArray } from "babylonjs/Misc/smartArray";
  25061. import { Observable } from "babylonjs/Misc/observable";
  25062. import { Nullable } from "babylonjs/types";
  25063. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25064. import { Scene } from "babylonjs/scene";
  25065. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25066. import { Node } from "babylonjs/node";
  25067. import { Mesh } from "babylonjs/Meshes/mesh";
  25068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25069. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25070. import { Viewport } from "babylonjs/Maths/math.viewport";
  25071. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25072. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25074. import { Ray } from "babylonjs/Culling/ray";
  25075. /**
  25076. * This is the base class of all the camera used in the application.
  25077. * @see http://doc.babylonjs.com/features/cameras
  25078. */
  25079. export class Camera extends Node {
  25080. /** @hidden */
  25081. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25082. /**
  25083. * This is the default projection mode used by the cameras.
  25084. * It helps recreating a feeling of perspective and better appreciate depth.
  25085. * This is the best way to simulate real life cameras.
  25086. */
  25087. static readonly PERSPECTIVE_CAMERA: number;
  25088. /**
  25089. * This helps creating camera with an orthographic mode.
  25090. * 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.
  25091. */
  25092. static readonly ORTHOGRAPHIC_CAMERA: number;
  25093. /**
  25094. * This is the default FOV mode for perspective cameras.
  25095. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25096. */
  25097. static readonly FOVMODE_VERTICAL_FIXED: number;
  25098. /**
  25099. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25100. */
  25101. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25102. /**
  25103. * This specifies ther is no need for a camera rig.
  25104. * Basically only one eye is rendered corresponding to the camera.
  25105. */
  25106. static readonly RIG_MODE_NONE: number;
  25107. /**
  25108. * Simulates a camera Rig with one blue eye and one red eye.
  25109. * This can be use with 3d blue and red glasses.
  25110. */
  25111. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25112. /**
  25113. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25114. */
  25115. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25116. /**
  25117. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25118. */
  25119. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25120. /**
  25121. * Defines that both eyes of the camera will be rendered over under each other.
  25122. */
  25123. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25124. /**
  25125. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25126. */
  25127. static readonly RIG_MODE_VR: number;
  25128. /**
  25129. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25130. */
  25131. static readonly RIG_MODE_WEBVR: number;
  25132. /**
  25133. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25134. */
  25135. static readonly RIG_MODE_CUSTOM: number;
  25136. /**
  25137. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25138. */
  25139. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25140. /**
  25141. * Define the input manager associated with the camera.
  25142. */
  25143. inputs: CameraInputsManager<Camera>;
  25144. /** @hidden */
  25145. _position: Vector3;
  25146. /**
  25147. * Define the current local position of the camera in the scene
  25148. */
  25149. position: Vector3;
  25150. /**
  25151. * The vector the camera should consider as up.
  25152. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25153. */
  25154. upVector: Vector3;
  25155. /**
  25156. * Define the current limit on the left side for an orthographic camera
  25157. * In scene unit
  25158. */
  25159. orthoLeft: Nullable<number>;
  25160. /**
  25161. * Define the current limit on the right side for an orthographic camera
  25162. * In scene unit
  25163. */
  25164. orthoRight: Nullable<number>;
  25165. /**
  25166. * Define the current limit on the bottom side for an orthographic camera
  25167. * In scene unit
  25168. */
  25169. orthoBottom: Nullable<number>;
  25170. /**
  25171. * Define the current limit on the top side for an orthographic camera
  25172. * In scene unit
  25173. */
  25174. orthoTop: Nullable<number>;
  25175. /**
  25176. * Field Of View is set in Radians. (default is 0.8)
  25177. */
  25178. fov: number;
  25179. /**
  25180. * Define the minimum distance the camera can see from.
  25181. * This is important to note that the depth buffer are not infinite and the closer it starts
  25182. * the more your scene might encounter depth fighting issue.
  25183. */
  25184. minZ: number;
  25185. /**
  25186. * Define the maximum distance the camera can see to.
  25187. * This is important to note that the depth buffer are not infinite and the further it end
  25188. * the more your scene might encounter depth fighting issue.
  25189. */
  25190. maxZ: number;
  25191. /**
  25192. * Define the default inertia of the camera.
  25193. * This helps giving a smooth feeling to the camera movement.
  25194. */
  25195. inertia: number;
  25196. /**
  25197. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25198. */
  25199. mode: number;
  25200. /**
  25201. * Define wether the camera is intermediate.
  25202. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25203. */
  25204. isIntermediate: boolean;
  25205. /**
  25206. * Define the viewport of the camera.
  25207. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25208. */
  25209. viewport: Viewport;
  25210. /**
  25211. * Restricts the camera to viewing objects with the same layerMask.
  25212. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25213. */
  25214. layerMask: number;
  25215. /**
  25216. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25217. */
  25218. fovMode: number;
  25219. /**
  25220. * Rig mode of the camera.
  25221. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25222. * This is normally controlled byt the camera themselves as internal use.
  25223. */
  25224. cameraRigMode: number;
  25225. /**
  25226. * Defines the distance between both "eyes" in case of a RIG
  25227. */
  25228. interaxialDistance: number;
  25229. /**
  25230. * Defines if stereoscopic rendering is done side by side or over under.
  25231. */
  25232. isStereoscopicSideBySide: boolean;
  25233. /**
  25234. * 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
  25235. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25236. * else in the scene. (Eg. security camera)
  25237. *
  25238. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25239. */
  25240. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25241. /**
  25242. * When set, the camera will render to this render target instead of the default canvas
  25243. *
  25244. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25245. */
  25246. outputRenderTarget: Nullable<RenderTargetTexture>;
  25247. /**
  25248. * Observable triggered when the camera view matrix has changed.
  25249. */
  25250. onViewMatrixChangedObservable: Observable<Camera>;
  25251. /**
  25252. * Observable triggered when the camera Projection matrix has changed.
  25253. */
  25254. onProjectionMatrixChangedObservable: Observable<Camera>;
  25255. /**
  25256. * Observable triggered when the inputs have been processed.
  25257. */
  25258. onAfterCheckInputsObservable: Observable<Camera>;
  25259. /**
  25260. * Observable triggered when reset has been called and applied to the camera.
  25261. */
  25262. onRestoreStateObservable: Observable<Camera>;
  25263. /** @hidden */
  25264. _cameraRigParams: any;
  25265. /** @hidden */
  25266. _rigCameras: Camera[];
  25267. /** @hidden */
  25268. _rigPostProcess: Nullable<PostProcess>;
  25269. protected _webvrViewMatrix: Matrix;
  25270. /** @hidden */
  25271. _skipRendering: boolean;
  25272. /** @hidden */
  25273. _projectionMatrix: Matrix;
  25274. /** @hidden */
  25275. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25276. /** @hidden */
  25277. _activeMeshes: SmartArray<AbstractMesh>;
  25278. protected _globalPosition: Vector3;
  25279. /** @hidden */
  25280. _computedViewMatrix: Matrix;
  25281. private _doNotComputeProjectionMatrix;
  25282. private _transformMatrix;
  25283. private _frustumPlanes;
  25284. private _refreshFrustumPlanes;
  25285. private _storedFov;
  25286. private _stateStored;
  25287. /**
  25288. * Instantiates a new camera object.
  25289. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25290. * @see http://doc.babylonjs.com/features/cameras
  25291. * @param name Defines the name of the camera in the scene
  25292. * @param position Defines the position of the camera
  25293. * @param scene Defines the scene the camera belongs too
  25294. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25295. */
  25296. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25297. /**
  25298. * Store current camera state (fov, position, etc..)
  25299. * @returns the camera
  25300. */
  25301. storeState(): Camera;
  25302. /**
  25303. * Restores the camera state values if it has been stored. You must call storeState() first
  25304. */
  25305. protected _restoreStateValues(): boolean;
  25306. /**
  25307. * Restored camera state. You must call storeState() first.
  25308. * @returns true if restored and false otherwise
  25309. */
  25310. restoreState(): boolean;
  25311. /**
  25312. * Gets the class name of the camera.
  25313. * @returns the class name
  25314. */
  25315. getClassName(): string;
  25316. /** @hidden */
  25317. readonly _isCamera: boolean;
  25318. /**
  25319. * Gets a string representation of the camera useful for debug purpose.
  25320. * @param fullDetails Defines that a more verboe level of logging is required
  25321. * @returns the string representation
  25322. */
  25323. toString(fullDetails?: boolean): string;
  25324. /**
  25325. * Gets the current world space position of the camera.
  25326. */
  25327. readonly globalPosition: Vector3;
  25328. /**
  25329. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25330. * @returns the active meshe list
  25331. */
  25332. getActiveMeshes(): SmartArray<AbstractMesh>;
  25333. /**
  25334. * Check wether a mesh is part of the current active mesh list of the camera
  25335. * @param mesh Defines the mesh to check
  25336. * @returns true if active, false otherwise
  25337. */
  25338. isActiveMesh(mesh: Mesh): boolean;
  25339. /**
  25340. * Is this camera ready to be used/rendered
  25341. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25342. * @return true if the camera is ready
  25343. */
  25344. isReady(completeCheck?: boolean): boolean;
  25345. /** @hidden */
  25346. _initCache(): void;
  25347. /** @hidden */
  25348. _updateCache(ignoreParentClass?: boolean): void;
  25349. /** @hidden */
  25350. _isSynchronized(): boolean;
  25351. /** @hidden */
  25352. _isSynchronizedViewMatrix(): boolean;
  25353. /** @hidden */
  25354. _isSynchronizedProjectionMatrix(): boolean;
  25355. /**
  25356. * Attach the input controls to a specific dom element to get the input from.
  25357. * @param element Defines the element the controls should be listened from
  25358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25359. */
  25360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25361. /**
  25362. * Detach the current controls from the specified dom element.
  25363. * @param element Defines the element to stop listening the inputs from
  25364. */
  25365. detachControl(element: HTMLElement): void;
  25366. /**
  25367. * Update the camera state according to the different inputs gathered during the frame.
  25368. */
  25369. update(): void;
  25370. /** @hidden */
  25371. _checkInputs(): void;
  25372. /** @hidden */
  25373. readonly rigCameras: Camera[];
  25374. /**
  25375. * Gets the post process used by the rig cameras
  25376. */
  25377. readonly rigPostProcess: Nullable<PostProcess>;
  25378. /**
  25379. * Internal, gets the first post proces.
  25380. * @returns the first post process to be run on this camera.
  25381. */
  25382. _getFirstPostProcess(): Nullable<PostProcess>;
  25383. private _cascadePostProcessesToRigCams;
  25384. /**
  25385. * Attach a post process to the camera.
  25386. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25387. * @param postProcess The post process to attach to the camera
  25388. * @param insertAt The position of the post process in case several of them are in use in the scene
  25389. * @returns the position the post process has been inserted at
  25390. */
  25391. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25392. /**
  25393. * Detach a post process to the camera.
  25394. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25395. * @param postProcess The post process to detach from the camera
  25396. */
  25397. detachPostProcess(postProcess: PostProcess): void;
  25398. /**
  25399. * Gets the current world matrix of the camera
  25400. */
  25401. getWorldMatrix(): Matrix;
  25402. /** @hidden */
  25403. _getViewMatrix(): Matrix;
  25404. /**
  25405. * Gets the current view matrix of the camera.
  25406. * @param force forces the camera to recompute the matrix without looking at the cached state
  25407. * @returns the view matrix
  25408. */
  25409. getViewMatrix(force?: boolean): Matrix;
  25410. /**
  25411. * Freeze the projection matrix.
  25412. * It will prevent the cache check of the camera projection compute and can speed up perf
  25413. * if no parameter of the camera are meant to change
  25414. * @param projection Defines manually a projection if necessary
  25415. */
  25416. freezeProjectionMatrix(projection?: Matrix): void;
  25417. /**
  25418. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25419. */
  25420. unfreezeProjectionMatrix(): void;
  25421. /**
  25422. * Gets the current projection matrix of the camera.
  25423. * @param force forces the camera to recompute the matrix without looking at the cached state
  25424. * @returns the projection matrix
  25425. */
  25426. getProjectionMatrix(force?: boolean): Matrix;
  25427. /**
  25428. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25429. * @returns a Matrix
  25430. */
  25431. getTransformationMatrix(): Matrix;
  25432. private _updateFrustumPlanes;
  25433. /**
  25434. * Checks if a cullable object (mesh...) is in the camera frustum
  25435. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25436. * @param target The object to check
  25437. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25438. * @returns true if the object is in frustum otherwise false
  25439. */
  25440. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25441. /**
  25442. * Checks if a cullable object (mesh...) is in the camera frustum
  25443. * Unlike isInFrustum this cheks the full bounding box
  25444. * @param target The object to check
  25445. * @returns true if the object is in frustum otherwise false
  25446. */
  25447. isCompletelyInFrustum(target: ICullable): boolean;
  25448. /**
  25449. * Gets a ray in the forward direction from the camera.
  25450. * @param length Defines the length of the ray to create
  25451. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25452. * @param origin Defines the start point of the ray which defaults to the camera position
  25453. * @returns the forward ray
  25454. */
  25455. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25456. /**
  25457. * Releases resources associated with this node.
  25458. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25459. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25460. */
  25461. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25462. /** @hidden */
  25463. _isLeftCamera: boolean;
  25464. /**
  25465. * Gets the left camera of a rig setup in case of Rigged Camera
  25466. */
  25467. readonly isLeftCamera: boolean;
  25468. /** @hidden */
  25469. _isRightCamera: boolean;
  25470. /**
  25471. * Gets the right camera of a rig setup in case of Rigged Camera
  25472. */
  25473. readonly isRightCamera: boolean;
  25474. /**
  25475. * Gets the left camera of a rig setup in case of Rigged Camera
  25476. */
  25477. readonly leftCamera: Nullable<FreeCamera>;
  25478. /**
  25479. * Gets the right camera of a rig setup in case of Rigged Camera
  25480. */
  25481. readonly rightCamera: Nullable<FreeCamera>;
  25482. /**
  25483. * Gets the left camera target of a rig setup in case of Rigged Camera
  25484. * @returns the target position
  25485. */
  25486. getLeftTarget(): Nullable<Vector3>;
  25487. /**
  25488. * Gets the right camera target of a rig setup in case of Rigged Camera
  25489. * @returns the target position
  25490. */
  25491. getRightTarget(): Nullable<Vector3>;
  25492. /**
  25493. * @hidden
  25494. */
  25495. setCameraRigMode(mode: number, rigParams: any): void;
  25496. /** @hidden */
  25497. static _setStereoscopicRigMode(camera: Camera): void;
  25498. /** @hidden */
  25499. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25500. /** @hidden */
  25501. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25502. /** @hidden */
  25503. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25504. /** @hidden */
  25505. _getVRProjectionMatrix(): Matrix;
  25506. protected _updateCameraRotationMatrix(): void;
  25507. protected _updateWebVRCameraRotationMatrix(): void;
  25508. /**
  25509. * This function MUST be overwritten by the different WebVR cameras available.
  25510. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25511. * @hidden
  25512. */
  25513. _getWebVRProjectionMatrix(): Matrix;
  25514. /**
  25515. * This function MUST be overwritten by the different WebVR cameras available.
  25516. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25517. * @hidden
  25518. */
  25519. _getWebVRViewMatrix(): Matrix;
  25520. /** @hidden */
  25521. setCameraRigParameter(name: string, value: any): void;
  25522. /**
  25523. * needs to be overridden by children so sub has required properties to be copied
  25524. * @hidden
  25525. */
  25526. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25527. /**
  25528. * May need to be overridden by children
  25529. * @hidden
  25530. */
  25531. _updateRigCameras(): void;
  25532. /** @hidden */
  25533. _setupInputs(): void;
  25534. /**
  25535. * Serialiaze the camera setup to a json represention
  25536. * @returns the JSON representation
  25537. */
  25538. serialize(): any;
  25539. /**
  25540. * Clones the current camera.
  25541. * @param name The cloned camera name
  25542. * @returns the cloned camera
  25543. */
  25544. clone(name: string): Camera;
  25545. /**
  25546. * Gets the direction of the camera relative to a given local axis.
  25547. * @param localAxis Defines the reference axis to provide a relative direction.
  25548. * @return the direction
  25549. */
  25550. getDirection(localAxis: Vector3): Vector3;
  25551. /**
  25552. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25553. * @param localAxis Defines the reference axis to provide a relative direction.
  25554. * @param result Defines the vector to store the result in
  25555. */
  25556. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25557. /**
  25558. * Gets a camera constructor for a given camera type
  25559. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25560. * @param name The name of the camera the result will be able to instantiate
  25561. * @param scene The scene the result will construct the camera in
  25562. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25563. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25564. * @returns a factory method to construc the camera
  25565. */
  25566. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25567. /**
  25568. * Compute the world matrix of the camera.
  25569. * @returns the camera workd matrix
  25570. */
  25571. computeWorldMatrix(): Matrix;
  25572. /**
  25573. * Parse a JSON and creates the camera from the parsed information
  25574. * @param parsedCamera The JSON to parse
  25575. * @param scene The scene to instantiate the camera in
  25576. * @returns the newly constructed camera
  25577. */
  25578. static Parse(parsedCamera: any, scene: Scene): Camera;
  25579. }
  25580. }
  25581. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25582. import { Nullable } from "babylonjs/types";
  25583. import { Scene } from "babylonjs/scene";
  25584. import { Vector4 } from "babylonjs/Maths/math.vector";
  25585. import { Mesh } from "babylonjs/Meshes/mesh";
  25586. /**
  25587. * Class containing static functions to help procedurally build meshes
  25588. */
  25589. export class DiscBuilder {
  25590. /**
  25591. * Creates a plane polygonal mesh. By default, this is a disc
  25592. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25593. * * 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
  25594. * * 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
  25595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25598. * @param name defines the name of the mesh
  25599. * @param options defines the options used to create the mesh
  25600. * @param scene defines the hosting scene
  25601. * @returns the plane polygonal mesh
  25602. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25603. */
  25604. static CreateDisc(name: string, options: {
  25605. radius?: number;
  25606. tessellation?: number;
  25607. arc?: number;
  25608. updatable?: boolean;
  25609. sideOrientation?: number;
  25610. frontUVs?: Vector4;
  25611. backUVs?: Vector4;
  25612. }, scene?: Nullable<Scene>): Mesh;
  25613. }
  25614. }
  25615. declare module "babylonjs/Particles/solidParticleSystem" {
  25616. import { Vector3 } from "babylonjs/Maths/math.vector";
  25617. import { Mesh } from "babylonjs/Meshes/mesh";
  25618. import { Scene, IDisposable } from "babylonjs/scene";
  25619. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25620. /**
  25621. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25622. *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.
  25623. * The SPS is also a particle system. It provides some methods to manage the particles.
  25624. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25625. *
  25626. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25627. */
  25628. export class SolidParticleSystem implements IDisposable {
  25629. /**
  25630. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25631. * Example : var p = SPS.particles[i];
  25632. */
  25633. particles: SolidParticle[];
  25634. /**
  25635. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25636. */
  25637. nbParticles: number;
  25638. /**
  25639. * If the particles must ever face the camera (default false). Useful for planar particles.
  25640. */
  25641. billboard: boolean;
  25642. /**
  25643. * Recompute normals when adding a shape
  25644. */
  25645. recomputeNormals: boolean;
  25646. /**
  25647. * This a counter ofr your own usage. It's not set by any SPS functions.
  25648. */
  25649. counter: number;
  25650. /**
  25651. * The SPS name. This name is also given to the underlying mesh.
  25652. */
  25653. name: string;
  25654. /**
  25655. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25656. */
  25657. mesh: Mesh;
  25658. /**
  25659. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25660. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25661. */
  25662. vars: any;
  25663. /**
  25664. * This array is populated when the SPS is set as 'pickable'.
  25665. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25666. * Each element of this array is an object `{idx: int, faceId: int}`.
  25667. * `idx` is the picked particle index in the `SPS.particles` array
  25668. * `faceId` is the picked face index counted within this particle.
  25669. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25670. */
  25671. pickedParticles: {
  25672. idx: number;
  25673. faceId: number;
  25674. }[];
  25675. /**
  25676. * This array is populated when `enableDepthSort` is set to true.
  25677. * Each element of this array is an instance of the class DepthSortedParticle.
  25678. */
  25679. depthSortedParticles: DepthSortedParticle[];
  25680. /**
  25681. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25682. * @hidden
  25683. */
  25684. _bSphereOnly: boolean;
  25685. /**
  25686. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25687. * @hidden
  25688. */
  25689. _bSphereRadiusFactor: number;
  25690. private _scene;
  25691. private _positions;
  25692. private _indices;
  25693. private _normals;
  25694. private _colors;
  25695. private _uvs;
  25696. private _indices32;
  25697. private _positions32;
  25698. private _normals32;
  25699. private _fixedNormal32;
  25700. private _colors32;
  25701. private _uvs32;
  25702. private _index;
  25703. private _updatable;
  25704. private _pickable;
  25705. private _isVisibilityBoxLocked;
  25706. private _alwaysVisible;
  25707. private _depthSort;
  25708. private _shapeCounter;
  25709. private _copy;
  25710. private _color;
  25711. private _computeParticleColor;
  25712. private _computeParticleTexture;
  25713. private _computeParticleRotation;
  25714. private _computeParticleVertex;
  25715. private _computeBoundingBox;
  25716. private _depthSortParticles;
  25717. private _camera;
  25718. private _mustUnrotateFixedNormals;
  25719. private _particlesIntersect;
  25720. private _needs32Bits;
  25721. /**
  25722. * Creates a SPS (Solid Particle System) object.
  25723. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25724. * @param scene (Scene) is the scene in which the SPS is added.
  25725. * @param options defines the options of the sps e.g.
  25726. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25727. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25728. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25729. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25730. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25731. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25732. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25733. */
  25734. constructor(name: string, scene: Scene, options?: {
  25735. updatable?: boolean;
  25736. isPickable?: boolean;
  25737. enableDepthSort?: boolean;
  25738. particleIntersection?: boolean;
  25739. boundingSphereOnly?: boolean;
  25740. bSphereRadiusFactor?: number;
  25741. });
  25742. /**
  25743. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25744. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25745. * @returns the created mesh
  25746. */
  25747. buildMesh(): Mesh;
  25748. /**
  25749. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25750. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25751. * Thus the particles generated from `digest()` have their property `position` set yet.
  25752. * @param mesh ( Mesh ) is the mesh to be digested
  25753. * @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
  25754. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25755. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25756. * @returns the current SPS
  25757. */
  25758. digest(mesh: Mesh, options?: {
  25759. facetNb?: number;
  25760. number?: number;
  25761. delta?: number;
  25762. }): SolidParticleSystem;
  25763. private _unrotateFixedNormals;
  25764. private _resetCopy;
  25765. private _meshBuilder;
  25766. private _posToShape;
  25767. private _uvsToShapeUV;
  25768. private _addParticle;
  25769. /**
  25770. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25771. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25772. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25773. * @param nb (positive integer) the number of particles to be created from this model
  25774. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25775. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25776. * @returns the number of shapes in the system
  25777. */
  25778. addShape(mesh: Mesh, nb: number, options?: {
  25779. positionFunction?: any;
  25780. vertexFunction?: any;
  25781. }): number;
  25782. private _rebuildParticle;
  25783. /**
  25784. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25785. * @returns the SPS.
  25786. */
  25787. rebuildMesh(): SolidParticleSystem;
  25788. /**
  25789. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25790. * This method calls `updateParticle()` for each particle of the SPS.
  25791. * For an animated SPS, it is usually called within the render loop.
  25792. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25793. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25794. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25795. * @returns the SPS.
  25796. */
  25797. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25798. /**
  25799. * Disposes the SPS.
  25800. */
  25801. dispose(): void;
  25802. /**
  25803. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25804. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25805. * @returns the SPS.
  25806. */
  25807. refreshVisibleSize(): SolidParticleSystem;
  25808. /**
  25809. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25810. * @param size the size (float) of the visibility box
  25811. * note : this doesn't lock the SPS mesh bounding box.
  25812. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25813. */
  25814. setVisibilityBox(size: number): void;
  25815. /**
  25816. * Gets whether the SPS as always visible or not
  25817. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25818. */
  25819. /**
  25820. * Sets the SPS as always visible or not
  25821. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25822. */
  25823. isAlwaysVisible: boolean;
  25824. /**
  25825. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25826. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25827. */
  25828. /**
  25829. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25830. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25831. */
  25832. isVisibilityBoxLocked: boolean;
  25833. /**
  25834. * Tells to `setParticles()` to compute the particle rotations or not.
  25835. * Default value : true. The SPS is faster when it's set to false.
  25836. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25837. */
  25838. /**
  25839. * Gets if `setParticles()` computes the particle rotations or not.
  25840. * Default value : true. The SPS is faster when it's set to false.
  25841. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25842. */
  25843. computeParticleRotation: boolean;
  25844. /**
  25845. * Tells to `setParticles()` to compute the particle colors or not.
  25846. * Default value : true. The SPS is faster when it's set to false.
  25847. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25848. */
  25849. /**
  25850. * Gets if `setParticles()` computes the particle colors or not.
  25851. * Default value : true. The SPS is faster when it's set to false.
  25852. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25853. */
  25854. computeParticleColor: boolean;
  25855. /**
  25856. * Gets if `setParticles()` computes the particle textures or not.
  25857. * Default value : true. The SPS is faster when it's set to false.
  25858. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25859. */
  25860. computeParticleTexture: boolean;
  25861. /**
  25862. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25863. * Default value : false. The SPS is faster when it's set to false.
  25864. * Note : the particle custom vertex positions aren't stored values.
  25865. */
  25866. /**
  25867. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25868. * Default value : false. The SPS is faster when it's set to false.
  25869. * Note : the particle custom vertex positions aren't stored values.
  25870. */
  25871. computeParticleVertex: boolean;
  25872. /**
  25873. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25874. */
  25875. /**
  25876. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25877. */
  25878. computeBoundingBox: boolean;
  25879. /**
  25880. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25881. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25882. * Default : `true`
  25883. */
  25884. /**
  25885. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25886. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25887. * Default : `true`
  25888. */
  25889. depthSortParticles: boolean;
  25890. /**
  25891. * This function does nothing. It may be overwritten to set all the particle first values.
  25892. * The SPS doesn't call this function, you may have to call it by your own.
  25893. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25894. */
  25895. initParticles(): void;
  25896. /**
  25897. * This function does nothing. It may be overwritten to recycle a particle.
  25898. * The SPS doesn't call this function, you may have to call it by your own.
  25899. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25900. * @param particle The particle to recycle
  25901. * @returns the recycled particle
  25902. */
  25903. recycleParticle(particle: SolidParticle): SolidParticle;
  25904. /**
  25905. * Updates a particle : this function should be overwritten by the user.
  25906. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25907. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25908. * @example : just set a particle position or velocity and recycle conditions
  25909. * @param particle The particle to update
  25910. * @returns the updated particle
  25911. */
  25912. updateParticle(particle: SolidParticle): SolidParticle;
  25913. /**
  25914. * Updates a vertex of a particle : it can be overwritten by the user.
  25915. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25916. * @param particle the current particle
  25917. * @param vertex the current index of the current particle
  25918. * @param pt the index of the current vertex in the particle shape
  25919. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25920. * @example : just set a vertex particle position
  25921. * @returns the updated vertex
  25922. */
  25923. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25924. /**
  25925. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25926. * This does nothing and may be overwritten by the user.
  25927. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25928. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25929. * @param update the boolean update value actually passed to setParticles()
  25930. */
  25931. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25932. /**
  25933. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25934. * This will be passed three parameters.
  25935. * This does nothing and may be overwritten by the user.
  25936. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25937. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25938. * @param update the boolean update value actually passed to setParticles()
  25939. */
  25940. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25941. }
  25942. }
  25943. declare module "babylonjs/Particles/solidParticle" {
  25944. import { Nullable } from "babylonjs/types";
  25945. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25946. import { Color4 } from "babylonjs/Maths/math.color";
  25947. import { Mesh } from "babylonjs/Meshes/mesh";
  25948. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25949. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25950. import { Plane } from "babylonjs/Maths/math.plane";
  25951. /**
  25952. * Represents one particle of a solid particle system.
  25953. */
  25954. export class SolidParticle {
  25955. /**
  25956. * particle global index
  25957. */
  25958. idx: number;
  25959. /**
  25960. * The color of the particle
  25961. */
  25962. color: Nullable<Color4>;
  25963. /**
  25964. * The world space position of the particle.
  25965. */
  25966. position: Vector3;
  25967. /**
  25968. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25969. */
  25970. rotation: Vector3;
  25971. /**
  25972. * The world space rotation quaternion of the particle.
  25973. */
  25974. rotationQuaternion: Nullable<Quaternion>;
  25975. /**
  25976. * The scaling of the particle.
  25977. */
  25978. scaling: Vector3;
  25979. /**
  25980. * The uvs of the particle.
  25981. */
  25982. uvs: Vector4;
  25983. /**
  25984. * The current speed of the particle.
  25985. */
  25986. velocity: Vector3;
  25987. /**
  25988. * The pivot point in the particle local space.
  25989. */
  25990. pivot: Vector3;
  25991. /**
  25992. * Must the particle be translated from its pivot point in its local space ?
  25993. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25994. * Default : false
  25995. */
  25996. translateFromPivot: boolean;
  25997. /**
  25998. * Is the particle active or not ?
  25999. */
  26000. alive: boolean;
  26001. /**
  26002. * Is the particle visible or not ?
  26003. */
  26004. isVisible: boolean;
  26005. /**
  26006. * Index of this particle in the global "positions" array (Internal use)
  26007. * @hidden
  26008. */
  26009. _pos: number;
  26010. /**
  26011. * @hidden Index of this particle in the global "indices" array (Internal use)
  26012. */
  26013. _ind: number;
  26014. /**
  26015. * @hidden ModelShape of this particle (Internal use)
  26016. */
  26017. _model: ModelShape;
  26018. /**
  26019. * ModelShape id of this particle
  26020. */
  26021. shapeId: number;
  26022. /**
  26023. * Index of the particle in its shape id (Internal use)
  26024. */
  26025. idxInShape: number;
  26026. /**
  26027. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26028. */
  26029. _modelBoundingInfo: BoundingInfo;
  26030. /**
  26031. * @hidden Particle BoundingInfo object (Internal use)
  26032. */
  26033. _boundingInfo: BoundingInfo;
  26034. /**
  26035. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26036. */
  26037. _sps: SolidParticleSystem;
  26038. /**
  26039. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26040. */
  26041. _stillInvisible: boolean;
  26042. /**
  26043. * @hidden Last computed particle rotation matrix
  26044. */
  26045. _rotationMatrix: number[];
  26046. /**
  26047. * Parent particle Id, if any.
  26048. * Default null.
  26049. */
  26050. parentId: Nullable<number>;
  26051. /**
  26052. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26053. * The possible values are :
  26054. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26055. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26056. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26057. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26058. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26059. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26060. * */
  26061. cullingStrategy: number;
  26062. /**
  26063. * @hidden Internal global position in the SPS.
  26064. */
  26065. _globalPosition: Vector3;
  26066. /**
  26067. * Creates a Solid Particle object.
  26068. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26069. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26070. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26071. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26072. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26073. * @param shapeId (integer) is the model shape identifier in the SPS.
  26074. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26075. * @param sps defines the sps it is associated to
  26076. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26077. */
  26078. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26079. /**
  26080. * Legacy support, changed scale to scaling
  26081. */
  26082. /**
  26083. * Legacy support, changed scale to scaling
  26084. */
  26085. scale: Vector3;
  26086. /**
  26087. * Legacy support, changed quaternion to rotationQuaternion
  26088. */
  26089. /**
  26090. * Legacy support, changed quaternion to rotationQuaternion
  26091. */
  26092. quaternion: Nullable<Quaternion>;
  26093. /**
  26094. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26095. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26096. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26097. * @returns true if it intersects
  26098. */
  26099. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26100. /**
  26101. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26102. * A particle is in the frustum if its bounding box intersects the frustum
  26103. * @param frustumPlanes defines the frustum to test
  26104. * @returns true if the particle is in the frustum planes
  26105. */
  26106. isInFrustum(frustumPlanes: Plane[]): boolean;
  26107. /**
  26108. * get the rotation matrix of the particle
  26109. * @hidden
  26110. */
  26111. getRotationMatrix(m: Matrix): void;
  26112. }
  26113. /**
  26114. * Represents the shape of the model used by one particle of a solid particle system.
  26115. * SPS internal tool, don't use it manually.
  26116. */
  26117. export class ModelShape {
  26118. /**
  26119. * The shape id
  26120. * @hidden
  26121. */
  26122. shapeID: number;
  26123. /**
  26124. * flat array of model positions (internal use)
  26125. * @hidden
  26126. */
  26127. _shape: Vector3[];
  26128. /**
  26129. * flat array of model UVs (internal use)
  26130. * @hidden
  26131. */
  26132. _shapeUV: number[];
  26133. /**
  26134. * length of the shape in the model indices array (internal use)
  26135. * @hidden
  26136. */
  26137. _indicesLength: number;
  26138. /**
  26139. * Custom position function (internal use)
  26140. * @hidden
  26141. */
  26142. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26143. /**
  26144. * Custom vertex function (internal use)
  26145. * @hidden
  26146. */
  26147. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26148. /**
  26149. * 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.
  26150. * SPS internal tool, don't use it manually.
  26151. * @hidden
  26152. */
  26153. 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>);
  26154. }
  26155. /**
  26156. * Represents a Depth Sorted Particle in the solid particle system.
  26157. */
  26158. export class DepthSortedParticle {
  26159. /**
  26160. * Index of the particle in the "indices" array
  26161. */
  26162. ind: number;
  26163. /**
  26164. * Length of the particle shape in the "indices" array
  26165. */
  26166. indicesLength: number;
  26167. /**
  26168. * Squared distance from the particle to the camera
  26169. */
  26170. sqDistance: number;
  26171. }
  26172. }
  26173. declare module "babylonjs/Collisions/meshCollisionData" {
  26174. import { Collider } from "babylonjs/Collisions/collider";
  26175. import { Vector3 } from "babylonjs/Maths/math.vector";
  26176. import { Nullable } from "babylonjs/types";
  26177. import { Observer } from "babylonjs/Misc/observable";
  26178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26179. /**
  26180. * @hidden
  26181. */
  26182. export class _MeshCollisionData {
  26183. _checkCollisions: boolean;
  26184. _collisionMask: number;
  26185. _collisionGroup: number;
  26186. _collider: Nullable<Collider>;
  26187. _oldPositionForCollisions: Vector3;
  26188. _diffPositionForCollisions: Vector3;
  26189. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26190. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26191. }
  26192. }
  26193. declare module "babylonjs/Meshes/abstractMesh" {
  26194. import { Observable } from "babylonjs/Misc/observable";
  26195. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26196. import { Camera } from "babylonjs/Cameras/camera";
  26197. import { Scene, IDisposable } from "babylonjs/scene";
  26198. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26199. import { Node } from "babylonjs/node";
  26200. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26201. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26202. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26203. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26204. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26205. import { Material } from "babylonjs/Materials/material";
  26206. import { Light } from "babylonjs/Lights/light";
  26207. import { Skeleton } from "babylonjs/Bones/skeleton";
  26208. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26209. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26210. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26211. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26212. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26213. import { Plane } from "babylonjs/Maths/math.plane";
  26214. import { Ray } from "babylonjs/Culling/ray";
  26215. import { Collider } from "babylonjs/Collisions/collider";
  26216. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26217. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26218. /** @hidden */
  26219. class _FacetDataStorage {
  26220. facetPositions: Vector3[];
  26221. facetNormals: Vector3[];
  26222. facetPartitioning: number[][];
  26223. facetNb: number;
  26224. partitioningSubdivisions: number;
  26225. partitioningBBoxRatio: number;
  26226. facetDataEnabled: boolean;
  26227. facetParameters: any;
  26228. bbSize: Vector3;
  26229. subDiv: {
  26230. max: number;
  26231. X: number;
  26232. Y: number;
  26233. Z: number;
  26234. };
  26235. facetDepthSort: boolean;
  26236. facetDepthSortEnabled: boolean;
  26237. depthSortedIndices: IndicesArray;
  26238. depthSortedFacets: {
  26239. ind: number;
  26240. sqDistance: number;
  26241. }[];
  26242. facetDepthSortFunction: (f1: {
  26243. ind: number;
  26244. sqDistance: number;
  26245. }, f2: {
  26246. ind: number;
  26247. sqDistance: number;
  26248. }) => number;
  26249. facetDepthSortFrom: Vector3;
  26250. facetDepthSortOrigin: Vector3;
  26251. invertedMatrix: Matrix;
  26252. }
  26253. /**
  26254. * @hidden
  26255. **/
  26256. class _InternalAbstractMeshDataInfo {
  26257. _hasVertexAlpha: boolean;
  26258. _useVertexColors: boolean;
  26259. _numBoneInfluencers: number;
  26260. _applyFog: boolean;
  26261. _receiveShadows: boolean;
  26262. _facetData: _FacetDataStorage;
  26263. _visibility: number;
  26264. _skeleton: Nullable<Skeleton>;
  26265. _layerMask: number;
  26266. _computeBonesUsingShaders: boolean;
  26267. _isActive: boolean;
  26268. _onlyForInstances: boolean;
  26269. _isActiveIntermediate: boolean;
  26270. _onlyForInstancesIntermediate: boolean;
  26271. }
  26272. /**
  26273. * Class used to store all common mesh properties
  26274. */
  26275. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26276. /** No occlusion */
  26277. static OCCLUSION_TYPE_NONE: number;
  26278. /** Occlusion set to optimisitic */
  26279. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26280. /** Occlusion set to strict */
  26281. static OCCLUSION_TYPE_STRICT: number;
  26282. /** Use an accurante occlusion algorithm */
  26283. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26284. /** Use a conservative occlusion algorithm */
  26285. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26286. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26287. * Test order :
  26288. * Is the bounding sphere outside the frustum ?
  26289. * If not, are the bounding box vertices outside the frustum ?
  26290. * It not, then the cullable object is in the frustum.
  26291. */
  26292. static readonly CULLINGSTRATEGY_STANDARD: number;
  26293. /** Culling strategy : Bounding Sphere Only.
  26294. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26295. * It's also less accurate than the standard because some not visible objects can still be selected.
  26296. * Test : is the bounding sphere outside the frustum ?
  26297. * If not, then the cullable object is in the frustum.
  26298. */
  26299. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26300. /** Culling strategy : Optimistic Inclusion.
  26301. * This in an inclusion test first, then the standard exclusion test.
  26302. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26303. * 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.
  26304. * Anyway, it's as accurate as the standard strategy.
  26305. * Test :
  26306. * Is the cullable object bounding sphere center in the frustum ?
  26307. * If not, apply the default culling strategy.
  26308. */
  26309. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26310. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26311. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26312. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26313. * 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.
  26314. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26315. * Test :
  26316. * Is the cullable object bounding sphere center in the frustum ?
  26317. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26318. */
  26319. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26320. /**
  26321. * No billboard
  26322. */
  26323. static readonly BILLBOARDMODE_NONE: number;
  26324. /** Billboard on X axis */
  26325. static readonly BILLBOARDMODE_X: number;
  26326. /** Billboard on Y axis */
  26327. static readonly BILLBOARDMODE_Y: number;
  26328. /** Billboard on Z axis */
  26329. static readonly BILLBOARDMODE_Z: number;
  26330. /** Billboard on all axes */
  26331. static readonly BILLBOARDMODE_ALL: number;
  26332. /** Billboard on using position instead of orientation */
  26333. static readonly BILLBOARDMODE_USE_POSITION: number;
  26334. /** @hidden */
  26335. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26336. /**
  26337. * The culling strategy to use to check whether the mesh must be rendered or not.
  26338. * This value can be changed at any time and will be used on the next render mesh selection.
  26339. * The possible values are :
  26340. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26341. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26342. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26343. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26344. * Please read each static variable documentation to get details about the culling process.
  26345. * */
  26346. cullingStrategy: number;
  26347. /**
  26348. * Gets the number of facets in the mesh
  26349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26350. */
  26351. readonly facetNb: number;
  26352. /**
  26353. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26355. */
  26356. partitioningSubdivisions: number;
  26357. /**
  26358. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26359. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26361. */
  26362. partitioningBBoxRatio: number;
  26363. /**
  26364. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26365. * Works only for updatable meshes.
  26366. * Doesn't work with multi-materials
  26367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26368. */
  26369. mustDepthSortFacets: boolean;
  26370. /**
  26371. * The location (Vector3) where the facet depth sort must be computed from.
  26372. * By default, the active camera position.
  26373. * Used only when facet depth sort is enabled
  26374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26375. */
  26376. facetDepthSortFrom: Vector3;
  26377. /**
  26378. * gets a boolean indicating if facetData is enabled
  26379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26380. */
  26381. readonly isFacetDataEnabled: boolean;
  26382. /** @hidden */
  26383. _updateNonUniformScalingState(value: boolean): boolean;
  26384. /**
  26385. * An event triggered when this mesh collides with another one
  26386. */
  26387. onCollideObservable: Observable<AbstractMesh>;
  26388. /** Set a function to call when this mesh collides with another one */
  26389. onCollide: () => void;
  26390. /**
  26391. * An event triggered when the collision's position changes
  26392. */
  26393. onCollisionPositionChangeObservable: Observable<Vector3>;
  26394. /** Set a function to call when the collision's position changes */
  26395. onCollisionPositionChange: () => void;
  26396. /**
  26397. * An event triggered when material is changed
  26398. */
  26399. onMaterialChangedObservable: Observable<AbstractMesh>;
  26400. /**
  26401. * Gets or sets the orientation for POV movement & rotation
  26402. */
  26403. definedFacingForward: boolean;
  26404. /** @hidden */
  26405. _occlusionQuery: Nullable<WebGLQuery>;
  26406. /** @hidden */
  26407. _renderingGroup: Nullable<RenderingGroup>;
  26408. /**
  26409. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26410. */
  26411. /**
  26412. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26413. */
  26414. visibility: number;
  26415. /** Gets or sets the alpha index used to sort transparent meshes
  26416. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26417. */
  26418. alphaIndex: number;
  26419. /**
  26420. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26421. */
  26422. isVisible: boolean;
  26423. /**
  26424. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26425. */
  26426. isPickable: boolean;
  26427. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26428. showSubMeshesBoundingBox: boolean;
  26429. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26430. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26431. */
  26432. isBlocker: boolean;
  26433. /**
  26434. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26435. */
  26436. enablePointerMoveEvents: boolean;
  26437. /**
  26438. * Specifies the rendering group id for this mesh (0 by default)
  26439. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26440. */
  26441. renderingGroupId: number;
  26442. private _material;
  26443. /** Gets or sets current material */
  26444. material: Nullable<Material>;
  26445. /**
  26446. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26447. * @see http://doc.babylonjs.com/babylon101/shadows
  26448. */
  26449. receiveShadows: boolean;
  26450. /** Defines color to use when rendering outline */
  26451. outlineColor: Color3;
  26452. /** Define width to use when rendering outline */
  26453. outlineWidth: number;
  26454. /** Defines color to use when rendering overlay */
  26455. overlayColor: Color3;
  26456. /** Defines alpha to use when rendering overlay */
  26457. overlayAlpha: number;
  26458. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26459. hasVertexAlpha: boolean;
  26460. /** 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) */
  26461. useVertexColors: boolean;
  26462. /**
  26463. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26464. */
  26465. computeBonesUsingShaders: boolean;
  26466. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26467. numBoneInfluencers: number;
  26468. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26469. applyFog: boolean;
  26470. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26471. useOctreeForRenderingSelection: boolean;
  26472. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26473. useOctreeForPicking: boolean;
  26474. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26475. useOctreeForCollisions: boolean;
  26476. /**
  26477. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26478. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26479. */
  26480. layerMask: number;
  26481. /**
  26482. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26483. */
  26484. alwaysSelectAsActiveMesh: boolean;
  26485. /**
  26486. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26487. */
  26488. doNotSyncBoundingInfo: boolean;
  26489. /**
  26490. * Gets or sets the current action manager
  26491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26492. */
  26493. actionManager: Nullable<AbstractActionManager>;
  26494. private _meshCollisionData;
  26495. /**
  26496. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26498. */
  26499. ellipsoid: Vector3;
  26500. /**
  26501. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26502. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26503. */
  26504. ellipsoidOffset: Vector3;
  26505. /**
  26506. * Gets or sets a collision mask used to mask collisions (default is -1).
  26507. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26508. */
  26509. collisionMask: number;
  26510. /**
  26511. * Gets or sets the current collision group mask (-1 by default).
  26512. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26513. */
  26514. collisionGroup: number;
  26515. /**
  26516. * Defines edge width used when edgesRenderer is enabled
  26517. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26518. */
  26519. edgesWidth: number;
  26520. /**
  26521. * Defines edge color used when edgesRenderer is enabled
  26522. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26523. */
  26524. edgesColor: Color4;
  26525. /** @hidden */
  26526. _edgesRenderer: Nullable<IEdgesRenderer>;
  26527. /** @hidden */
  26528. _masterMesh: Nullable<AbstractMesh>;
  26529. /** @hidden */
  26530. _boundingInfo: Nullable<BoundingInfo>;
  26531. /** @hidden */
  26532. _renderId: number;
  26533. /**
  26534. * Gets or sets the list of subMeshes
  26535. * @see http://doc.babylonjs.com/how_to/multi_materials
  26536. */
  26537. subMeshes: SubMesh[];
  26538. /** @hidden */
  26539. _intersectionsInProgress: AbstractMesh[];
  26540. /** @hidden */
  26541. _unIndexed: boolean;
  26542. /** @hidden */
  26543. _lightSources: Light[];
  26544. /** Gets the list of lights affecting that mesh */
  26545. readonly lightSources: Light[];
  26546. /** @hidden */
  26547. readonly _positions: Nullable<Vector3[]>;
  26548. /** @hidden */
  26549. _waitingData: {
  26550. lods: Nullable<any>;
  26551. actions: Nullable<any>;
  26552. freezeWorldMatrix: Nullable<boolean>;
  26553. };
  26554. /** @hidden */
  26555. _bonesTransformMatrices: Nullable<Float32Array>;
  26556. /** @hidden */
  26557. _transformMatrixTexture: Nullable<RawTexture>;
  26558. /**
  26559. * Gets or sets a skeleton to apply skining transformations
  26560. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26561. */
  26562. skeleton: Nullable<Skeleton>;
  26563. /**
  26564. * An event triggered when the mesh is rebuilt.
  26565. */
  26566. onRebuildObservable: Observable<AbstractMesh>;
  26567. /**
  26568. * Creates a new AbstractMesh
  26569. * @param name defines the name of the mesh
  26570. * @param scene defines the hosting scene
  26571. */
  26572. constructor(name: string, scene?: Nullable<Scene>);
  26573. /**
  26574. * Returns the string "AbstractMesh"
  26575. * @returns "AbstractMesh"
  26576. */
  26577. getClassName(): string;
  26578. /**
  26579. * Gets a string representation of the current mesh
  26580. * @param fullDetails defines a boolean indicating if full details must be included
  26581. * @returns a string representation of the current mesh
  26582. */
  26583. toString(fullDetails?: boolean): string;
  26584. /**
  26585. * @hidden
  26586. */
  26587. protected _getEffectiveParent(): Nullable<Node>;
  26588. /** @hidden */
  26589. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26590. /** @hidden */
  26591. _rebuild(): void;
  26592. /** @hidden */
  26593. _resyncLightSources(): void;
  26594. /** @hidden */
  26595. _resyncLighSource(light: Light): void;
  26596. /** @hidden */
  26597. _unBindEffect(): void;
  26598. /** @hidden */
  26599. _removeLightSource(light: Light): void;
  26600. private _markSubMeshesAsDirty;
  26601. /** @hidden */
  26602. _markSubMeshesAsLightDirty(): void;
  26603. /** @hidden */
  26604. _markSubMeshesAsAttributesDirty(): void;
  26605. /** @hidden */
  26606. _markSubMeshesAsMiscDirty(): void;
  26607. /**
  26608. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26609. */
  26610. scaling: Vector3;
  26611. /**
  26612. * Returns true if the mesh is blocked. Implemented by child classes
  26613. */
  26614. readonly isBlocked: boolean;
  26615. /**
  26616. * Returns the mesh itself by default. Implemented by child classes
  26617. * @param camera defines the camera to use to pick the right LOD level
  26618. * @returns the currentAbstractMesh
  26619. */
  26620. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26621. /**
  26622. * Returns 0 by default. Implemented by child classes
  26623. * @returns an integer
  26624. */
  26625. getTotalVertices(): number;
  26626. /**
  26627. * Returns a positive integer : the total number of indices in this mesh geometry.
  26628. * @returns the numner of indices or zero if the mesh has no geometry.
  26629. */
  26630. getTotalIndices(): number;
  26631. /**
  26632. * Returns null by default. Implemented by child classes
  26633. * @returns null
  26634. */
  26635. getIndices(): Nullable<IndicesArray>;
  26636. /**
  26637. * Returns the array of the requested vertex data kind. Implemented by child classes
  26638. * @param kind defines the vertex data kind to use
  26639. * @returns null
  26640. */
  26641. getVerticesData(kind: string): Nullable<FloatArray>;
  26642. /**
  26643. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26644. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26645. * Note that a new underlying VertexBuffer object is created each call.
  26646. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26647. * @param kind defines vertex data kind:
  26648. * * VertexBuffer.PositionKind
  26649. * * VertexBuffer.UVKind
  26650. * * VertexBuffer.UV2Kind
  26651. * * VertexBuffer.UV3Kind
  26652. * * VertexBuffer.UV4Kind
  26653. * * VertexBuffer.UV5Kind
  26654. * * VertexBuffer.UV6Kind
  26655. * * VertexBuffer.ColorKind
  26656. * * VertexBuffer.MatricesIndicesKind
  26657. * * VertexBuffer.MatricesIndicesExtraKind
  26658. * * VertexBuffer.MatricesWeightsKind
  26659. * * VertexBuffer.MatricesWeightsExtraKind
  26660. * @param data defines the data source
  26661. * @param updatable defines if the data must be flagged as updatable (or static)
  26662. * @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
  26663. * @returns the current mesh
  26664. */
  26665. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26666. /**
  26667. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26668. * If the mesh has no geometry, it is simply returned as it is.
  26669. * @param kind defines vertex data kind:
  26670. * * VertexBuffer.PositionKind
  26671. * * VertexBuffer.UVKind
  26672. * * VertexBuffer.UV2Kind
  26673. * * VertexBuffer.UV3Kind
  26674. * * VertexBuffer.UV4Kind
  26675. * * VertexBuffer.UV5Kind
  26676. * * VertexBuffer.UV6Kind
  26677. * * VertexBuffer.ColorKind
  26678. * * VertexBuffer.MatricesIndicesKind
  26679. * * VertexBuffer.MatricesIndicesExtraKind
  26680. * * VertexBuffer.MatricesWeightsKind
  26681. * * VertexBuffer.MatricesWeightsExtraKind
  26682. * @param data defines the data source
  26683. * @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
  26684. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26685. * @returns the current mesh
  26686. */
  26687. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26688. /**
  26689. * Sets the mesh indices,
  26690. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26691. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26692. * @param totalVertices Defines the total number of vertices
  26693. * @returns the current mesh
  26694. */
  26695. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26696. /**
  26697. * Gets a boolean indicating if specific vertex data is present
  26698. * @param kind defines the vertex data kind to use
  26699. * @returns true is data kind is present
  26700. */
  26701. isVerticesDataPresent(kind: string): boolean;
  26702. /**
  26703. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26704. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26705. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26706. * @returns a BoundingInfo
  26707. */
  26708. getBoundingInfo(): BoundingInfo;
  26709. /**
  26710. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26711. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26712. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26713. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26714. * @returns the current mesh
  26715. */
  26716. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26717. /**
  26718. * Overwrite the current bounding info
  26719. * @param boundingInfo defines the new bounding info
  26720. * @returns the current mesh
  26721. */
  26722. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26723. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26724. readonly useBones: boolean;
  26725. /** @hidden */
  26726. _preActivate(): void;
  26727. /** @hidden */
  26728. _preActivateForIntermediateRendering(renderId: number): void;
  26729. /** @hidden */
  26730. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26731. /** @hidden */
  26732. _postActivate(): void;
  26733. /** @hidden */
  26734. _freeze(): void;
  26735. /** @hidden */
  26736. _unFreeze(): void;
  26737. /**
  26738. * Gets the current world matrix
  26739. * @returns a Matrix
  26740. */
  26741. getWorldMatrix(): Matrix;
  26742. /** @hidden */
  26743. _getWorldMatrixDeterminant(): number;
  26744. /**
  26745. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26746. */
  26747. readonly isAnInstance: boolean;
  26748. /**
  26749. * Perform relative position change from the point of view of behind the front of the mesh.
  26750. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26751. * Supports definition of mesh facing forward or backward
  26752. * @param amountRight defines the distance on the right axis
  26753. * @param amountUp defines the distance on the up axis
  26754. * @param amountForward defines the distance on the forward axis
  26755. * @returns the current mesh
  26756. */
  26757. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26758. /**
  26759. * Calculate relative position change from the point of view of behind the front of the mesh.
  26760. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26761. * Supports definition of mesh facing forward or backward
  26762. * @param amountRight defines the distance on the right axis
  26763. * @param amountUp defines the distance on the up axis
  26764. * @param amountForward defines the distance on the forward axis
  26765. * @returns the new displacement vector
  26766. */
  26767. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26768. /**
  26769. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26770. * Supports definition of mesh facing forward or backward
  26771. * @param flipBack defines the flip
  26772. * @param twirlClockwise defines the twirl
  26773. * @param tiltRight defines the tilt
  26774. * @returns the current mesh
  26775. */
  26776. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26777. /**
  26778. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26779. * Supports definition of mesh facing forward or backward.
  26780. * @param flipBack defines the flip
  26781. * @param twirlClockwise defines the twirl
  26782. * @param tiltRight defines the tilt
  26783. * @returns the new rotation vector
  26784. */
  26785. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26786. /**
  26787. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26788. * This means the mesh underlying bounding box and sphere are recomputed.
  26789. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26790. * @returns the current mesh
  26791. */
  26792. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26793. /** @hidden */
  26794. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26795. /** @hidden */
  26796. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26797. /** @hidden */
  26798. _updateBoundingInfo(): AbstractMesh;
  26799. /** @hidden */
  26800. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26801. /** @hidden */
  26802. protected _afterComputeWorldMatrix(): void;
  26803. /** @hidden */
  26804. readonly _effectiveMesh: AbstractMesh;
  26805. /**
  26806. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26807. * A mesh is in the frustum if its bounding box intersects the frustum
  26808. * @param frustumPlanes defines the frustum to test
  26809. * @returns true if the mesh is in the frustum planes
  26810. */
  26811. isInFrustum(frustumPlanes: Plane[]): boolean;
  26812. /**
  26813. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26814. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26815. * @param frustumPlanes defines the frustum to test
  26816. * @returns true if the mesh is completely in the frustum planes
  26817. */
  26818. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26819. /**
  26820. * True if the mesh intersects another mesh or a SolidParticle object
  26821. * @param mesh defines a target mesh or SolidParticle to test
  26822. * @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)
  26823. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26824. * @returns true if there is an intersection
  26825. */
  26826. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26827. /**
  26828. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26829. * @param point defines the point to test
  26830. * @returns true if there is an intersection
  26831. */
  26832. intersectsPoint(point: Vector3): boolean;
  26833. /**
  26834. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26836. */
  26837. checkCollisions: boolean;
  26838. /**
  26839. * Gets Collider object used to compute collisions (not physics)
  26840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26841. */
  26842. readonly collider: Nullable<Collider>;
  26843. /**
  26844. * Move the mesh using collision engine
  26845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26846. * @param displacement defines the requested displacement vector
  26847. * @returns the current mesh
  26848. */
  26849. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26850. private _onCollisionPositionChange;
  26851. /** @hidden */
  26852. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26853. /** @hidden */
  26854. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26855. /** @hidden */
  26856. _checkCollision(collider: Collider): AbstractMesh;
  26857. /** @hidden */
  26858. _generatePointsArray(): boolean;
  26859. /**
  26860. * Checks if the passed Ray intersects with the mesh
  26861. * @param ray defines the ray to use
  26862. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26863. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26864. * @returns the picking info
  26865. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26866. */
  26867. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26868. /**
  26869. * Clones the current mesh
  26870. * @param name defines the mesh name
  26871. * @param newParent defines the new mesh parent
  26872. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26873. * @returns the new mesh
  26874. */
  26875. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26876. /**
  26877. * Disposes all the submeshes of the current meshnp
  26878. * @returns the current mesh
  26879. */
  26880. releaseSubMeshes(): AbstractMesh;
  26881. /**
  26882. * Releases resources associated with this abstract mesh.
  26883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26885. */
  26886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26887. /**
  26888. * Adds the passed mesh as a child to the current mesh
  26889. * @param mesh defines the child mesh
  26890. * @returns the current mesh
  26891. */
  26892. addChild(mesh: AbstractMesh): AbstractMesh;
  26893. /**
  26894. * Removes the passed mesh from the current mesh children list
  26895. * @param mesh defines the child mesh
  26896. * @returns the current mesh
  26897. */
  26898. removeChild(mesh: AbstractMesh): AbstractMesh;
  26899. /** @hidden */
  26900. private _initFacetData;
  26901. /**
  26902. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26903. * This method can be called within the render loop.
  26904. * 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
  26905. * @returns the current mesh
  26906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26907. */
  26908. updateFacetData(): AbstractMesh;
  26909. /**
  26910. * Returns the facetLocalNormals array.
  26911. * The normals are expressed in the mesh local spac
  26912. * @returns an array of Vector3
  26913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26914. */
  26915. getFacetLocalNormals(): Vector3[];
  26916. /**
  26917. * Returns the facetLocalPositions array.
  26918. * The facet positions are expressed in the mesh local space
  26919. * @returns an array of Vector3
  26920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26921. */
  26922. getFacetLocalPositions(): Vector3[];
  26923. /**
  26924. * Returns the facetLocalPartioning array
  26925. * @returns an array of array of numbers
  26926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26927. */
  26928. getFacetLocalPartitioning(): number[][];
  26929. /**
  26930. * Returns the i-th facet position in the world system.
  26931. * This method allocates a new Vector3 per call
  26932. * @param i defines the facet index
  26933. * @returns a new Vector3
  26934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26935. */
  26936. getFacetPosition(i: number): Vector3;
  26937. /**
  26938. * Sets the reference Vector3 with the i-th facet position in the world system
  26939. * @param i defines the facet index
  26940. * @param ref defines the target vector
  26941. * @returns the current mesh
  26942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26943. */
  26944. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26945. /**
  26946. * Returns the i-th facet normal in the world system.
  26947. * This method allocates a new Vector3 per call
  26948. * @param i defines the facet index
  26949. * @returns a new Vector3
  26950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26951. */
  26952. getFacetNormal(i: number): Vector3;
  26953. /**
  26954. * Sets the reference Vector3 with the i-th facet normal in the world system
  26955. * @param i defines the facet index
  26956. * @param ref defines the target vector
  26957. * @returns the current mesh
  26958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26959. */
  26960. getFacetNormalToRef(i: number, ref: Vector3): this;
  26961. /**
  26962. * 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)
  26963. * @param x defines x coordinate
  26964. * @param y defines y coordinate
  26965. * @param z defines z coordinate
  26966. * @returns the array of facet indexes
  26967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26968. */
  26969. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26970. /**
  26971. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26972. * @param projected sets as the (x,y,z) world projection on the facet
  26973. * @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
  26974. * @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
  26975. * @param x defines x coordinate
  26976. * @param y defines y coordinate
  26977. * @param z defines z coordinate
  26978. * @returns the face index if found (or null instead)
  26979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26980. */
  26981. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26982. /**
  26983. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26984. * @param projected sets as the (x,y,z) local projection on the facet
  26985. * @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
  26986. * @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
  26987. * @param x defines x coordinate
  26988. * @param y defines y coordinate
  26989. * @param z defines z coordinate
  26990. * @returns the face index if found (or null instead)
  26991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26992. */
  26993. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26994. /**
  26995. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26996. * @returns the parameters
  26997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26998. */
  26999. getFacetDataParameters(): any;
  27000. /**
  27001. * Disables the feature FacetData and frees the related memory
  27002. * @returns the current mesh
  27003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27004. */
  27005. disableFacetData(): AbstractMesh;
  27006. /**
  27007. * Updates the AbstractMesh indices array
  27008. * @param indices defines the data source
  27009. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27010. * @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)
  27011. * @returns the current mesh
  27012. */
  27013. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27014. /**
  27015. * Creates new normals data for the mesh
  27016. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27017. * @returns the current mesh
  27018. */
  27019. createNormals(updatable: boolean): AbstractMesh;
  27020. /**
  27021. * Align the mesh with a normal
  27022. * @param normal defines the normal to use
  27023. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27024. * @returns the current mesh
  27025. */
  27026. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27027. /** @hidden */
  27028. _checkOcclusionQuery(): boolean;
  27029. /**
  27030. * Disables the mesh edge rendering mode
  27031. * @returns the currentAbstractMesh
  27032. */
  27033. disableEdgesRendering(): AbstractMesh;
  27034. /**
  27035. * Enables the edge rendering mode on the mesh.
  27036. * This mode makes the mesh edges visible
  27037. * @param epsilon defines the maximal distance between two angles to detect a face
  27038. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27039. * @returns the currentAbstractMesh
  27040. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27041. */
  27042. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27043. }
  27044. }
  27045. declare module "babylonjs/Actions/actionEvent" {
  27046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27047. import { Nullable } from "babylonjs/types";
  27048. import { Sprite } from "babylonjs/Sprites/sprite";
  27049. import { Scene } from "babylonjs/scene";
  27050. import { Vector2 } from "babylonjs/Maths/math.vector";
  27051. /**
  27052. * Interface used to define ActionEvent
  27053. */
  27054. export interface IActionEvent {
  27055. /** The mesh or sprite that triggered the action */
  27056. source: any;
  27057. /** The X mouse cursor position at the time of the event */
  27058. pointerX: number;
  27059. /** The Y mouse cursor position at the time of the event */
  27060. pointerY: number;
  27061. /** The mesh that is currently pointed at (can be null) */
  27062. meshUnderPointer: Nullable<AbstractMesh>;
  27063. /** the original (browser) event that triggered the ActionEvent */
  27064. sourceEvent?: any;
  27065. /** additional data for the event */
  27066. additionalData?: any;
  27067. }
  27068. /**
  27069. * ActionEvent is the event being sent when an action is triggered.
  27070. */
  27071. export class ActionEvent implements IActionEvent {
  27072. /** The mesh or sprite that triggered the action */
  27073. source: any;
  27074. /** The X mouse cursor position at the time of the event */
  27075. pointerX: number;
  27076. /** The Y mouse cursor position at the time of the event */
  27077. pointerY: number;
  27078. /** The mesh that is currently pointed at (can be null) */
  27079. meshUnderPointer: Nullable<AbstractMesh>;
  27080. /** the original (browser) event that triggered the ActionEvent */
  27081. sourceEvent?: any;
  27082. /** additional data for the event */
  27083. additionalData?: any;
  27084. /**
  27085. * Creates a new ActionEvent
  27086. * @param source The mesh or sprite that triggered the action
  27087. * @param pointerX The X mouse cursor position at the time of the event
  27088. * @param pointerY The Y mouse cursor position at the time of the event
  27089. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27090. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27091. * @param additionalData additional data for the event
  27092. */
  27093. constructor(
  27094. /** The mesh or sprite that triggered the action */
  27095. source: any,
  27096. /** The X mouse cursor position at the time of the event */
  27097. pointerX: number,
  27098. /** The Y mouse cursor position at the time of the event */
  27099. pointerY: number,
  27100. /** The mesh that is currently pointed at (can be null) */
  27101. meshUnderPointer: Nullable<AbstractMesh>,
  27102. /** the original (browser) event that triggered the ActionEvent */
  27103. sourceEvent?: any,
  27104. /** additional data for the event */
  27105. additionalData?: any);
  27106. /**
  27107. * Helper function to auto-create an ActionEvent from a source mesh.
  27108. * @param source The source mesh that triggered the event
  27109. * @param evt The original (browser) event
  27110. * @param additionalData additional data for the event
  27111. * @returns the new ActionEvent
  27112. */
  27113. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27114. /**
  27115. * Helper function to auto-create an ActionEvent from a source sprite
  27116. * @param source The source sprite that triggered the event
  27117. * @param scene Scene associated with the sprite
  27118. * @param evt The original (browser) event
  27119. * @param additionalData additional data for the event
  27120. * @returns the new ActionEvent
  27121. */
  27122. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27123. /**
  27124. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27125. * @param scene the scene where the event occurred
  27126. * @param evt The original (browser) event
  27127. * @returns the new ActionEvent
  27128. */
  27129. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27130. /**
  27131. * Helper function to auto-create an ActionEvent from a primitive
  27132. * @param prim defines the target primitive
  27133. * @param pointerPos defines the pointer position
  27134. * @param evt The original (browser) event
  27135. * @param additionalData additional data for the event
  27136. * @returns the new ActionEvent
  27137. */
  27138. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27139. }
  27140. }
  27141. declare module "babylonjs/Actions/abstractActionManager" {
  27142. import { IDisposable } from "babylonjs/scene";
  27143. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27144. import { IAction } from "babylonjs/Actions/action";
  27145. import { Nullable } from "babylonjs/types";
  27146. /**
  27147. * Abstract class used to decouple action Manager from scene and meshes.
  27148. * Do not instantiate.
  27149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27150. */
  27151. export abstract class AbstractActionManager implements IDisposable {
  27152. /** Gets the list of active triggers */
  27153. static Triggers: {
  27154. [key: string]: number;
  27155. };
  27156. /** Gets the cursor to use when hovering items */
  27157. hoverCursor: string;
  27158. /** Gets the list of actions */
  27159. actions: IAction[];
  27160. /**
  27161. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27162. */
  27163. isRecursive: boolean;
  27164. /**
  27165. * Releases all associated resources
  27166. */
  27167. abstract dispose(): void;
  27168. /**
  27169. * Does this action manager has pointer triggers
  27170. */
  27171. abstract readonly hasPointerTriggers: boolean;
  27172. /**
  27173. * Does this action manager has pick triggers
  27174. */
  27175. abstract readonly hasPickTriggers: boolean;
  27176. /**
  27177. * Process a specific trigger
  27178. * @param trigger defines the trigger to process
  27179. * @param evt defines the event details to be processed
  27180. */
  27181. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27182. /**
  27183. * Does this action manager handles actions of any of the given triggers
  27184. * @param triggers defines the triggers to be tested
  27185. * @return a boolean indicating whether one (or more) of the triggers is handled
  27186. */
  27187. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27188. /**
  27189. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27190. * speed.
  27191. * @param triggerA defines the trigger to be tested
  27192. * @param triggerB defines the trigger to be tested
  27193. * @return a boolean indicating whether one (or more) of the triggers is handled
  27194. */
  27195. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27196. /**
  27197. * Does this action manager handles actions of a given trigger
  27198. * @param trigger defines the trigger to be tested
  27199. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27200. * @return whether the trigger is handled
  27201. */
  27202. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27203. /**
  27204. * Serialize this manager to a JSON object
  27205. * @param name defines the property name to store this manager
  27206. * @returns a JSON representation of this manager
  27207. */
  27208. abstract serialize(name: string): any;
  27209. /**
  27210. * Registers an action to this action manager
  27211. * @param action defines the action to be registered
  27212. * @return the action amended (prepared) after registration
  27213. */
  27214. abstract registerAction(action: IAction): Nullable<IAction>;
  27215. /**
  27216. * Unregisters an action to this action manager
  27217. * @param action defines the action to be unregistered
  27218. * @return a boolean indicating whether the action has been unregistered
  27219. */
  27220. abstract unregisterAction(action: IAction): Boolean;
  27221. /**
  27222. * Does exist one action manager with at least one trigger
  27223. **/
  27224. static readonly HasTriggers: boolean;
  27225. /**
  27226. * Does exist one action manager with at least one pick trigger
  27227. **/
  27228. static readonly HasPickTriggers: boolean;
  27229. /**
  27230. * Does exist one action manager that handles actions of a given trigger
  27231. * @param trigger defines the trigger to be tested
  27232. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27233. **/
  27234. static HasSpecificTrigger(trigger: number): boolean;
  27235. }
  27236. }
  27237. declare module "babylonjs/node" {
  27238. import { Scene } from "babylonjs/scene";
  27239. import { Nullable } from "babylonjs/types";
  27240. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27241. import { Engine } from "babylonjs/Engines/engine";
  27242. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27243. import { Observable } from "babylonjs/Misc/observable";
  27244. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27245. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27246. import { Animatable } from "babylonjs/Animations/animatable";
  27247. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27248. import { Animation } from "babylonjs/Animations/animation";
  27249. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27251. /**
  27252. * Defines how a node can be built from a string name.
  27253. */
  27254. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27255. /**
  27256. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27257. */
  27258. export class Node implements IBehaviorAware<Node> {
  27259. /** @hidden */
  27260. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27261. private static _NodeConstructors;
  27262. /**
  27263. * Add a new node constructor
  27264. * @param type defines the type name of the node to construct
  27265. * @param constructorFunc defines the constructor function
  27266. */
  27267. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27268. /**
  27269. * Returns a node constructor based on type name
  27270. * @param type defines the type name
  27271. * @param name defines the new node name
  27272. * @param scene defines the hosting scene
  27273. * @param options defines optional options to transmit to constructors
  27274. * @returns the new constructor or null
  27275. */
  27276. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27277. /**
  27278. * Gets or sets the name of the node
  27279. */
  27280. name: string;
  27281. /**
  27282. * Gets or sets the id of the node
  27283. */
  27284. id: string;
  27285. /**
  27286. * Gets or sets the unique id of the node
  27287. */
  27288. uniqueId: number;
  27289. /**
  27290. * Gets or sets a string used to store user defined state for the node
  27291. */
  27292. state: string;
  27293. /**
  27294. * Gets or sets an object used to store user defined information for the node
  27295. */
  27296. metadata: any;
  27297. /**
  27298. * For internal use only. Please do not use.
  27299. */
  27300. reservedDataStore: any;
  27301. /**
  27302. * List of inspectable custom properties (used by the Inspector)
  27303. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27304. */
  27305. inspectableCustomProperties: IInspectable[];
  27306. /**
  27307. * Gets or sets a boolean used to define if the node must be serialized
  27308. */
  27309. doNotSerialize: boolean;
  27310. /** @hidden */
  27311. _isDisposed: boolean;
  27312. /**
  27313. * Gets a list of Animations associated with the node
  27314. */
  27315. animations: import("babylonjs/Animations/animation").Animation[];
  27316. protected _ranges: {
  27317. [name: string]: Nullable<AnimationRange>;
  27318. };
  27319. /**
  27320. * Callback raised when the node is ready to be used
  27321. */
  27322. onReady: Nullable<(node: Node) => void>;
  27323. private _isEnabled;
  27324. private _isParentEnabled;
  27325. private _isReady;
  27326. /** @hidden */
  27327. _currentRenderId: number;
  27328. private _parentUpdateId;
  27329. /** @hidden */
  27330. _childUpdateId: number;
  27331. /** @hidden */
  27332. _waitingParentId: Nullable<string>;
  27333. /** @hidden */
  27334. _scene: Scene;
  27335. /** @hidden */
  27336. _cache: any;
  27337. private _parentNode;
  27338. private _children;
  27339. /** @hidden */
  27340. _worldMatrix: Matrix;
  27341. /** @hidden */
  27342. _worldMatrixDeterminant: number;
  27343. /** @hidden */
  27344. _worldMatrixDeterminantIsDirty: boolean;
  27345. /** @hidden */
  27346. private _sceneRootNodesIndex;
  27347. /**
  27348. * Gets a boolean indicating if the node has been disposed
  27349. * @returns true if the node was disposed
  27350. */
  27351. isDisposed(): boolean;
  27352. /**
  27353. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27354. * @see https://doc.babylonjs.com/how_to/parenting
  27355. */
  27356. parent: Nullable<Node>;
  27357. private addToSceneRootNodes;
  27358. private removeFromSceneRootNodes;
  27359. private _animationPropertiesOverride;
  27360. /**
  27361. * Gets or sets the animation properties override
  27362. */
  27363. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27364. /**
  27365. * Gets a string idenfifying the name of the class
  27366. * @returns "Node" string
  27367. */
  27368. getClassName(): string;
  27369. /** @hidden */
  27370. readonly _isNode: boolean;
  27371. /**
  27372. * An event triggered when the mesh is disposed
  27373. */
  27374. onDisposeObservable: Observable<Node>;
  27375. private _onDisposeObserver;
  27376. /**
  27377. * Sets a callback that will be raised when the node will be disposed
  27378. */
  27379. onDispose: () => void;
  27380. /**
  27381. * Creates a new Node
  27382. * @param name the name and id to be given to this node
  27383. * @param scene the scene this node will be added to
  27384. * @param addToRootNodes the node will be added to scene.rootNodes
  27385. */
  27386. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27387. /**
  27388. * Gets the scene of the node
  27389. * @returns a scene
  27390. */
  27391. getScene(): Scene;
  27392. /**
  27393. * Gets the engine of the node
  27394. * @returns a Engine
  27395. */
  27396. getEngine(): Engine;
  27397. private _behaviors;
  27398. /**
  27399. * Attach a behavior to the node
  27400. * @see http://doc.babylonjs.com/features/behaviour
  27401. * @param behavior defines the behavior to attach
  27402. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27403. * @returns the current Node
  27404. */
  27405. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27406. /**
  27407. * Remove an attached behavior
  27408. * @see http://doc.babylonjs.com/features/behaviour
  27409. * @param behavior defines the behavior to attach
  27410. * @returns the current Node
  27411. */
  27412. removeBehavior(behavior: Behavior<Node>): Node;
  27413. /**
  27414. * Gets the list of attached behaviors
  27415. * @see http://doc.babylonjs.com/features/behaviour
  27416. */
  27417. readonly behaviors: Behavior<Node>[];
  27418. /**
  27419. * Gets an attached behavior by name
  27420. * @param name defines the name of the behavior to look for
  27421. * @see http://doc.babylonjs.com/features/behaviour
  27422. * @returns null if behavior was not found else the requested behavior
  27423. */
  27424. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27425. /**
  27426. * Returns the latest update of the World matrix
  27427. * @returns a Matrix
  27428. */
  27429. getWorldMatrix(): Matrix;
  27430. /** @hidden */
  27431. _getWorldMatrixDeterminant(): number;
  27432. /**
  27433. * Returns directly the latest state of the mesh World matrix.
  27434. * A Matrix is returned.
  27435. */
  27436. readonly worldMatrixFromCache: Matrix;
  27437. /** @hidden */
  27438. _initCache(): void;
  27439. /** @hidden */
  27440. updateCache(force?: boolean): void;
  27441. /** @hidden */
  27442. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27443. /** @hidden */
  27444. _updateCache(ignoreParentClass?: boolean): void;
  27445. /** @hidden */
  27446. _isSynchronized(): boolean;
  27447. /** @hidden */
  27448. _markSyncedWithParent(): void;
  27449. /** @hidden */
  27450. isSynchronizedWithParent(): boolean;
  27451. /** @hidden */
  27452. isSynchronized(): boolean;
  27453. /**
  27454. * Is this node ready to be used/rendered
  27455. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27456. * @return true if the node is ready
  27457. */
  27458. isReady(completeCheck?: boolean): boolean;
  27459. /**
  27460. * Is this node enabled?
  27461. * 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
  27462. * @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
  27463. * @return whether this node (and its parent) is enabled
  27464. */
  27465. isEnabled(checkAncestors?: boolean): boolean;
  27466. /** @hidden */
  27467. protected _syncParentEnabledState(): void;
  27468. /**
  27469. * Set the enabled state of this node
  27470. * @param value defines the new enabled state
  27471. */
  27472. setEnabled(value: boolean): void;
  27473. /**
  27474. * Is this node a descendant of the given node?
  27475. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27476. * @param ancestor defines the parent node to inspect
  27477. * @returns a boolean indicating if this node is a descendant of the given node
  27478. */
  27479. isDescendantOf(ancestor: Node): boolean;
  27480. /** @hidden */
  27481. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27482. /**
  27483. * Will return all nodes that have this node as ascendant
  27484. * @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
  27485. * @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
  27486. * @return all children nodes of all types
  27487. */
  27488. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27489. /**
  27490. * Get all child-meshes of this node
  27491. * @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)
  27492. * @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
  27493. * @returns an array of AbstractMesh
  27494. */
  27495. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27496. /**
  27497. * Get all direct children of this node
  27498. * @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
  27499. * @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)
  27500. * @returns an array of Node
  27501. */
  27502. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27503. /** @hidden */
  27504. _setReady(state: boolean): void;
  27505. /**
  27506. * Get an animation by name
  27507. * @param name defines the name of the animation to look for
  27508. * @returns null if not found else the requested animation
  27509. */
  27510. getAnimationByName(name: string): Nullable<Animation>;
  27511. /**
  27512. * Creates an animation range for this node
  27513. * @param name defines the name of the range
  27514. * @param from defines the starting key
  27515. * @param to defines the end key
  27516. */
  27517. createAnimationRange(name: string, from: number, to: number): void;
  27518. /**
  27519. * Delete a specific animation range
  27520. * @param name defines the name of the range to delete
  27521. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27522. */
  27523. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27524. /**
  27525. * Get an animation range by name
  27526. * @param name defines the name of the animation range to look for
  27527. * @returns null if not found else the requested animation range
  27528. */
  27529. getAnimationRange(name: string): Nullable<AnimationRange>;
  27530. /**
  27531. * Gets the list of all animation ranges defined on this node
  27532. * @returns an array
  27533. */
  27534. getAnimationRanges(): Nullable<AnimationRange>[];
  27535. /**
  27536. * Will start the animation sequence
  27537. * @param name defines the range frames for animation sequence
  27538. * @param loop defines if the animation should loop (false by default)
  27539. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27540. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27541. * @returns the object created for this animation. If range does not exist, it will return null
  27542. */
  27543. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27544. /**
  27545. * Serialize animation ranges into a JSON compatible object
  27546. * @returns serialization object
  27547. */
  27548. serializeAnimationRanges(): any;
  27549. /**
  27550. * Computes the world matrix of the node
  27551. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27552. * @returns the world matrix
  27553. */
  27554. computeWorldMatrix(force?: boolean): Matrix;
  27555. /**
  27556. * Releases resources associated with this node.
  27557. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27558. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27559. */
  27560. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27561. /**
  27562. * Parse animation range data from a serialization object and store them into a given node
  27563. * @param node defines where to store the animation ranges
  27564. * @param parsedNode defines the serialization object to read data from
  27565. * @param scene defines the hosting scene
  27566. */
  27567. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27568. /**
  27569. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27570. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27571. * @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
  27572. * @returns the new bounding vectors
  27573. */
  27574. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27575. min: Vector3;
  27576. max: Vector3;
  27577. };
  27578. }
  27579. }
  27580. declare module "babylonjs/Animations/animation" {
  27581. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27582. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27583. import { Color3 } from "babylonjs/Maths/math.color";
  27584. import { Nullable } from "babylonjs/types";
  27585. import { Scene } from "babylonjs/scene";
  27586. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27587. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27588. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27589. import { Node } from "babylonjs/node";
  27590. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27591. import { Size } from "babylonjs/Maths/math.size";
  27592. import { Animatable } from "babylonjs/Animations/animatable";
  27593. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27594. /**
  27595. * @hidden
  27596. */
  27597. export class _IAnimationState {
  27598. key: number;
  27599. repeatCount: number;
  27600. workValue?: any;
  27601. loopMode?: number;
  27602. offsetValue?: any;
  27603. highLimitValue?: any;
  27604. }
  27605. /**
  27606. * Class used to store any kind of animation
  27607. */
  27608. export class Animation {
  27609. /**Name of the animation */
  27610. name: string;
  27611. /**Property to animate */
  27612. targetProperty: string;
  27613. /**The frames per second of the animation */
  27614. framePerSecond: number;
  27615. /**The data type of the animation */
  27616. dataType: number;
  27617. /**The loop mode of the animation */
  27618. loopMode?: number | undefined;
  27619. /**Specifies if blending should be enabled */
  27620. enableBlending?: boolean | undefined;
  27621. /**
  27622. * Use matrix interpolation instead of using direct key value when animating matrices
  27623. */
  27624. static AllowMatricesInterpolation: boolean;
  27625. /**
  27626. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27627. */
  27628. static AllowMatrixDecomposeForInterpolation: boolean;
  27629. /**
  27630. * Stores the key frames of the animation
  27631. */
  27632. private _keys;
  27633. /**
  27634. * Stores the easing function of the animation
  27635. */
  27636. private _easingFunction;
  27637. /**
  27638. * @hidden Internal use only
  27639. */
  27640. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27641. /**
  27642. * The set of event that will be linked to this animation
  27643. */
  27644. private _events;
  27645. /**
  27646. * Stores an array of target property paths
  27647. */
  27648. targetPropertyPath: string[];
  27649. /**
  27650. * Stores the blending speed of the animation
  27651. */
  27652. blendingSpeed: number;
  27653. /**
  27654. * Stores the animation ranges for the animation
  27655. */
  27656. private _ranges;
  27657. /**
  27658. * @hidden Internal use
  27659. */
  27660. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27661. /**
  27662. * Sets up an animation
  27663. * @param property The property to animate
  27664. * @param animationType The animation type to apply
  27665. * @param framePerSecond The frames per second of the animation
  27666. * @param easingFunction The easing function used in the animation
  27667. * @returns The created animation
  27668. */
  27669. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27670. /**
  27671. * Create and start an animation on a node
  27672. * @param name defines the name of the global animation that will be run on all nodes
  27673. * @param node defines the root node where the animation will take place
  27674. * @param targetProperty defines property to animate
  27675. * @param framePerSecond defines the number of frame per second yo use
  27676. * @param totalFrame defines the number of frames in total
  27677. * @param from defines the initial value
  27678. * @param to defines the final value
  27679. * @param loopMode defines which loop mode you want to use (off by default)
  27680. * @param easingFunction defines the easing function to use (linear by default)
  27681. * @param onAnimationEnd defines the callback to call when animation end
  27682. * @returns the animatable created for this animation
  27683. */
  27684. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27685. /**
  27686. * Create and start an animation on a node and its descendants
  27687. * @param name defines the name of the global animation that will be run on all nodes
  27688. * @param node defines the root node where the animation will take place
  27689. * @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
  27690. * @param targetProperty defines property to animate
  27691. * @param framePerSecond defines the number of frame per second to use
  27692. * @param totalFrame defines the number of frames in total
  27693. * @param from defines the initial value
  27694. * @param to defines the final value
  27695. * @param loopMode defines which loop mode you want to use (off by default)
  27696. * @param easingFunction defines the easing function to use (linear by default)
  27697. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27698. * @returns the list of animatables created for all nodes
  27699. * @example https://www.babylonjs-playground.com/#MH0VLI
  27700. */
  27701. 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[]>;
  27702. /**
  27703. * Creates a new animation, merges it with the existing animations and starts it
  27704. * @param name Name of the animation
  27705. * @param node Node which contains the scene that begins the animations
  27706. * @param targetProperty Specifies which property to animate
  27707. * @param framePerSecond The frames per second of the animation
  27708. * @param totalFrame The total number of frames
  27709. * @param from The frame at the beginning of the animation
  27710. * @param to The frame at the end of the animation
  27711. * @param loopMode Specifies the loop mode of the animation
  27712. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27713. * @param onAnimationEnd Callback to run once the animation is complete
  27714. * @returns Nullable animation
  27715. */
  27716. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27717. /**
  27718. * Transition property of an host to the target Value
  27719. * @param property The property to transition
  27720. * @param targetValue The target Value of the property
  27721. * @param host The object where the property to animate belongs
  27722. * @param scene Scene used to run the animation
  27723. * @param frameRate Framerate (in frame/s) to use
  27724. * @param transition The transition type we want to use
  27725. * @param duration The duration of the animation, in milliseconds
  27726. * @param onAnimationEnd Callback trigger at the end of the animation
  27727. * @returns Nullable animation
  27728. */
  27729. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27730. /**
  27731. * Return the array of runtime animations currently using this animation
  27732. */
  27733. readonly runtimeAnimations: RuntimeAnimation[];
  27734. /**
  27735. * Specifies if any of the runtime animations are currently running
  27736. */
  27737. readonly hasRunningRuntimeAnimations: boolean;
  27738. /**
  27739. * Initializes the animation
  27740. * @param name Name of the animation
  27741. * @param targetProperty Property to animate
  27742. * @param framePerSecond The frames per second of the animation
  27743. * @param dataType The data type of the animation
  27744. * @param loopMode The loop mode of the animation
  27745. * @param enableBlending Specifies if blending should be enabled
  27746. */
  27747. constructor(
  27748. /**Name of the animation */
  27749. name: string,
  27750. /**Property to animate */
  27751. targetProperty: string,
  27752. /**The frames per second of the animation */
  27753. framePerSecond: number,
  27754. /**The data type of the animation */
  27755. dataType: number,
  27756. /**The loop mode of the animation */
  27757. loopMode?: number | undefined,
  27758. /**Specifies if blending should be enabled */
  27759. enableBlending?: boolean | undefined);
  27760. /**
  27761. * Converts the animation to a string
  27762. * @param fullDetails support for multiple levels of logging within scene loading
  27763. * @returns String form of the animation
  27764. */
  27765. toString(fullDetails?: boolean): string;
  27766. /**
  27767. * Add an event to this animation
  27768. * @param event Event to add
  27769. */
  27770. addEvent(event: AnimationEvent): void;
  27771. /**
  27772. * Remove all events found at the given frame
  27773. * @param frame The frame to remove events from
  27774. */
  27775. removeEvents(frame: number): void;
  27776. /**
  27777. * Retrieves all the events from the animation
  27778. * @returns Events from the animation
  27779. */
  27780. getEvents(): AnimationEvent[];
  27781. /**
  27782. * Creates an animation range
  27783. * @param name Name of the animation range
  27784. * @param from Starting frame of the animation range
  27785. * @param to Ending frame of the animation
  27786. */
  27787. createRange(name: string, from: number, to: number): void;
  27788. /**
  27789. * Deletes an animation range by name
  27790. * @param name Name of the animation range to delete
  27791. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27792. */
  27793. deleteRange(name: string, deleteFrames?: boolean): void;
  27794. /**
  27795. * Gets the animation range by name, or null if not defined
  27796. * @param name Name of the animation range
  27797. * @returns Nullable animation range
  27798. */
  27799. getRange(name: string): Nullable<AnimationRange>;
  27800. /**
  27801. * Gets the key frames from the animation
  27802. * @returns The key frames of the animation
  27803. */
  27804. getKeys(): Array<IAnimationKey>;
  27805. /**
  27806. * Gets the highest frame rate of the animation
  27807. * @returns Highest frame rate of the animation
  27808. */
  27809. getHighestFrame(): number;
  27810. /**
  27811. * Gets the easing function of the animation
  27812. * @returns Easing function of the animation
  27813. */
  27814. getEasingFunction(): IEasingFunction;
  27815. /**
  27816. * Sets the easing function of the animation
  27817. * @param easingFunction A custom mathematical formula for animation
  27818. */
  27819. setEasingFunction(easingFunction: EasingFunction): void;
  27820. /**
  27821. * Interpolates a scalar linearly
  27822. * @param startValue Start value of the animation curve
  27823. * @param endValue End value of the animation curve
  27824. * @param gradient Scalar amount to interpolate
  27825. * @returns Interpolated scalar value
  27826. */
  27827. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27828. /**
  27829. * Interpolates a scalar cubically
  27830. * @param startValue Start value of the animation curve
  27831. * @param outTangent End tangent of the animation
  27832. * @param endValue End value of the animation curve
  27833. * @param inTangent Start tangent of the animation curve
  27834. * @param gradient Scalar amount to interpolate
  27835. * @returns Interpolated scalar value
  27836. */
  27837. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27838. /**
  27839. * Interpolates a quaternion using a spherical linear interpolation
  27840. * @param startValue Start value of the animation curve
  27841. * @param endValue End value of the animation curve
  27842. * @param gradient Scalar amount to interpolate
  27843. * @returns Interpolated quaternion value
  27844. */
  27845. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27846. /**
  27847. * Interpolates a quaternion cubically
  27848. * @param startValue Start value of the animation curve
  27849. * @param outTangent End tangent of the animation curve
  27850. * @param endValue End value of the animation curve
  27851. * @param inTangent Start tangent of the animation curve
  27852. * @param gradient Scalar amount to interpolate
  27853. * @returns Interpolated quaternion value
  27854. */
  27855. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27856. /**
  27857. * Interpolates a Vector3 linearl
  27858. * @param startValue Start value of the animation curve
  27859. * @param endValue End value of the animation curve
  27860. * @param gradient Scalar amount to interpolate
  27861. * @returns Interpolated scalar value
  27862. */
  27863. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27864. /**
  27865. * Interpolates a Vector3 cubically
  27866. * @param startValue Start value of the animation curve
  27867. * @param outTangent End tangent of the animation
  27868. * @param endValue End value of the animation curve
  27869. * @param inTangent Start tangent of the animation curve
  27870. * @param gradient Scalar amount to interpolate
  27871. * @returns InterpolatedVector3 value
  27872. */
  27873. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27874. /**
  27875. * Interpolates a Vector2 linearly
  27876. * @param startValue Start value of the animation curve
  27877. * @param endValue End value of the animation curve
  27878. * @param gradient Scalar amount to interpolate
  27879. * @returns Interpolated Vector2 value
  27880. */
  27881. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27882. /**
  27883. * Interpolates a Vector2 cubically
  27884. * @param startValue Start value of the animation curve
  27885. * @param outTangent End tangent of the animation
  27886. * @param endValue End value of the animation curve
  27887. * @param inTangent Start tangent of the animation curve
  27888. * @param gradient Scalar amount to interpolate
  27889. * @returns Interpolated Vector2 value
  27890. */
  27891. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27892. /**
  27893. * Interpolates a size linearly
  27894. * @param startValue Start value of the animation curve
  27895. * @param endValue End value of the animation curve
  27896. * @param gradient Scalar amount to interpolate
  27897. * @returns Interpolated Size value
  27898. */
  27899. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27900. /**
  27901. * Interpolates a Color3 linearly
  27902. * @param startValue Start value of the animation curve
  27903. * @param endValue End value of the animation curve
  27904. * @param gradient Scalar amount to interpolate
  27905. * @returns Interpolated Color3 value
  27906. */
  27907. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27908. /**
  27909. * @hidden Internal use only
  27910. */
  27911. _getKeyValue(value: any): any;
  27912. /**
  27913. * @hidden Internal use only
  27914. */
  27915. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27916. /**
  27917. * Defines the function to use to interpolate matrices
  27918. * @param startValue defines the start matrix
  27919. * @param endValue defines the end matrix
  27920. * @param gradient defines the gradient between both matrices
  27921. * @param result defines an optional target matrix where to store the interpolation
  27922. * @returns the interpolated matrix
  27923. */
  27924. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27925. /**
  27926. * Makes a copy of the animation
  27927. * @returns Cloned animation
  27928. */
  27929. clone(): Animation;
  27930. /**
  27931. * Sets the key frames of the animation
  27932. * @param values The animation key frames to set
  27933. */
  27934. setKeys(values: Array<IAnimationKey>): void;
  27935. /**
  27936. * Serializes the animation to an object
  27937. * @returns Serialized object
  27938. */
  27939. serialize(): any;
  27940. /**
  27941. * Float animation type
  27942. */
  27943. private static _ANIMATIONTYPE_FLOAT;
  27944. /**
  27945. * Vector3 animation type
  27946. */
  27947. private static _ANIMATIONTYPE_VECTOR3;
  27948. /**
  27949. * Quaternion animation type
  27950. */
  27951. private static _ANIMATIONTYPE_QUATERNION;
  27952. /**
  27953. * Matrix animation type
  27954. */
  27955. private static _ANIMATIONTYPE_MATRIX;
  27956. /**
  27957. * Color3 animation type
  27958. */
  27959. private static _ANIMATIONTYPE_COLOR3;
  27960. /**
  27961. * Vector2 animation type
  27962. */
  27963. private static _ANIMATIONTYPE_VECTOR2;
  27964. /**
  27965. * Size animation type
  27966. */
  27967. private static _ANIMATIONTYPE_SIZE;
  27968. /**
  27969. * Relative Loop Mode
  27970. */
  27971. private static _ANIMATIONLOOPMODE_RELATIVE;
  27972. /**
  27973. * Cycle Loop Mode
  27974. */
  27975. private static _ANIMATIONLOOPMODE_CYCLE;
  27976. /**
  27977. * Constant Loop Mode
  27978. */
  27979. private static _ANIMATIONLOOPMODE_CONSTANT;
  27980. /**
  27981. * Get the float animation type
  27982. */
  27983. static readonly ANIMATIONTYPE_FLOAT: number;
  27984. /**
  27985. * Get the Vector3 animation type
  27986. */
  27987. static readonly ANIMATIONTYPE_VECTOR3: number;
  27988. /**
  27989. * Get the Vector2 animation type
  27990. */
  27991. static readonly ANIMATIONTYPE_VECTOR2: number;
  27992. /**
  27993. * Get the Size animation type
  27994. */
  27995. static readonly ANIMATIONTYPE_SIZE: number;
  27996. /**
  27997. * Get the Quaternion animation type
  27998. */
  27999. static readonly ANIMATIONTYPE_QUATERNION: number;
  28000. /**
  28001. * Get the Matrix animation type
  28002. */
  28003. static readonly ANIMATIONTYPE_MATRIX: number;
  28004. /**
  28005. * Get the Color3 animation type
  28006. */
  28007. static readonly ANIMATIONTYPE_COLOR3: number;
  28008. /**
  28009. * Get the Relative Loop Mode
  28010. */
  28011. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28012. /**
  28013. * Get the Cycle Loop Mode
  28014. */
  28015. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28016. /**
  28017. * Get the Constant Loop Mode
  28018. */
  28019. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28020. /** @hidden */
  28021. static _UniversalLerp(left: any, right: any, amount: number): any;
  28022. /**
  28023. * Parses an animation object and creates an animation
  28024. * @param parsedAnimation Parsed animation object
  28025. * @returns Animation object
  28026. */
  28027. static Parse(parsedAnimation: any): Animation;
  28028. /**
  28029. * Appends the serialized animations from the source animations
  28030. * @param source Source containing the animations
  28031. * @param destination Target to store the animations
  28032. */
  28033. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28034. }
  28035. }
  28036. declare module "babylonjs/Animations/animatable.interface" {
  28037. import { Nullable } from "babylonjs/types";
  28038. import { Animation } from "babylonjs/Animations/animation";
  28039. /**
  28040. * Interface containing an array of animations
  28041. */
  28042. export interface IAnimatable {
  28043. /**
  28044. * Array of animations
  28045. */
  28046. animations: Nullable<Array<Animation>>;
  28047. }
  28048. }
  28049. declare module "babylonjs/Materials/fresnelParameters" {
  28050. import { Color3 } from "babylonjs/Maths/math.color";
  28051. /**
  28052. * This represents all the required information to add a fresnel effect on a material:
  28053. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28054. */
  28055. export class FresnelParameters {
  28056. private _isEnabled;
  28057. /**
  28058. * Define if the fresnel effect is enable or not.
  28059. */
  28060. isEnabled: boolean;
  28061. /**
  28062. * Define the color used on edges (grazing angle)
  28063. */
  28064. leftColor: Color3;
  28065. /**
  28066. * Define the color used on center
  28067. */
  28068. rightColor: Color3;
  28069. /**
  28070. * Define bias applied to computed fresnel term
  28071. */
  28072. bias: number;
  28073. /**
  28074. * Defined the power exponent applied to fresnel term
  28075. */
  28076. power: number;
  28077. /**
  28078. * Clones the current fresnel and its valuues
  28079. * @returns a clone fresnel configuration
  28080. */
  28081. clone(): FresnelParameters;
  28082. /**
  28083. * Serializes the current fresnel parameters to a JSON representation.
  28084. * @return the JSON serialization
  28085. */
  28086. serialize(): any;
  28087. /**
  28088. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28089. * @param parsedFresnelParameters Define the JSON representation
  28090. * @returns the parsed parameters
  28091. */
  28092. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28093. }
  28094. }
  28095. declare module "babylonjs/Misc/decorators" {
  28096. import { Nullable } from "babylonjs/types";
  28097. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28098. import { Scene } from "babylonjs/scene";
  28099. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28100. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28101. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28102. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28103. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28104. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28105. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28106. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28107. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28108. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28109. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28110. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28111. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28112. /**
  28113. * Decorator used to define property that can be serialized as reference to a camera
  28114. * @param sourceName defines the name of the property to decorate
  28115. */
  28116. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28117. /**
  28118. * Class used to help serialization objects
  28119. */
  28120. export class SerializationHelper {
  28121. /** @hidden */
  28122. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28123. /** @hidden */
  28124. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28125. /** @hidden */
  28126. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28127. /** @hidden */
  28128. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28129. /**
  28130. * Appends the serialized animations from the source animations
  28131. * @param source Source containing the animations
  28132. * @param destination Target to store the animations
  28133. */
  28134. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28135. /**
  28136. * Static function used to serialized a specific entity
  28137. * @param entity defines the entity to serialize
  28138. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28139. * @returns a JSON compatible object representing the serialization of the entity
  28140. */
  28141. static Serialize<T>(entity: T, serializationObject?: any): any;
  28142. /**
  28143. * Creates a new entity from a serialization data object
  28144. * @param creationFunction defines a function used to instanciated the new entity
  28145. * @param source defines the source serialization data
  28146. * @param scene defines the hosting scene
  28147. * @param rootUrl defines the root url for resources
  28148. * @returns a new entity
  28149. */
  28150. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28151. /**
  28152. * Clones an object
  28153. * @param creationFunction defines the function used to instanciate the new object
  28154. * @param source defines the source object
  28155. * @returns the cloned object
  28156. */
  28157. static Clone<T>(creationFunction: () => T, source: T): T;
  28158. /**
  28159. * Instanciates a new object based on a source one (some data will be shared between both object)
  28160. * @param creationFunction defines the function used to instanciate the new object
  28161. * @param source defines the source object
  28162. * @returns the new object
  28163. */
  28164. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28165. }
  28166. }
  28167. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28168. import { Nullable } from "babylonjs/types";
  28169. /**
  28170. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28171. */
  28172. export interface CubeMapInfo {
  28173. /**
  28174. * The pixel array for the front face.
  28175. * This is stored in format, left to right, up to down format.
  28176. */
  28177. front: Nullable<ArrayBufferView>;
  28178. /**
  28179. * The pixel array for the back face.
  28180. * This is stored in format, left to right, up to down format.
  28181. */
  28182. back: Nullable<ArrayBufferView>;
  28183. /**
  28184. * The pixel array for the left face.
  28185. * This is stored in format, left to right, up to down format.
  28186. */
  28187. left: Nullable<ArrayBufferView>;
  28188. /**
  28189. * The pixel array for the right face.
  28190. * This is stored in format, left to right, up to down format.
  28191. */
  28192. right: Nullable<ArrayBufferView>;
  28193. /**
  28194. * The pixel array for the up face.
  28195. * This is stored in format, left to right, up to down format.
  28196. */
  28197. up: Nullable<ArrayBufferView>;
  28198. /**
  28199. * The pixel array for the down face.
  28200. * This is stored in format, left to right, up to down format.
  28201. */
  28202. down: Nullable<ArrayBufferView>;
  28203. /**
  28204. * The size of the cubemap stored.
  28205. *
  28206. * Each faces will be size * size pixels.
  28207. */
  28208. size: number;
  28209. /**
  28210. * The format of the texture.
  28211. *
  28212. * RGBA, RGB.
  28213. */
  28214. format: number;
  28215. /**
  28216. * The type of the texture data.
  28217. *
  28218. * UNSIGNED_INT, FLOAT.
  28219. */
  28220. type: number;
  28221. /**
  28222. * Specifies whether the texture is in gamma space.
  28223. */
  28224. gammaSpace: boolean;
  28225. }
  28226. /**
  28227. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28228. */
  28229. export class PanoramaToCubeMapTools {
  28230. private static FACE_FRONT;
  28231. private static FACE_BACK;
  28232. private static FACE_RIGHT;
  28233. private static FACE_LEFT;
  28234. private static FACE_DOWN;
  28235. private static FACE_UP;
  28236. /**
  28237. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28238. *
  28239. * @param float32Array The source data.
  28240. * @param inputWidth The width of the input panorama.
  28241. * @param inputHeight The height of the input panorama.
  28242. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28243. * @return The cubemap data
  28244. */
  28245. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28246. private static CreateCubemapTexture;
  28247. private static CalcProjectionSpherical;
  28248. }
  28249. }
  28250. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28251. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28252. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28253. import { Nullable } from "babylonjs/types";
  28254. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28255. /**
  28256. * Helper class dealing with the extraction of spherical polynomial dataArray
  28257. * from a cube map.
  28258. */
  28259. export class CubeMapToSphericalPolynomialTools {
  28260. private static FileFaces;
  28261. /**
  28262. * Converts a texture to the according Spherical Polynomial data.
  28263. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28264. *
  28265. * @param texture The texture to extract the information from.
  28266. * @return The Spherical Polynomial data.
  28267. */
  28268. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28269. /**
  28270. * Converts a cubemap to the according Spherical Polynomial data.
  28271. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28272. *
  28273. * @param cubeInfo The Cube map to extract the information from.
  28274. * @return The Spherical Polynomial data.
  28275. */
  28276. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28277. }
  28278. }
  28279. declare module "babylonjs/Misc/guid" {
  28280. /**
  28281. * Class used to manipulate GUIDs
  28282. */
  28283. export class GUID {
  28284. /**
  28285. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28286. * Be aware Math.random() could cause collisions, but:
  28287. * "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"
  28288. * @returns a pseudo random id
  28289. */
  28290. static RandomId(): string;
  28291. }
  28292. }
  28293. declare module "babylonjs/Materials/Textures/baseTexture" {
  28294. import { Observable } from "babylonjs/Misc/observable";
  28295. import { Nullable } from "babylonjs/types";
  28296. import { Scene } from "babylonjs/scene";
  28297. import { Matrix } from "babylonjs/Maths/math.vector";
  28298. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28300. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28301. import { ISize } from "babylonjs/Maths/math.size";
  28302. /**
  28303. * Base class of all the textures in babylon.
  28304. * It groups all the common properties the materials, post process, lights... might need
  28305. * in order to make a correct use of the texture.
  28306. */
  28307. export class BaseTexture implements IAnimatable {
  28308. /**
  28309. * Default anisotropic filtering level for the application.
  28310. * It is set to 4 as a good tradeoff between perf and quality.
  28311. */
  28312. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28313. /**
  28314. * Gets or sets the unique id of the texture
  28315. */
  28316. uniqueId: number;
  28317. /**
  28318. * Define the name of the texture.
  28319. */
  28320. name: string;
  28321. /**
  28322. * Gets or sets an object used to store user defined information.
  28323. */
  28324. metadata: any;
  28325. /**
  28326. * For internal use only. Please do not use.
  28327. */
  28328. reservedDataStore: any;
  28329. private _hasAlpha;
  28330. /**
  28331. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28332. */
  28333. hasAlpha: boolean;
  28334. /**
  28335. * Defines if the alpha value should be determined via the rgb values.
  28336. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28337. */
  28338. getAlphaFromRGB: boolean;
  28339. /**
  28340. * Intensity or strength of the texture.
  28341. * It is commonly used by materials to fine tune the intensity of the texture
  28342. */
  28343. level: number;
  28344. /**
  28345. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28346. * This is part of the texture as textures usually maps to one uv set.
  28347. */
  28348. coordinatesIndex: number;
  28349. private _coordinatesMode;
  28350. /**
  28351. * How a texture is mapped.
  28352. *
  28353. * | Value | Type | Description |
  28354. * | ----- | ----------------------------------- | ----------- |
  28355. * | 0 | EXPLICIT_MODE | |
  28356. * | 1 | SPHERICAL_MODE | |
  28357. * | 2 | PLANAR_MODE | |
  28358. * | 3 | CUBIC_MODE | |
  28359. * | 4 | PROJECTION_MODE | |
  28360. * | 5 | SKYBOX_MODE | |
  28361. * | 6 | INVCUBIC_MODE | |
  28362. * | 7 | EQUIRECTANGULAR_MODE | |
  28363. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28364. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28365. */
  28366. coordinatesMode: number;
  28367. /**
  28368. * | Value | Type | Description |
  28369. * | ----- | ------------------ | ----------- |
  28370. * | 0 | CLAMP_ADDRESSMODE | |
  28371. * | 1 | WRAP_ADDRESSMODE | |
  28372. * | 2 | MIRROR_ADDRESSMODE | |
  28373. */
  28374. wrapU: number;
  28375. /**
  28376. * | Value | Type | Description |
  28377. * | ----- | ------------------ | ----------- |
  28378. * | 0 | CLAMP_ADDRESSMODE | |
  28379. * | 1 | WRAP_ADDRESSMODE | |
  28380. * | 2 | MIRROR_ADDRESSMODE | |
  28381. */
  28382. wrapV: number;
  28383. /**
  28384. * | Value | Type | Description |
  28385. * | ----- | ------------------ | ----------- |
  28386. * | 0 | CLAMP_ADDRESSMODE | |
  28387. * | 1 | WRAP_ADDRESSMODE | |
  28388. * | 2 | MIRROR_ADDRESSMODE | |
  28389. */
  28390. wrapR: number;
  28391. /**
  28392. * With compliant hardware and browser (supporting anisotropic filtering)
  28393. * this defines the level of anisotropic filtering in the texture.
  28394. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28395. */
  28396. anisotropicFilteringLevel: number;
  28397. /**
  28398. * Define if the texture is a cube texture or if false a 2d texture.
  28399. */
  28400. isCube: boolean;
  28401. /**
  28402. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28403. */
  28404. is3D: boolean;
  28405. /**
  28406. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28407. * HDR texture are usually stored in linear space.
  28408. * This only impacts the PBR and Background materials
  28409. */
  28410. gammaSpace: boolean;
  28411. /**
  28412. * Gets whether or not the texture contains RGBD data.
  28413. */
  28414. readonly isRGBD: boolean;
  28415. /**
  28416. * Is Z inverted in the texture (useful in a cube texture).
  28417. */
  28418. invertZ: boolean;
  28419. /**
  28420. * Are mip maps generated for this texture or not.
  28421. */
  28422. readonly noMipmap: boolean;
  28423. /**
  28424. * @hidden
  28425. */
  28426. lodLevelInAlpha: boolean;
  28427. /**
  28428. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28429. */
  28430. lodGenerationOffset: number;
  28431. /**
  28432. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28433. */
  28434. lodGenerationScale: number;
  28435. /**
  28436. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28437. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28438. * average roughness values.
  28439. */
  28440. linearSpecularLOD: boolean;
  28441. /**
  28442. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28443. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28444. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28445. */
  28446. irradianceTexture: Nullable<BaseTexture>;
  28447. /**
  28448. * Define if the texture is a render target.
  28449. */
  28450. isRenderTarget: boolean;
  28451. /**
  28452. * Define the unique id of the texture in the scene.
  28453. */
  28454. readonly uid: string;
  28455. /**
  28456. * Return a string representation of the texture.
  28457. * @returns the texture as a string
  28458. */
  28459. toString(): string;
  28460. /**
  28461. * Get the class name of the texture.
  28462. * @returns "BaseTexture"
  28463. */
  28464. getClassName(): string;
  28465. /**
  28466. * Define the list of animation attached to the texture.
  28467. */
  28468. animations: import("babylonjs/Animations/animation").Animation[];
  28469. /**
  28470. * An event triggered when the texture is disposed.
  28471. */
  28472. onDisposeObservable: Observable<BaseTexture>;
  28473. private _onDisposeObserver;
  28474. /**
  28475. * Callback triggered when the texture has been disposed.
  28476. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28477. */
  28478. onDispose: () => void;
  28479. /**
  28480. * Define the current state of the loading sequence when in delayed load mode.
  28481. */
  28482. delayLoadState: number;
  28483. private _scene;
  28484. /** @hidden */
  28485. _texture: Nullable<InternalTexture>;
  28486. private _uid;
  28487. /**
  28488. * Define if the texture is preventinga material to render or not.
  28489. * If not and the texture is not ready, the engine will use a default black texture instead.
  28490. */
  28491. readonly isBlocking: boolean;
  28492. /**
  28493. * Instantiates a new BaseTexture.
  28494. * Base class of all the textures in babylon.
  28495. * It groups all the common properties the materials, post process, lights... might need
  28496. * in order to make a correct use of the texture.
  28497. * @param scene Define the scene the texture blongs to
  28498. */
  28499. constructor(scene: Nullable<Scene>);
  28500. /**
  28501. * Get the scene the texture belongs to.
  28502. * @returns the scene or null if undefined
  28503. */
  28504. getScene(): Nullable<Scene>;
  28505. /**
  28506. * Get the texture transform matrix used to offset tile the texture for istance.
  28507. * @returns the transformation matrix
  28508. */
  28509. getTextureMatrix(): Matrix;
  28510. /**
  28511. * Get the texture reflection matrix used to rotate/transform the reflection.
  28512. * @returns the reflection matrix
  28513. */
  28514. getReflectionTextureMatrix(): Matrix;
  28515. /**
  28516. * Get the underlying lower level texture from Babylon.
  28517. * @returns the insternal texture
  28518. */
  28519. getInternalTexture(): Nullable<InternalTexture>;
  28520. /**
  28521. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28522. * @returns true if ready or not blocking
  28523. */
  28524. isReadyOrNotBlocking(): boolean;
  28525. /**
  28526. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28527. * @returns true if fully ready
  28528. */
  28529. isReady(): boolean;
  28530. private _cachedSize;
  28531. /**
  28532. * Get the size of the texture.
  28533. * @returns the texture size.
  28534. */
  28535. getSize(): ISize;
  28536. /**
  28537. * Get the base size of the texture.
  28538. * It can be different from the size if the texture has been resized for POT for instance
  28539. * @returns the base size
  28540. */
  28541. getBaseSize(): ISize;
  28542. /**
  28543. * Update the sampling mode of the texture.
  28544. * Default is Trilinear mode.
  28545. *
  28546. * | Value | Type | Description |
  28547. * | ----- | ------------------ | ----------- |
  28548. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28549. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28550. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28551. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28552. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28553. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28554. * | 7 | NEAREST_LINEAR | |
  28555. * | 8 | NEAREST_NEAREST | |
  28556. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28557. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28558. * | 11 | LINEAR_LINEAR | |
  28559. * | 12 | LINEAR_NEAREST | |
  28560. *
  28561. * > _mag_: magnification filter (close to the viewer)
  28562. * > _min_: minification filter (far from the viewer)
  28563. * > _mip_: filter used between mip map levels
  28564. *@param samplingMode Define the new sampling mode of the texture
  28565. */
  28566. updateSamplingMode(samplingMode: number): void;
  28567. /**
  28568. * Scales the texture if is `canRescale()`
  28569. * @param ratio the resize factor we want to use to rescale
  28570. */
  28571. scale(ratio: number): void;
  28572. /**
  28573. * Get if the texture can rescale.
  28574. */
  28575. readonly canRescale: boolean;
  28576. /** @hidden */
  28577. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28578. /** @hidden */
  28579. _rebuild(): void;
  28580. /**
  28581. * Triggers the load sequence in delayed load mode.
  28582. */
  28583. delayLoad(): void;
  28584. /**
  28585. * Clones the texture.
  28586. * @returns the cloned texture
  28587. */
  28588. clone(): Nullable<BaseTexture>;
  28589. /**
  28590. * Get the texture underlying type (INT, FLOAT...)
  28591. */
  28592. readonly textureType: number;
  28593. /**
  28594. * Get the texture underlying format (RGB, RGBA...)
  28595. */
  28596. readonly textureFormat: number;
  28597. /**
  28598. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28599. * This will returns an RGBA array buffer containing either in values (0-255) or
  28600. * float values (0-1) depending of the underlying buffer type.
  28601. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28602. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28603. * @param buffer defines a user defined buffer to fill with data (can be null)
  28604. * @returns The Array buffer containing the pixels data.
  28605. */
  28606. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28607. /**
  28608. * Release and destroy the underlying lower level texture aka internalTexture.
  28609. */
  28610. releaseInternalTexture(): void;
  28611. /**
  28612. * Get the polynomial representation of the texture data.
  28613. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28614. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28615. */
  28616. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28617. /** @hidden */
  28618. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28619. /** @hidden */
  28620. readonly _lodTextureMid: Nullable<BaseTexture>;
  28621. /** @hidden */
  28622. readonly _lodTextureLow: Nullable<BaseTexture>;
  28623. /**
  28624. * Dispose the texture and release its associated resources.
  28625. */
  28626. dispose(): void;
  28627. /**
  28628. * Serialize the texture into a JSON representation that can be parsed later on.
  28629. * @returns the JSON representation of the texture
  28630. */
  28631. serialize(): any;
  28632. /**
  28633. * Helper function to be called back once a list of texture contains only ready textures.
  28634. * @param textures Define the list of textures to wait for
  28635. * @param callback Define the callback triggered once the entire list will be ready
  28636. */
  28637. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28638. }
  28639. }
  28640. declare module "babylonjs/Materials/Textures/internalTexture" {
  28641. import { Observable } from "babylonjs/Misc/observable";
  28642. import { Nullable, int } from "babylonjs/types";
  28643. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28644. import { Engine } from "babylonjs/Engines/engine";
  28645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28646. /**
  28647. * Class used to store data associated with WebGL texture data for the engine
  28648. * This class should not be used directly
  28649. */
  28650. export class InternalTexture {
  28651. /** @hidden */
  28652. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28653. /**
  28654. * The source of the texture data is unknown
  28655. */
  28656. static DATASOURCE_UNKNOWN: number;
  28657. /**
  28658. * Texture data comes from an URL
  28659. */
  28660. static DATASOURCE_URL: number;
  28661. /**
  28662. * Texture data is only used for temporary storage
  28663. */
  28664. static DATASOURCE_TEMP: number;
  28665. /**
  28666. * Texture data comes from raw data (ArrayBuffer)
  28667. */
  28668. static DATASOURCE_RAW: number;
  28669. /**
  28670. * Texture content is dynamic (video or dynamic texture)
  28671. */
  28672. static DATASOURCE_DYNAMIC: number;
  28673. /**
  28674. * Texture content is generated by rendering to it
  28675. */
  28676. static DATASOURCE_RENDERTARGET: number;
  28677. /**
  28678. * Texture content is part of a multi render target process
  28679. */
  28680. static DATASOURCE_MULTIRENDERTARGET: number;
  28681. /**
  28682. * Texture data comes from a cube data file
  28683. */
  28684. static DATASOURCE_CUBE: number;
  28685. /**
  28686. * Texture data comes from a raw cube data
  28687. */
  28688. static DATASOURCE_CUBERAW: number;
  28689. /**
  28690. * Texture data come from a prefiltered cube data file
  28691. */
  28692. static DATASOURCE_CUBEPREFILTERED: number;
  28693. /**
  28694. * Texture content is raw 3D data
  28695. */
  28696. static DATASOURCE_RAW3D: number;
  28697. /**
  28698. * Texture content is a depth texture
  28699. */
  28700. static DATASOURCE_DEPTHTEXTURE: number;
  28701. /**
  28702. * Texture data comes from a raw cube data encoded with RGBD
  28703. */
  28704. static DATASOURCE_CUBERAW_RGBD: number;
  28705. /**
  28706. * Defines if the texture is ready
  28707. */
  28708. isReady: boolean;
  28709. /**
  28710. * Defines if the texture is a cube texture
  28711. */
  28712. isCube: boolean;
  28713. /**
  28714. * Defines if the texture contains 3D data
  28715. */
  28716. is3D: boolean;
  28717. /**
  28718. * Defines if the texture contains multiview data
  28719. */
  28720. isMultiview: boolean;
  28721. /**
  28722. * Gets the URL used to load this texture
  28723. */
  28724. url: string;
  28725. /**
  28726. * Gets the sampling mode of the texture
  28727. */
  28728. samplingMode: number;
  28729. /**
  28730. * Gets a boolean indicating if the texture needs mipmaps generation
  28731. */
  28732. generateMipMaps: boolean;
  28733. /**
  28734. * Gets the number of samples used by the texture (WebGL2+ only)
  28735. */
  28736. samples: number;
  28737. /**
  28738. * Gets the type of the texture (int, float...)
  28739. */
  28740. type: number;
  28741. /**
  28742. * Gets the format of the texture (RGB, RGBA...)
  28743. */
  28744. format: number;
  28745. /**
  28746. * Observable called when the texture is loaded
  28747. */
  28748. onLoadedObservable: Observable<InternalTexture>;
  28749. /**
  28750. * Gets the width of the texture
  28751. */
  28752. width: number;
  28753. /**
  28754. * Gets the height of the texture
  28755. */
  28756. height: number;
  28757. /**
  28758. * Gets the depth of the texture
  28759. */
  28760. depth: number;
  28761. /**
  28762. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28763. */
  28764. baseWidth: number;
  28765. /**
  28766. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28767. */
  28768. baseHeight: number;
  28769. /**
  28770. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28771. */
  28772. baseDepth: number;
  28773. /**
  28774. * Gets a boolean indicating if the texture is inverted on Y axis
  28775. */
  28776. invertY: boolean;
  28777. /** @hidden */
  28778. _invertVScale: boolean;
  28779. /** @hidden */
  28780. _associatedChannel: number;
  28781. /** @hidden */
  28782. _dataSource: number;
  28783. /** @hidden */
  28784. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28785. /** @hidden */
  28786. _bufferView: Nullable<ArrayBufferView>;
  28787. /** @hidden */
  28788. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28789. /** @hidden */
  28790. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28791. /** @hidden */
  28792. _size: number;
  28793. /** @hidden */
  28794. _extension: string;
  28795. /** @hidden */
  28796. _files: Nullable<string[]>;
  28797. /** @hidden */
  28798. _workingCanvas: Nullable<HTMLCanvasElement>;
  28799. /** @hidden */
  28800. _workingContext: Nullable<CanvasRenderingContext2D>;
  28801. /** @hidden */
  28802. _framebuffer: Nullable<WebGLFramebuffer>;
  28803. /** @hidden */
  28804. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28805. /** @hidden */
  28806. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28807. /** @hidden */
  28808. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28809. /** @hidden */
  28810. _attachments: Nullable<number[]>;
  28811. /** @hidden */
  28812. _cachedCoordinatesMode: Nullable<number>;
  28813. /** @hidden */
  28814. _cachedWrapU: Nullable<number>;
  28815. /** @hidden */
  28816. _cachedWrapV: Nullable<number>;
  28817. /** @hidden */
  28818. _cachedWrapR: Nullable<number>;
  28819. /** @hidden */
  28820. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28821. /** @hidden */
  28822. _isDisabled: boolean;
  28823. /** @hidden */
  28824. _compression: Nullable<string>;
  28825. /** @hidden */
  28826. _generateStencilBuffer: boolean;
  28827. /** @hidden */
  28828. _generateDepthBuffer: boolean;
  28829. /** @hidden */
  28830. _comparisonFunction: number;
  28831. /** @hidden */
  28832. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28833. /** @hidden */
  28834. _lodGenerationScale: number;
  28835. /** @hidden */
  28836. _lodGenerationOffset: number;
  28837. /** @hidden */
  28838. _colorTextureArray: Nullable<WebGLTexture>;
  28839. /** @hidden */
  28840. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28841. /** @hidden */
  28842. _lodTextureHigh: Nullable<BaseTexture>;
  28843. /** @hidden */
  28844. _lodTextureMid: Nullable<BaseTexture>;
  28845. /** @hidden */
  28846. _lodTextureLow: Nullable<BaseTexture>;
  28847. /** @hidden */
  28848. _isRGBD: boolean;
  28849. /** @hidden */
  28850. _linearSpecularLOD: boolean;
  28851. /** @hidden */
  28852. _irradianceTexture: Nullable<BaseTexture>;
  28853. /** @hidden */
  28854. _webGLTexture: Nullable<WebGLTexture>;
  28855. /** @hidden */
  28856. _references: number;
  28857. private _engine;
  28858. /**
  28859. * Gets the Engine the texture belongs to.
  28860. * @returns The babylon engine
  28861. */
  28862. getEngine(): Engine;
  28863. /**
  28864. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28865. */
  28866. readonly dataSource: number;
  28867. /**
  28868. * Creates a new InternalTexture
  28869. * @param engine defines the engine to use
  28870. * @param dataSource defines the type of data that will be used
  28871. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28872. */
  28873. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28874. /**
  28875. * Increments the number of references (ie. the number of Texture that point to it)
  28876. */
  28877. incrementReferences(): void;
  28878. /**
  28879. * Change the size of the texture (not the size of the content)
  28880. * @param width defines the new width
  28881. * @param height defines the new height
  28882. * @param depth defines the new depth (1 by default)
  28883. */
  28884. updateSize(width: int, height: int, depth?: int): void;
  28885. /** @hidden */
  28886. _rebuild(): void;
  28887. /** @hidden */
  28888. _swapAndDie(target: InternalTexture): void;
  28889. /**
  28890. * Dispose the current allocated resources
  28891. */
  28892. dispose(): void;
  28893. }
  28894. }
  28895. declare module "babylonjs/Materials/effect" {
  28896. import { Observable } from "babylonjs/Misc/observable";
  28897. import { Nullable } from "babylonjs/types";
  28898. import { IDisposable } from "babylonjs/scene";
  28899. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28900. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28901. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28902. import { Engine } from "babylonjs/Engines/engine";
  28903. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28905. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28906. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28908. /**
  28909. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28910. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28911. */
  28912. export class EffectFallbacks {
  28913. private _defines;
  28914. private _currentRank;
  28915. private _maxRank;
  28916. private _mesh;
  28917. /**
  28918. * Removes the fallback from the bound mesh.
  28919. */
  28920. unBindMesh(): void;
  28921. /**
  28922. * Adds a fallback on the specified property.
  28923. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28924. * @param define The name of the define in the shader
  28925. */
  28926. addFallback(rank: number, define: string): void;
  28927. /**
  28928. * Sets the mesh to use CPU skinning when needing to fallback.
  28929. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28930. * @param mesh The mesh to use the fallbacks.
  28931. */
  28932. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28933. /**
  28934. * Checks to see if more fallbacks are still availible.
  28935. */
  28936. readonly isMoreFallbacks: boolean;
  28937. /**
  28938. * Removes the defines that should be removed when falling back.
  28939. * @param currentDefines defines the current define statements for the shader.
  28940. * @param effect defines the current effect we try to compile
  28941. * @returns The resulting defines with defines of the current rank removed.
  28942. */
  28943. reduce(currentDefines: string, effect: Effect): string;
  28944. }
  28945. /**
  28946. * Options to be used when creating an effect.
  28947. */
  28948. export class EffectCreationOptions {
  28949. /**
  28950. * Atrributes that will be used in the shader.
  28951. */
  28952. attributes: string[];
  28953. /**
  28954. * Uniform varible names that will be set in the shader.
  28955. */
  28956. uniformsNames: string[];
  28957. /**
  28958. * Uniform buffer varible names that will be set in the shader.
  28959. */
  28960. uniformBuffersNames: string[];
  28961. /**
  28962. * Sampler texture variable names that will be set in the shader.
  28963. */
  28964. samplers: string[];
  28965. /**
  28966. * Define statements that will be set in the shader.
  28967. */
  28968. defines: any;
  28969. /**
  28970. * Possible fallbacks for this effect to improve performance when needed.
  28971. */
  28972. fallbacks: Nullable<EffectFallbacks>;
  28973. /**
  28974. * Callback that will be called when the shader is compiled.
  28975. */
  28976. onCompiled: Nullable<(effect: Effect) => void>;
  28977. /**
  28978. * Callback that will be called if an error occurs during shader compilation.
  28979. */
  28980. onError: Nullable<(effect: Effect, errors: string) => void>;
  28981. /**
  28982. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28983. */
  28984. indexParameters: any;
  28985. /**
  28986. * Max number of lights that can be used in the shader.
  28987. */
  28988. maxSimultaneousLights: number;
  28989. /**
  28990. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28991. */
  28992. transformFeedbackVaryings: Nullable<string[]>;
  28993. }
  28994. /**
  28995. * Effect containing vertex and fragment shader that can be executed on an object.
  28996. */
  28997. export class Effect implements IDisposable {
  28998. /**
  28999. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29000. */
  29001. static ShadersRepository: string;
  29002. /**
  29003. * Name of the effect.
  29004. */
  29005. name: any;
  29006. /**
  29007. * String container all the define statements that should be set on the shader.
  29008. */
  29009. defines: string;
  29010. /**
  29011. * Callback that will be called when the shader is compiled.
  29012. */
  29013. onCompiled: Nullable<(effect: Effect) => void>;
  29014. /**
  29015. * Callback that will be called if an error occurs during shader compilation.
  29016. */
  29017. onError: Nullable<(effect: Effect, errors: string) => void>;
  29018. /**
  29019. * Callback that will be called when effect is bound.
  29020. */
  29021. onBind: Nullable<(effect: Effect) => void>;
  29022. /**
  29023. * Unique ID of the effect.
  29024. */
  29025. uniqueId: number;
  29026. /**
  29027. * Observable that will be called when the shader is compiled.
  29028. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29029. */
  29030. onCompileObservable: Observable<Effect>;
  29031. /**
  29032. * Observable that will be called if an error occurs during shader compilation.
  29033. */
  29034. onErrorObservable: Observable<Effect>;
  29035. /** @hidden */
  29036. _onBindObservable: Nullable<Observable<Effect>>;
  29037. /**
  29038. * Observable that will be called when effect is bound.
  29039. */
  29040. readonly onBindObservable: Observable<Effect>;
  29041. /** @hidden */
  29042. _bonesComputationForcedToCPU: boolean;
  29043. private static _uniqueIdSeed;
  29044. private _engine;
  29045. private _uniformBuffersNames;
  29046. private _uniformsNames;
  29047. private _samplerList;
  29048. private _samplers;
  29049. private _isReady;
  29050. private _compilationError;
  29051. private _attributesNames;
  29052. private _attributes;
  29053. private _uniforms;
  29054. /**
  29055. * Key for the effect.
  29056. * @hidden
  29057. */
  29058. _key: string;
  29059. private _indexParameters;
  29060. private _fallbacks;
  29061. private _vertexSourceCode;
  29062. private _fragmentSourceCode;
  29063. private _vertexSourceCodeOverride;
  29064. private _fragmentSourceCodeOverride;
  29065. private _transformFeedbackVaryings;
  29066. /**
  29067. * Compiled shader to webGL program.
  29068. * @hidden
  29069. */
  29070. _pipelineContext: Nullable<IPipelineContext>;
  29071. private _valueCache;
  29072. private static _baseCache;
  29073. /**
  29074. * Instantiates an effect.
  29075. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29076. * @param baseName Name of the effect.
  29077. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29078. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29079. * @param samplers List of sampler variables that will be passed to the shader.
  29080. * @param engine Engine to be used to render the effect
  29081. * @param defines Define statements to be added to the shader.
  29082. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29083. * @param onCompiled Callback that will be called when the shader is compiled.
  29084. * @param onError Callback that will be called if an error occurs during shader compilation.
  29085. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29086. */
  29087. 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);
  29088. private _useFinalCode;
  29089. /**
  29090. * Unique key for this effect
  29091. */
  29092. readonly key: string;
  29093. /**
  29094. * If the effect has been compiled and prepared.
  29095. * @returns if the effect is compiled and prepared.
  29096. */
  29097. isReady(): boolean;
  29098. /**
  29099. * The engine the effect was initialized with.
  29100. * @returns the engine.
  29101. */
  29102. getEngine(): Engine;
  29103. /**
  29104. * The pipeline context for this effect
  29105. * @returns the associated pipeline context
  29106. */
  29107. getPipelineContext(): Nullable<IPipelineContext>;
  29108. /**
  29109. * The set of names of attribute variables for the shader.
  29110. * @returns An array of attribute names.
  29111. */
  29112. getAttributesNames(): string[];
  29113. /**
  29114. * Returns the attribute at the given index.
  29115. * @param index The index of the attribute.
  29116. * @returns The location of the attribute.
  29117. */
  29118. getAttributeLocation(index: number): number;
  29119. /**
  29120. * Returns the attribute based on the name of the variable.
  29121. * @param name of the attribute to look up.
  29122. * @returns the attribute location.
  29123. */
  29124. getAttributeLocationByName(name: string): number;
  29125. /**
  29126. * The number of attributes.
  29127. * @returns the numnber of attributes.
  29128. */
  29129. getAttributesCount(): number;
  29130. /**
  29131. * Gets the index of a uniform variable.
  29132. * @param uniformName of the uniform to look up.
  29133. * @returns the index.
  29134. */
  29135. getUniformIndex(uniformName: string): number;
  29136. /**
  29137. * Returns the attribute based on the name of the variable.
  29138. * @param uniformName of the uniform to look up.
  29139. * @returns the location of the uniform.
  29140. */
  29141. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29142. /**
  29143. * Returns an array of sampler variable names
  29144. * @returns The array of sampler variable neames.
  29145. */
  29146. getSamplers(): string[];
  29147. /**
  29148. * The error from the last compilation.
  29149. * @returns the error string.
  29150. */
  29151. getCompilationError(): string;
  29152. /**
  29153. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29154. * @param func The callback to be used.
  29155. */
  29156. executeWhenCompiled(func: (effect: Effect) => void): void;
  29157. private _checkIsReady;
  29158. /** @hidden */
  29159. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29160. /** @hidden */
  29161. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29162. /** @hidden */
  29163. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29164. /**
  29165. * Recompiles the webGL program
  29166. * @param vertexSourceCode The source code for the vertex shader.
  29167. * @param fragmentSourceCode The source code for the fragment shader.
  29168. * @param onCompiled Callback called when completed.
  29169. * @param onError Callback called on error.
  29170. * @hidden
  29171. */
  29172. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29173. /**
  29174. * Prepares the effect
  29175. * @hidden
  29176. */
  29177. _prepareEffect(): void;
  29178. /**
  29179. * Checks if the effect is supported. (Must be called after compilation)
  29180. */
  29181. readonly isSupported: boolean;
  29182. /**
  29183. * Binds a texture to the engine to be used as output of the shader.
  29184. * @param channel Name of the output variable.
  29185. * @param texture Texture to bind.
  29186. * @hidden
  29187. */
  29188. _bindTexture(channel: string, texture: InternalTexture): void;
  29189. /**
  29190. * Sets a texture on the engine to be used in the shader.
  29191. * @param channel Name of the sampler variable.
  29192. * @param texture Texture to set.
  29193. */
  29194. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29195. /**
  29196. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29197. * @param channel Name of the sampler variable.
  29198. * @param texture Texture to set.
  29199. */
  29200. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29201. /**
  29202. * Sets an array of textures on the engine to be used in the shader.
  29203. * @param channel Name of the variable.
  29204. * @param textures Textures to set.
  29205. */
  29206. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29207. /**
  29208. * 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)
  29209. * @param channel Name of the sampler variable.
  29210. * @param postProcess Post process to get the input texture from.
  29211. */
  29212. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29213. /**
  29214. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29215. * 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)
  29216. * @param channel Name of the sampler variable.
  29217. * @param postProcess Post process to get the output texture from.
  29218. */
  29219. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29220. /** @hidden */
  29221. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29222. /** @hidden */
  29223. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29224. /** @hidden */
  29225. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29226. /** @hidden */
  29227. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29228. /**
  29229. * Binds a buffer to a uniform.
  29230. * @param buffer Buffer to bind.
  29231. * @param name Name of the uniform variable to bind to.
  29232. */
  29233. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29234. /**
  29235. * Binds block to a uniform.
  29236. * @param blockName Name of the block to bind.
  29237. * @param index Index to bind.
  29238. */
  29239. bindUniformBlock(blockName: string, index: number): void;
  29240. /**
  29241. * Sets an interger value on a uniform variable.
  29242. * @param uniformName Name of the variable.
  29243. * @param value Value to be set.
  29244. * @returns this effect.
  29245. */
  29246. setInt(uniformName: string, value: number): Effect;
  29247. /**
  29248. * Sets an int array on a uniform variable.
  29249. * @param uniformName Name of the variable.
  29250. * @param array array to be set.
  29251. * @returns this effect.
  29252. */
  29253. setIntArray(uniformName: string, array: Int32Array): Effect;
  29254. /**
  29255. * 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)
  29256. * @param uniformName Name of the variable.
  29257. * @param array array to be set.
  29258. * @returns this effect.
  29259. */
  29260. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29261. /**
  29262. * 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)
  29263. * @param uniformName Name of the variable.
  29264. * @param array array to be set.
  29265. * @returns this effect.
  29266. */
  29267. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29268. /**
  29269. * 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)
  29270. * @param uniformName Name of the variable.
  29271. * @param array array to be set.
  29272. * @returns this effect.
  29273. */
  29274. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29275. /**
  29276. * Sets an float array on a uniform variable.
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29282. /**
  29283. * 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)
  29284. * @param uniformName Name of the variable.
  29285. * @param array array to be set.
  29286. * @returns this effect.
  29287. */
  29288. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29289. /**
  29290. * 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)
  29291. * @param uniformName Name of the variable.
  29292. * @param array array to be set.
  29293. * @returns this effect.
  29294. */
  29295. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29296. /**
  29297. * 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)
  29298. * @param uniformName Name of the variable.
  29299. * @param array array to be set.
  29300. * @returns this effect.
  29301. */
  29302. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29303. /**
  29304. * Sets an array on a uniform variable.
  29305. * @param uniformName Name of the variable.
  29306. * @param array array to be set.
  29307. * @returns this effect.
  29308. */
  29309. setArray(uniformName: string, array: number[]): Effect;
  29310. /**
  29311. * 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)
  29312. * @param uniformName Name of the variable.
  29313. * @param array array to be set.
  29314. * @returns this effect.
  29315. */
  29316. setArray2(uniformName: string, array: number[]): Effect;
  29317. /**
  29318. * 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)
  29319. * @param uniformName Name of the variable.
  29320. * @param array array to be set.
  29321. * @returns this effect.
  29322. */
  29323. setArray3(uniformName: string, array: number[]): Effect;
  29324. /**
  29325. * 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)
  29326. * @param uniformName Name of the variable.
  29327. * @param array array to be set.
  29328. * @returns this effect.
  29329. */
  29330. setArray4(uniformName: string, array: number[]): Effect;
  29331. /**
  29332. * Sets matrices on a uniform variable.
  29333. * @param uniformName Name of the variable.
  29334. * @param matrices matrices to be set.
  29335. * @returns this effect.
  29336. */
  29337. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29338. /**
  29339. * Sets matrix on a uniform variable.
  29340. * @param uniformName Name of the variable.
  29341. * @param matrix matrix to be set.
  29342. * @returns this effect.
  29343. */
  29344. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29345. /**
  29346. * 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)
  29347. * @param uniformName Name of the variable.
  29348. * @param matrix matrix to be set.
  29349. * @returns this effect.
  29350. */
  29351. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29352. /**
  29353. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29354. * @param uniformName Name of the variable.
  29355. * @param matrix matrix to be set.
  29356. * @returns this effect.
  29357. */
  29358. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29359. /**
  29360. * Sets a float on a uniform variable.
  29361. * @param uniformName Name of the variable.
  29362. * @param value value to be set.
  29363. * @returns this effect.
  29364. */
  29365. setFloat(uniformName: string, value: number): Effect;
  29366. /**
  29367. * Sets a boolean on a uniform variable.
  29368. * @param uniformName Name of the variable.
  29369. * @param bool value to be set.
  29370. * @returns this effect.
  29371. */
  29372. setBool(uniformName: string, bool: boolean): Effect;
  29373. /**
  29374. * Sets a Vector2 on a uniform variable.
  29375. * @param uniformName Name of the variable.
  29376. * @param vector2 vector2 to be set.
  29377. * @returns this effect.
  29378. */
  29379. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29380. /**
  29381. * Sets a float2 on a uniform variable.
  29382. * @param uniformName Name of the variable.
  29383. * @param x First float in float2.
  29384. * @param y Second float in float2.
  29385. * @returns this effect.
  29386. */
  29387. setFloat2(uniformName: string, x: number, y: number): Effect;
  29388. /**
  29389. * Sets a Vector3 on a uniform variable.
  29390. * @param uniformName Name of the variable.
  29391. * @param vector3 Value to be set.
  29392. * @returns this effect.
  29393. */
  29394. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29395. /**
  29396. * Sets a float3 on a uniform variable.
  29397. * @param uniformName Name of the variable.
  29398. * @param x First float in float3.
  29399. * @param y Second float in float3.
  29400. * @param z Third float in float3.
  29401. * @returns this effect.
  29402. */
  29403. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29404. /**
  29405. * Sets a Vector4 on a uniform variable.
  29406. * @param uniformName Name of the variable.
  29407. * @param vector4 Value to be set.
  29408. * @returns this effect.
  29409. */
  29410. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29411. /**
  29412. * Sets a float4 on a uniform variable.
  29413. * @param uniformName Name of the variable.
  29414. * @param x First float in float4.
  29415. * @param y Second float in float4.
  29416. * @param z Third float in float4.
  29417. * @param w Fourth float in float4.
  29418. * @returns this effect.
  29419. */
  29420. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29421. /**
  29422. * Sets a Color3 on a uniform variable.
  29423. * @param uniformName Name of the variable.
  29424. * @param color3 Value to be set.
  29425. * @returns this effect.
  29426. */
  29427. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29428. /**
  29429. * Sets a Color4 on a uniform variable.
  29430. * @param uniformName Name of the variable.
  29431. * @param color3 Value to be set.
  29432. * @param alpha Alpha value to be set.
  29433. * @returns this effect.
  29434. */
  29435. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29436. /**
  29437. * Sets a Color4 on a uniform variable
  29438. * @param uniformName defines the name of the variable
  29439. * @param color4 defines the value to be set
  29440. * @returns this effect.
  29441. */
  29442. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29443. /** Release all associated resources */
  29444. dispose(): void;
  29445. /**
  29446. * This function will add a new shader to the shader store
  29447. * @param name the name of the shader
  29448. * @param pixelShader optional pixel shader content
  29449. * @param vertexShader optional vertex shader content
  29450. */
  29451. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29452. /**
  29453. * Store of each shader (The can be looked up using effect.key)
  29454. */
  29455. static ShadersStore: {
  29456. [key: string]: string;
  29457. };
  29458. /**
  29459. * Store of each included file for a shader (The can be looked up using effect.key)
  29460. */
  29461. static IncludesShadersStore: {
  29462. [key: string]: string;
  29463. };
  29464. /**
  29465. * Resets the cache of effects.
  29466. */
  29467. static ResetCache(): void;
  29468. }
  29469. }
  29470. declare module "babylonjs/Materials/uniformBuffer" {
  29471. import { Nullable, FloatArray } from "babylonjs/types";
  29472. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29473. import { Engine } from "babylonjs/Engines/engine";
  29474. import { Effect } from "babylonjs/Materials/effect";
  29475. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29476. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29477. import { Color3 } from "babylonjs/Maths/math.color";
  29478. /**
  29479. * Uniform buffer objects.
  29480. *
  29481. * Handles blocks of uniform on the GPU.
  29482. *
  29483. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29484. *
  29485. * For more information, please refer to :
  29486. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29487. */
  29488. export class UniformBuffer {
  29489. private _engine;
  29490. private _buffer;
  29491. private _data;
  29492. private _bufferData;
  29493. private _dynamic?;
  29494. private _uniformLocations;
  29495. private _uniformSizes;
  29496. private _uniformLocationPointer;
  29497. private _needSync;
  29498. private _noUBO;
  29499. private _currentEffect;
  29500. private static _MAX_UNIFORM_SIZE;
  29501. private static _tempBuffer;
  29502. /**
  29503. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29504. * This is dynamic to allow compat with webgl 1 and 2.
  29505. * You will need to pass the name of the uniform as well as the value.
  29506. */
  29507. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29508. /**
  29509. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29510. * This is dynamic to allow compat with webgl 1 and 2.
  29511. * You will need to pass the name of the uniform as well as the value.
  29512. */
  29513. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29514. /**
  29515. * Lambda to Update a single float in a uniform buffer.
  29516. * This is dynamic to allow compat with webgl 1 and 2.
  29517. * You will need to pass the name of the uniform as well as the value.
  29518. */
  29519. updateFloat: (name: string, x: number) => void;
  29520. /**
  29521. * Lambda to Update a vec2 of float in a uniform buffer.
  29522. * This is dynamic to allow compat with webgl 1 and 2.
  29523. * You will need to pass the name of the uniform as well as the value.
  29524. */
  29525. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29526. /**
  29527. * Lambda to Update a vec3 of float in a uniform buffer.
  29528. * This is dynamic to allow compat with webgl 1 and 2.
  29529. * You will need to pass the name of the uniform as well as the value.
  29530. */
  29531. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29532. /**
  29533. * Lambda to Update a vec4 of float in a uniform buffer.
  29534. * This is dynamic to allow compat with webgl 1 and 2.
  29535. * You will need to pass the name of the uniform as well as the value.
  29536. */
  29537. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29538. /**
  29539. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29540. * This is dynamic to allow compat with webgl 1 and 2.
  29541. * You will need to pass the name of the uniform as well as the value.
  29542. */
  29543. updateMatrix: (name: string, mat: Matrix) => void;
  29544. /**
  29545. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29546. * This is dynamic to allow compat with webgl 1 and 2.
  29547. * You will need to pass the name of the uniform as well as the value.
  29548. */
  29549. updateVector3: (name: string, vector: Vector3) => void;
  29550. /**
  29551. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29552. * This is dynamic to allow compat with webgl 1 and 2.
  29553. * You will need to pass the name of the uniform as well as the value.
  29554. */
  29555. updateVector4: (name: string, vector: Vector4) => void;
  29556. /**
  29557. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29558. * This is dynamic to allow compat with webgl 1 and 2.
  29559. * You will need to pass the name of the uniform as well as the value.
  29560. */
  29561. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29562. /**
  29563. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29564. * This is dynamic to allow compat with webgl 1 and 2.
  29565. * You will need to pass the name of the uniform as well as the value.
  29566. */
  29567. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29568. /**
  29569. * Instantiates a new Uniform buffer objects.
  29570. *
  29571. * Handles blocks of uniform on the GPU.
  29572. *
  29573. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29574. *
  29575. * For more information, please refer to :
  29576. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29577. * @param engine Define the engine the buffer is associated with
  29578. * @param data Define the data contained in the buffer
  29579. * @param dynamic Define if the buffer is updatable
  29580. */
  29581. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29582. /**
  29583. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29584. * or just falling back on setUniformXXX calls.
  29585. */
  29586. readonly useUbo: boolean;
  29587. /**
  29588. * Indicates if the WebGL underlying uniform buffer is in sync
  29589. * with the javascript cache data.
  29590. */
  29591. readonly isSync: boolean;
  29592. /**
  29593. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29594. * Also, a dynamic UniformBuffer will disable cache verification and always
  29595. * update the underlying WebGL uniform buffer to the GPU.
  29596. * @returns if Dynamic, otherwise false
  29597. */
  29598. isDynamic(): boolean;
  29599. /**
  29600. * The data cache on JS side.
  29601. * @returns the underlying data as a float array
  29602. */
  29603. getData(): Float32Array;
  29604. /**
  29605. * The underlying WebGL Uniform buffer.
  29606. * @returns the webgl buffer
  29607. */
  29608. getBuffer(): Nullable<DataBuffer>;
  29609. /**
  29610. * std140 layout specifies how to align data within an UBO structure.
  29611. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29612. * for specs.
  29613. */
  29614. private _fillAlignment;
  29615. /**
  29616. * Adds an uniform in the buffer.
  29617. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29618. * for the layout to be correct !
  29619. * @param name Name of the uniform, as used in the uniform block in the shader.
  29620. * @param size Data size, or data directly.
  29621. */
  29622. addUniform(name: string, size: number | number[]): void;
  29623. /**
  29624. * Adds a Matrix 4x4 to the uniform buffer.
  29625. * @param name Name of the uniform, as used in the uniform block in the shader.
  29626. * @param mat A 4x4 matrix.
  29627. */
  29628. addMatrix(name: string, mat: Matrix): void;
  29629. /**
  29630. * Adds a vec2 to the uniform buffer.
  29631. * @param name Name of the uniform, as used in the uniform block in the shader.
  29632. * @param x Define the x component value of the vec2
  29633. * @param y Define the y component value of the vec2
  29634. */
  29635. addFloat2(name: string, x: number, y: number): void;
  29636. /**
  29637. * Adds a vec3 to the uniform buffer.
  29638. * @param name Name of the uniform, as used in the uniform block in the shader.
  29639. * @param x Define the x component value of the vec3
  29640. * @param y Define the y component value of the vec3
  29641. * @param z Define the z component value of the vec3
  29642. */
  29643. addFloat3(name: string, x: number, y: number, z: number): void;
  29644. /**
  29645. * Adds a vec3 to the uniform buffer.
  29646. * @param name Name of the uniform, as used in the uniform block in the shader.
  29647. * @param color Define the vec3 from a Color
  29648. */
  29649. addColor3(name: string, color: Color3): void;
  29650. /**
  29651. * Adds a vec4 to the uniform buffer.
  29652. * @param name Name of the uniform, as used in the uniform block in the shader.
  29653. * @param color Define the rgb components from a Color
  29654. * @param alpha Define the a component of the vec4
  29655. */
  29656. addColor4(name: string, color: Color3, alpha: number): void;
  29657. /**
  29658. * Adds a vec3 to the uniform buffer.
  29659. * @param name Name of the uniform, as used in the uniform block in the shader.
  29660. * @param vector Define the vec3 components from a Vector
  29661. */
  29662. addVector3(name: string, vector: Vector3): void;
  29663. /**
  29664. * Adds a Matrix 3x3 to the uniform buffer.
  29665. * @param name Name of the uniform, as used in the uniform block in the shader.
  29666. */
  29667. addMatrix3x3(name: string): void;
  29668. /**
  29669. * Adds a Matrix 2x2 to the uniform buffer.
  29670. * @param name Name of the uniform, as used in the uniform block in the shader.
  29671. */
  29672. addMatrix2x2(name: string): void;
  29673. /**
  29674. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29675. */
  29676. create(): void;
  29677. /** @hidden */
  29678. _rebuild(): void;
  29679. /**
  29680. * Updates the WebGL Uniform Buffer on the GPU.
  29681. * If the `dynamic` flag is set to true, no cache comparison is done.
  29682. * Otherwise, the buffer will be updated only if the cache differs.
  29683. */
  29684. update(): void;
  29685. /**
  29686. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29687. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29688. * @param data Define the flattened data
  29689. * @param size Define the size of the data.
  29690. */
  29691. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29692. private _updateMatrix3x3ForUniform;
  29693. private _updateMatrix3x3ForEffect;
  29694. private _updateMatrix2x2ForEffect;
  29695. private _updateMatrix2x2ForUniform;
  29696. private _updateFloatForEffect;
  29697. private _updateFloatForUniform;
  29698. private _updateFloat2ForEffect;
  29699. private _updateFloat2ForUniform;
  29700. private _updateFloat3ForEffect;
  29701. private _updateFloat3ForUniform;
  29702. private _updateFloat4ForEffect;
  29703. private _updateFloat4ForUniform;
  29704. private _updateMatrixForEffect;
  29705. private _updateMatrixForUniform;
  29706. private _updateVector3ForEffect;
  29707. private _updateVector3ForUniform;
  29708. private _updateVector4ForEffect;
  29709. private _updateVector4ForUniform;
  29710. private _updateColor3ForEffect;
  29711. private _updateColor3ForUniform;
  29712. private _updateColor4ForEffect;
  29713. private _updateColor4ForUniform;
  29714. /**
  29715. * Sets a sampler uniform on the effect.
  29716. * @param name Define the name of the sampler.
  29717. * @param texture Define the texture to set in the sampler
  29718. */
  29719. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29720. /**
  29721. * Directly updates the value of the uniform in the cache AND on the GPU.
  29722. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29723. * @param data Define the flattened data
  29724. */
  29725. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29726. /**
  29727. * Binds this uniform buffer to an effect.
  29728. * @param effect Define the effect to bind the buffer to
  29729. * @param name Name of the uniform block in the shader.
  29730. */
  29731. bindToEffect(effect: Effect, name: string): void;
  29732. /**
  29733. * Disposes the uniform buffer.
  29734. */
  29735. dispose(): void;
  29736. }
  29737. }
  29738. declare module "babylonjs/Audio/analyser" {
  29739. import { Scene } from "babylonjs/scene";
  29740. /**
  29741. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29743. */
  29744. export class Analyser {
  29745. /**
  29746. * Gets or sets the smoothing
  29747. * @ignorenaming
  29748. */
  29749. SMOOTHING: number;
  29750. /**
  29751. * Gets or sets the FFT table size
  29752. * @ignorenaming
  29753. */
  29754. FFT_SIZE: number;
  29755. /**
  29756. * Gets or sets the bar graph amplitude
  29757. * @ignorenaming
  29758. */
  29759. BARGRAPHAMPLITUDE: number;
  29760. /**
  29761. * Gets or sets the position of the debug canvas
  29762. * @ignorenaming
  29763. */
  29764. DEBUGCANVASPOS: {
  29765. x: number;
  29766. y: number;
  29767. };
  29768. /**
  29769. * Gets or sets the debug canvas size
  29770. * @ignorenaming
  29771. */
  29772. DEBUGCANVASSIZE: {
  29773. width: number;
  29774. height: number;
  29775. };
  29776. private _byteFreqs;
  29777. private _byteTime;
  29778. private _floatFreqs;
  29779. private _webAudioAnalyser;
  29780. private _debugCanvas;
  29781. private _debugCanvasContext;
  29782. private _scene;
  29783. private _registerFunc;
  29784. private _audioEngine;
  29785. /**
  29786. * Creates a new analyser
  29787. * @param scene defines hosting scene
  29788. */
  29789. constructor(scene: Scene);
  29790. /**
  29791. * Get the number of data values you will have to play with for the visualization
  29792. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29793. * @returns a number
  29794. */
  29795. getFrequencyBinCount(): number;
  29796. /**
  29797. * Gets the current frequency data as a byte array
  29798. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29799. * @returns a Uint8Array
  29800. */
  29801. getByteFrequencyData(): Uint8Array;
  29802. /**
  29803. * Gets the current waveform as a byte array
  29804. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29805. * @returns a Uint8Array
  29806. */
  29807. getByteTimeDomainData(): Uint8Array;
  29808. /**
  29809. * Gets the current frequency data as a float array
  29810. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29811. * @returns a Float32Array
  29812. */
  29813. getFloatFrequencyData(): Float32Array;
  29814. /**
  29815. * Renders the debug canvas
  29816. */
  29817. drawDebugCanvas(): void;
  29818. /**
  29819. * Stops rendering the debug canvas and removes it
  29820. */
  29821. stopDebugCanvas(): void;
  29822. /**
  29823. * Connects two audio nodes
  29824. * @param inputAudioNode defines first node to connect
  29825. * @param outputAudioNode defines second node to connect
  29826. */
  29827. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29828. /**
  29829. * Releases all associated resources
  29830. */
  29831. dispose(): void;
  29832. }
  29833. }
  29834. declare module "babylonjs/Audio/audioEngine" {
  29835. import { IDisposable } from "babylonjs/scene";
  29836. import { Analyser } from "babylonjs/Audio/analyser";
  29837. import { Nullable } from "babylonjs/types";
  29838. import { Observable } from "babylonjs/Misc/observable";
  29839. /**
  29840. * This represents an audio engine and it is responsible
  29841. * to play, synchronize and analyse sounds throughout the application.
  29842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29843. */
  29844. export interface IAudioEngine extends IDisposable {
  29845. /**
  29846. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29847. */
  29848. readonly canUseWebAudio: boolean;
  29849. /**
  29850. * Gets the current AudioContext if available.
  29851. */
  29852. readonly audioContext: Nullable<AudioContext>;
  29853. /**
  29854. * The master gain node defines the global audio volume of your audio engine.
  29855. */
  29856. readonly masterGain: GainNode;
  29857. /**
  29858. * Gets whether or not mp3 are supported by your browser.
  29859. */
  29860. readonly isMP3supported: boolean;
  29861. /**
  29862. * Gets whether or not ogg are supported by your browser.
  29863. */
  29864. readonly isOGGsupported: boolean;
  29865. /**
  29866. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29867. * @ignoreNaming
  29868. */
  29869. WarnedWebAudioUnsupported: boolean;
  29870. /**
  29871. * Defines if the audio engine relies on a custom unlocked button.
  29872. * In this case, the embedded button will not be displayed.
  29873. */
  29874. useCustomUnlockedButton: boolean;
  29875. /**
  29876. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29877. */
  29878. readonly unlocked: boolean;
  29879. /**
  29880. * Event raised when audio has been unlocked on the browser.
  29881. */
  29882. onAudioUnlockedObservable: Observable<AudioEngine>;
  29883. /**
  29884. * Event raised when audio has been locked on the browser.
  29885. */
  29886. onAudioLockedObservable: Observable<AudioEngine>;
  29887. /**
  29888. * Flags the audio engine in Locked state.
  29889. * This happens due to new browser policies preventing audio to autoplay.
  29890. */
  29891. lock(): void;
  29892. /**
  29893. * Unlocks the audio engine once a user action has been done on the dom.
  29894. * This is helpful to resume play once browser policies have been satisfied.
  29895. */
  29896. unlock(): void;
  29897. }
  29898. /**
  29899. * This represents the default audio engine used in babylon.
  29900. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29902. */
  29903. export class AudioEngine implements IAudioEngine {
  29904. private _audioContext;
  29905. private _audioContextInitialized;
  29906. private _muteButton;
  29907. private _hostElement;
  29908. /**
  29909. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29910. */
  29911. canUseWebAudio: boolean;
  29912. /**
  29913. * The master gain node defines the global audio volume of your audio engine.
  29914. */
  29915. masterGain: GainNode;
  29916. /**
  29917. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29918. * @ignoreNaming
  29919. */
  29920. WarnedWebAudioUnsupported: boolean;
  29921. /**
  29922. * Gets whether or not mp3 are supported by your browser.
  29923. */
  29924. isMP3supported: boolean;
  29925. /**
  29926. * Gets whether or not ogg are supported by your browser.
  29927. */
  29928. isOGGsupported: boolean;
  29929. /**
  29930. * Gets whether audio has been unlocked on the device.
  29931. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29932. * a user interaction has happened.
  29933. */
  29934. unlocked: boolean;
  29935. /**
  29936. * Defines if the audio engine relies on a custom unlocked button.
  29937. * In this case, the embedded button will not be displayed.
  29938. */
  29939. useCustomUnlockedButton: boolean;
  29940. /**
  29941. * Event raised when audio has been unlocked on the browser.
  29942. */
  29943. onAudioUnlockedObservable: Observable<AudioEngine>;
  29944. /**
  29945. * Event raised when audio has been locked on the browser.
  29946. */
  29947. onAudioLockedObservable: Observable<AudioEngine>;
  29948. /**
  29949. * Gets the current AudioContext if available.
  29950. */
  29951. readonly audioContext: Nullable<AudioContext>;
  29952. private _connectedAnalyser;
  29953. /**
  29954. * Instantiates a new audio engine.
  29955. *
  29956. * There should be only one per page as some browsers restrict the number
  29957. * of audio contexts you can create.
  29958. * @param hostElement defines the host element where to display the mute icon if necessary
  29959. */
  29960. constructor(hostElement?: Nullable<HTMLElement>);
  29961. /**
  29962. * Flags the audio engine in Locked state.
  29963. * This happens due to new browser policies preventing audio to autoplay.
  29964. */
  29965. lock(): void;
  29966. /**
  29967. * Unlocks the audio engine once a user action has been done on the dom.
  29968. * This is helpful to resume play once browser policies have been satisfied.
  29969. */
  29970. unlock(): void;
  29971. private _resumeAudioContext;
  29972. private _initializeAudioContext;
  29973. private _tryToRun;
  29974. private _triggerRunningState;
  29975. private _triggerSuspendedState;
  29976. private _displayMuteButton;
  29977. private _moveButtonToTopLeft;
  29978. private _onResize;
  29979. private _hideMuteButton;
  29980. /**
  29981. * Destroy and release the resources associated with the audio ccontext.
  29982. */
  29983. dispose(): void;
  29984. /**
  29985. * Gets the global volume sets on the master gain.
  29986. * @returns the global volume if set or -1 otherwise
  29987. */
  29988. getGlobalVolume(): number;
  29989. /**
  29990. * Sets the global volume of your experience (sets on the master gain).
  29991. * @param newVolume Defines the new global volume of the application
  29992. */
  29993. setGlobalVolume(newVolume: number): void;
  29994. /**
  29995. * Connect the audio engine to an audio analyser allowing some amazing
  29996. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29998. * @param analyser The analyser to connect to the engine
  29999. */
  30000. connectToAnalyser(analyser: Analyser): void;
  30001. }
  30002. }
  30003. declare module "babylonjs/Loading/loadingScreen" {
  30004. /**
  30005. * Interface used to present a loading screen while loading a scene
  30006. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30007. */
  30008. export interface ILoadingScreen {
  30009. /**
  30010. * Function called to display the loading screen
  30011. */
  30012. displayLoadingUI: () => void;
  30013. /**
  30014. * Function called to hide the loading screen
  30015. */
  30016. hideLoadingUI: () => void;
  30017. /**
  30018. * Gets or sets the color to use for the background
  30019. */
  30020. loadingUIBackgroundColor: string;
  30021. /**
  30022. * Gets or sets the text to display while loading
  30023. */
  30024. loadingUIText: string;
  30025. }
  30026. /**
  30027. * Class used for the default loading screen
  30028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30029. */
  30030. export class DefaultLoadingScreen implements ILoadingScreen {
  30031. private _renderingCanvas;
  30032. private _loadingText;
  30033. private _loadingDivBackgroundColor;
  30034. private _loadingDiv;
  30035. private _loadingTextDiv;
  30036. /** Gets or sets the logo url to use for the default loading screen */
  30037. static DefaultLogoUrl: string;
  30038. /** Gets or sets the spinner url to use for the default loading screen */
  30039. static DefaultSpinnerUrl: string;
  30040. /**
  30041. * Creates a new default loading screen
  30042. * @param _renderingCanvas defines the canvas used to render the scene
  30043. * @param _loadingText defines the default text to display
  30044. * @param _loadingDivBackgroundColor defines the default background color
  30045. */
  30046. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30047. /**
  30048. * Function called to display the loading screen
  30049. */
  30050. displayLoadingUI(): void;
  30051. /**
  30052. * Function called to hide the loading screen
  30053. */
  30054. hideLoadingUI(): void;
  30055. /**
  30056. * Gets or sets the text to display while loading
  30057. */
  30058. loadingUIText: string;
  30059. /**
  30060. * Gets or sets the color to use for the background
  30061. */
  30062. loadingUIBackgroundColor: string;
  30063. private _resizeLoadingUI;
  30064. }
  30065. }
  30066. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30067. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30068. import { Engine } from "babylonjs/Engines/engine";
  30069. import { Nullable } from "babylonjs/types";
  30070. /** @hidden */
  30071. export class WebGLPipelineContext implements IPipelineContext {
  30072. engine: Engine;
  30073. program: Nullable<WebGLProgram>;
  30074. context?: WebGLRenderingContext;
  30075. vertexShader?: WebGLShader;
  30076. fragmentShader?: WebGLShader;
  30077. isParallelCompiled: boolean;
  30078. onCompiled?: () => void;
  30079. transformFeedback?: WebGLTransformFeedback | null;
  30080. readonly isAsync: boolean;
  30081. readonly isReady: boolean;
  30082. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30083. }
  30084. }
  30085. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30086. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30087. /** @hidden */
  30088. export class WebGLDataBuffer extends DataBuffer {
  30089. private _buffer;
  30090. constructor(resource: WebGLBuffer);
  30091. readonly underlyingResource: any;
  30092. }
  30093. }
  30094. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30095. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30096. /** @hidden */
  30097. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30098. attributeProcessor(attribute: string): string;
  30099. varyingProcessor(varying: string, isFragment: boolean): string;
  30100. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30101. }
  30102. }
  30103. declare module "babylonjs/Misc/perfCounter" {
  30104. /**
  30105. * This class is used to track a performance counter which is number based.
  30106. * The user has access to many properties which give statistics of different nature.
  30107. *
  30108. * The implementer can track two kinds of Performance Counter: time and count.
  30109. * 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.
  30110. * 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.
  30111. */
  30112. export class PerfCounter {
  30113. /**
  30114. * Gets or sets a global boolean to turn on and off all the counters
  30115. */
  30116. static Enabled: boolean;
  30117. /**
  30118. * Returns the smallest value ever
  30119. */
  30120. readonly min: number;
  30121. /**
  30122. * Returns the biggest value ever
  30123. */
  30124. readonly max: number;
  30125. /**
  30126. * Returns the average value since the performance counter is running
  30127. */
  30128. readonly average: number;
  30129. /**
  30130. * Returns the average value of the last second the counter was monitored
  30131. */
  30132. readonly lastSecAverage: number;
  30133. /**
  30134. * Returns the current value
  30135. */
  30136. readonly current: number;
  30137. /**
  30138. * Gets the accumulated total
  30139. */
  30140. readonly total: number;
  30141. /**
  30142. * Gets the total value count
  30143. */
  30144. readonly count: number;
  30145. /**
  30146. * Creates a new counter
  30147. */
  30148. constructor();
  30149. /**
  30150. * Call this method to start monitoring a new frame.
  30151. * 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.
  30152. */
  30153. fetchNewFrame(): void;
  30154. /**
  30155. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30156. * @param newCount the count value to add to the monitored count
  30157. * @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.
  30158. */
  30159. addCount(newCount: number, fetchResult: boolean): void;
  30160. /**
  30161. * Start monitoring this performance counter
  30162. */
  30163. beginMonitoring(): void;
  30164. /**
  30165. * Compute the time lapsed since the previous beginMonitoring() call.
  30166. * @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
  30167. */
  30168. endMonitoring(newFrame?: boolean): void;
  30169. private _fetchResult;
  30170. private _startMonitoringTime;
  30171. private _min;
  30172. private _max;
  30173. private _average;
  30174. private _current;
  30175. private _totalValueCount;
  30176. private _totalAccumulated;
  30177. private _lastSecAverage;
  30178. private _lastSecAccumulated;
  30179. private _lastSecTime;
  30180. private _lastSecValueCount;
  30181. }
  30182. }
  30183. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30184. /**
  30185. * Interface for any object that can request an animation frame
  30186. */
  30187. export interface ICustomAnimationFrameRequester {
  30188. /**
  30189. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30190. */
  30191. renderFunction?: Function;
  30192. /**
  30193. * Called to request the next frame to render to
  30194. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30195. */
  30196. requestAnimationFrame: Function;
  30197. /**
  30198. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30199. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30200. */
  30201. requestID?: number;
  30202. }
  30203. }
  30204. declare module "babylonjs/Materials/Textures/videoTexture" {
  30205. import { Observable } from "babylonjs/Misc/observable";
  30206. import { Nullable } from "babylonjs/types";
  30207. import { Scene } from "babylonjs/scene";
  30208. import { Texture } from "babylonjs/Materials/Textures/texture";
  30209. /**
  30210. * Settings for finer control over video usage
  30211. */
  30212. export interface VideoTextureSettings {
  30213. /**
  30214. * Applies `autoplay` to video, if specified
  30215. */
  30216. autoPlay?: boolean;
  30217. /**
  30218. * Applies `loop` to video, if specified
  30219. */
  30220. loop?: boolean;
  30221. /**
  30222. * Automatically updates internal texture from video at every frame in the render loop
  30223. */
  30224. autoUpdateTexture: boolean;
  30225. /**
  30226. * Image src displayed during the video loading or until the user interacts with the video.
  30227. */
  30228. poster?: string;
  30229. }
  30230. /**
  30231. * If you want to display a video in your scene, this is the special texture for that.
  30232. * This special texture works similar to other textures, with the exception of a few parameters.
  30233. * @see https://doc.babylonjs.com/how_to/video_texture
  30234. */
  30235. export class VideoTexture extends Texture {
  30236. /**
  30237. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30238. */
  30239. readonly autoUpdateTexture: boolean;
  30240. /**
  30241. * The video instance used by the texture internally
  30242. */
  30243. readonly video: HTMLVideoElement;
  30244. private _onUserActionRequestedObservable;
  30245. /**
  30246. * Event triggerd when a dom action is required by the user to play the video.
  30247. * This happens due to recent changes in browser policies preventing video to auto start.
  30248. */
  30249. readonly onUserActionRequestedObservable: Observable<Texture>;
  30250. private _generateMipMaps;
  30251. private _engine;
  30252. private _stillImageCaptured;
  30253. private _displayingPosterTexture;
  30254. private _settings;
  30255. private _createInternalTextureOnEvent;
  30256. /**
  30257. * Creates a video texture.
  30258. * If you want to display a video in your scene, this is the special texture for that.
  30259. * This special texture works similar to other textures, with the exception of a few parameters.
  30260. * @see https://doc.babylonjs.com/how_to/video_texture
  30261. * @param name optional name, will detect from video source, if not defined
  30262. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30263. * @param scene is obviously the current scene.
  30264. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30265. * @param invertY is false by default but can be used to invert video on Y axis
  30266. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30267. * @param settings allows finer control over video usage
  30268. */
  30269. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30270. private _getName;
  30271. private _getVideo;
  30272. private _createInternalTexture;
  30273. private reset;
  30274. /**
  30275. * @hidden Internal method to initiate `update`.
  30276. */
  30277. _rebuild(): void;
  30278. /**
  30279. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30280. */
  30281. update(): void;
  30282. /**
  30283. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30284. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30285. */
  30286. updateTexture(isVisible: boolean): void;
  30287. protected _updateInternalTexture: () => void;
  30288. /**
  30289. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30290. * @param url New url.
  30291. */
  30292. updateURL(url: string): void;
  30293. /**
  30294. * Dispose the texture and release its associated resources.
  30295. */
  30296. dispose(): void;
  30297. /**
  30298. * Creates a video texture straight from a stream.
  30299. * @param scene Define the scene the texture should be created in
  30300. * @param stream Define the stream the texture should be created from
  30301. * @returns The created video texture as a promise
  30302. */
  30303. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30304. /**
  30305. * Creates a video texture straight from your WebCam video feed.
  30306. * @param scene Define the scene the texture should be created in
  30307. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30308. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30309. * @returns The created video texture as a promise
  30310. */
  30311. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30312. minWidth: number;
  30313. maxWidth: number;
  30314. minHeight: number;
  30315. maxHeight: number;
  30316. deviceId: string;
  30317. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30318. /**
  30319. * Creates a video texture straight from your WebCam video feed.
  30320. * @param scene Define the scene the texture should be created in
  30321. * @param onReady Define a callback to triggered once the texture will be ready
  30322. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30323. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30324. */
  30325. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30326. minWidth: number;
  30327. maxWidth: number;
  30328. minHeight: number;
  30329. maxHeight: number;
  30330. deviceId: string;
  30331. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30332. }
  30333. }
  30334. declare module "babylonjs/Engines/engine" {
  30335. import { Observable } from "babylonjs/Misc/observable";
  30336. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30337. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30338. import { Scene } from "babylonjs/scene";
  30339. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30340. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30341. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30342. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30343. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30345. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30347. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30348. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30349. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30350. import { WebRequest } from "babylonjs/Misc/webRequest";
  30351. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30352. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30353. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30354. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30355. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30356. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30357. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30358. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30359. import { Material } from "babylonjs/Materials/material";
  30360. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30361. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30362. /**
  30363. * Defines the interface used by objects containing a viewport (like a camera)
  30364. */
  30365. interface IViewportOwnerLike {
  30366. /**
  30367. * Gets or sets the viewport
  30368. */
  30369. viewport: IViewportLike;
  30370. }
  30371. /**
  30372. * Interface for attribute information associated with buffer instanciation
  30373. */
  30374. export class InstancingAttributeInfo {
  30375. /**
  30376. * Index/offset of the attribute in the vertex shader
  30377. */
  30378. index: number;
  30379. /**
  30380. * size of the attribute, 1, 2, 3 or 4
  30381. */
  30382. attributeSize: number;
  30383. /**
  30384. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30385. * default is FLOAT
  30386. */
  30387. attribyteType: number;
  30388. /**
  30389. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30390. */
  30391. normalized: boolean;
  30392. /**
  30393. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30394. */
  30395. offset: number;
  30396. /**
  30397. * Name of the GLSL attribute, for debugging purpose only
  30398. */
  30399. attributeName: string;
  30400. }
  30401. /**
  30402. * Define options used to create a depth texture
  30403. */
  30404. export class DepthTextureCreationOptions {
  30405. /** Specifies whether or not a stencil should be allocated in the texture */
  30406. generateStencil?: boolean;
  30407. /** Specifies whether or not bilinear filtering is enable on the texture */
  30408. bilinearFiltering?: boolean;
  30409. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30410. comparisonFunction?: number;
  30411. /** Specifies if the created texture is a cube texture */
  30412. isCube?: boolean;
  30413. }
  30414. /**
  30415. * Class used to describe the capabilities of the engine relatively to the current browser
  30416. */
  30417. export class EngineCapabilities {
  30418. /** Maximum textures units per fragment shader */
  30419. maxTexturesImageUnits: number;
  30420. /** Maximum texture units per vertex shader */
  30421. maxVertexTextureImageUnits: number;
  30422. /** Maximum textures units in the entire pipeline */
  30423. maxCombinedTexturesImageUnits: number;
  30424. /** Maximum texture size */
  30425. maxTextureSize: number;
  30426. /** Maximum cube texture size */
  30427. maxCubemapTextureSize: number;
  30428. /** Maximum render texture size */
  30429. maxRenderTextureSize: number;
  30430. /** Maximum number of vertex attributes */
  30431. maxVertexAttribs: number;
  30432. /** Maximum number of varyings */
  30433. maxVaryingVectors: number;
  30434. /** Maximum number of uniforms per vertex shader */
  30435. maxVertexUniformVectors: number;
  30436. /** Maximum number of uniforms per fragment shader */
  30437. maxFragmentUniformVectors: number;
  30438. /** Defines if standard derivates (dx/dy) are supported */
  30439. standardDerivatives: boolean;
  30440. /** Defines if s3tc texture compression is supported */
  30441. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30442. /** Defines if pvrtc texture compression is supported */
  30443. pvrtc: any;
  30444. /** Defines if etc1 texture compression is supported */
  30445. etc1: any;
  30446. /** Defines if etc2 texture compression is supported */
  30447. etc2: any;
  30448. /** Defines if astc texture compression is supported */
  30449. astc: any;
  30450. /** Defines if float textures are supported */
  30451. textureFloat: boolean;
  30452. /** Defines if vertex array objects are supported */
  30453. vertexArrayObject: boolean;
  30454. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30455. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30456. /** Gets the maximum level of anisotropy supported */
  30457. maxAnisotropy: number;
  30458. /** Defines if instancing is supported */
  30459. instancedArrays: boolean;
  30460. /** Defines if 32 bits indices are supported */
  30461. uintIndices: boolean;
  30462. /** Defines if high precision shaders are supported */
  30463. highPrecisionShaderSupported: boolean;
  30464. /** Defines if depth reading in the fragment shader is supported */
  30465. fragmentDepthSupported: boolean;
  30466. /** Defines if float texture linear filtering is supported*/
  30467. textureFloatLinearFiltering: boolean;
  30468. /** Defines if rendering to float textures is supported */
  30469. textureFloatRender: boolean;
  30470. /** Defines if half float textures are supported*/
  30471. textureHalfFloat: boolean;
  30472. /** Defines if half float texture linear filtering is supported*/
  30473. textureHalfFloatLinearFiltering: boolean;
  30474. /** Defines if rendering to half float textures is supported */
  30475. textureHalfFloatRender: boolean;
  30476. /** Defines if textureLOD shader command is supported */
  30477. textureLOD: boolean;
  30478. /** Defines if draw buffers extension is supported */
  30479. drawBuffersExtension: boolean;
  30480. /** Defines if depth textures are supported */
  30481. depthTextureExtension: boolean;
  30482. /** Defines if float color buffer are supported */
  30483. colorBufferFloat: boolean;
  30484. /** Gets disjoint timer query extension (null if not supported) */
  30485. timerQuery: EXT_disjoint_timer_query;
  30486. /** Defines if timestamp can be used with timer query */
  30487. canUseTimestampForTimerQuery: boolean;
  30488. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30489. multiview: any;
  30490. /** Function used to let the system compiles shaders in background */
  30491. parallelShaderCompile: {
  30492. COMPLETION_STATUS_KHR: number;
  30493. };
  30494. /** Max number of texture samples for MSAA */
  30495. maxMSAASamples: number;
  30496. }
  30497. /** Interface defining initialization parameters for Engine class */
  30498. export interface EngineOptions extends WebGLContextAttributes {
  30499. /**
  30500. * Defines if the engine should no exceed a specified device ratio
  30501. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30502. */
  30503. limitDeviceRatio?: number;
  30504. /**
  30505. * Defines if webvr should be enabled automatically
  30506. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30507. */
  30508. autoEnableWebVR?: boolean;
  30509. /**
  30510. * Defines if webgl2 should be turned off even if supported
  30511. * @see http://doc.babylonjs.com/features/webgl2
  30512. */
  30513. disableWebGL2Support?: boolean;
  30514. /**
  30515. * Defines if webaudio should be initialized as well
  30516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30517. */
  30518. audioEngine?: boolean;
  30519. /**
  30520. * Defines if animations should run using a deterministic lock step
  30521. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30522. */
  30523. deterministicLockstep?: boolean;
  30524. /** Defines the maximum steps to use with deterministic lock step mode */
  30525. lockstepMaxSteps?: number;
  30526. /**
  30527. * Defines that engine should ignore context lost events
  30528. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30529. */
  30530. doNotHandleContextLost?: boolean;
  30531. /**
  30532. * Defines that engine should ignore modifying touch action attribute and style
  30533. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30534. */
  30535. doNotHandleTouchAction?: boolean;
  30536. /**
  30537. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30538. */
  30539. useHighPrecisionFloats?: boolean;
  30540. }
  30541. /**
  30542. * Defines the interface used by display changed events
  30543. */
  30544. export interface IDisplayChangedEventArgs {
  30545. /** Gets the vrDisplay object (if any) */
  30546. vrDisplay: Nullable<any>;
  30547. /** Gets a boolean indicating if webVR is supported */
  30548. vrSupported: boolean;
  30549. }
  30550. /**
  30551. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30552. */
  30553. export class Engine {
  30554. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30555. static ExceptionList: ({
  30556. key: string;
  30557. capture: string;
  30558. captureConstraint: number;
  30559. targets: string[];
  30560. } | {
  30561. key: string;
  30562. capture: null;
  30563. captureConstraint: null;
  30564. targets: string[];
  30565. })[];
  30566. /** Gets the list of created engines */
  30567. static readonly Instances: Engine[];
  30568. /**
  30569. * Gets the latest created engine
  30570. */
  30571. static readonly LastCreatedEngine: Nullable<Engine>;
  30572. /**
  30573. * Gets the latest created scene
  30574. */
  30575. static readonly LastCreatedScene: Nullable<Scene>;
  30576. /**
  30577. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30578. * @param flag defines which part of the materials must be marked as dirty
  30579. * @param predicate defines a predicate used to filter which materials should be affected
  30580. */
  30581. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30582. /** @hidden */
  30583. static _TextureLoaders: IInternalTextureLoader[];
  30584. /** Defines that alpha blending is disabled */
  30585. static readonly ALPHA_DISABLE: number;
  30586. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30587. static readonly ALPHA_ADD: number;
  30588. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30589. static readonly ALPHA_COMBINE: number;
  30590. /** Defines that alpha blending to DEST - SRC * DEST */
  30591. static readonly ALPHA_SUBTRACT: number;
  30592. /** Defines that alpha blending to SRC * DEST */
  30593. static readonly ALPHA_MULTIPLY: number;
  30594. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30595. static readonly ALPHA_MAXIMIZED: number;
  30596. /** Defines that alpha blending to SRC + DEST */
  30597. static readonly ALPHA_ONEONE: number;
  30598. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30599. static readonly ALPHA_PREMULTIPLIED: number;
  30600. /**
  30601. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30602. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30603. */
  30604. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30605. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30606. static readonly ALPHA_INTERPOLATE: number;
  30607. /**
  30608. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30609. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30610. */
  30611. static readonly ALPHA_SCREENMODE: number;
  30612. /** Defines that the ressource is not delayed*/
  30613. static readonly DELAYLOADSTATE_NONE: number;
  30614. /** Defines that the ressource was successfully delay loaded */
  30615. static readonly DELAYLOADSTATE_LOADED: number;
  30616. /** Defines that the ressource is currently delay loading */
  30617. static readonly DELAYLOADSTATE_LOADING: number;
  30618. /** Defines that the ressource is delayed and has not started loading */
  30619. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30621. static readonly NEVER: number;
  30622. /** 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 */
  30623. static readonly ALWAYS: number;
  30624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30625. static readonly LESS: number;
  30626. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30627. static readonly EQUAL: number;
  30628. /** 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 */
  30629. static readonly LEQUAL: number;
  30630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30631. static readonly GREATER: number;
  30632. /** 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 */
  30633. static readonly GEQUAL: number;
  30634. /** 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 */
  30635. static readonly NOTEQUAL: number;
  30636. /** Passed to stencilOperation to specify that stencil value must be kept */
  30637. static readonly KEEP: number;
  30638. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30639. static readonly REPLACE: number;
  30640. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30641. static readonly INCR: number;
  30642. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30643. static readonly DECR: number;
  30644. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30645. static readonly INVERT: number;
  30646. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30647. static readonly INCR_WRAP: number;
  30648. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30649. static readonly DECR_WRAP: number;
  30650. /** Texture is not repeating outside of 0..1 UVs */
  30651. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30652. /** Texture is repeating outside of 0..1 UVs */
  30653. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30654. /** Texture is repeating and mirrored */
  30655. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30656. /** ALPHA */
  30657. static readonly TEXTUREFORMAT_ALPHA: number;
  30658. /** LUMINANCE */
  30659. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30660. /** LUMINANCE_ALPHA */
  30661. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30662. /** RGB */
  30663. static readonly TEXTUREFORMAT_RGB: number;
  30664. /** RGBA */
  30665. static readonly TEXTUREFORMAT_RGBA: number;
  30666. /** RED */
  30667. static readonly TEXTUREFORMAT_RED: number;
  30668. /** RED (2nd reference) */
  30669. static readonly TEXTUREFORMAT_R: number;
  30670. /** RG */
  30671. static readonly TEXTUREFORMAT_RG: number;
  30672. /** RED_INTEGER */
  30673. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30674. /** RED_INTEGER (2nd reference) */
  30675. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30676. /** RG_INTEGER */
  30677. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30678. /** RGB_INTEGER */
  30679. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30680. /** RGBA_INTEGER */
  30681. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30682. /** UNSIGNED_BYTE */
  30683. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30684. /** UNSIGNED_BYTE (2nd reference) */
  30685. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30686. /** FLOAT */
  30687. static readonly TEXTURETYPE_FLOAT: number;
  30688. /** HALF_FLOAT */
  30689. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30690. /** BYTE */
  30691. static readonly TEXTURETYPE_BYTE: number;
  30692. /** SHORT */
  30693. static readonly TEXTURETYPE_SHORT: number;
  30694. /** UNSIGNED_SHORT */
  30695. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30696. /** INT */
  30697. static readonly TEXTURETYPE_INT: number;
  30698. /** UNSIGNED_INT */
  30699. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30700. /** UNSIGNED_SHORT_4_4_4_4 */
  30701. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30702. /** UNSIGNED_SHORT_5_5_5_1 */
  30703. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30704. /** UNSIGNED_SHORT_5_6_5 */
  30705. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30706. /** UNSIGNED_INT_2_10_10_10_REV */
  30707. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30708. /** UNSIGNED_INT_24_8 */
  30709. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30710. /** UNSIGNED_INT_10F_11F_11F_REV */
  30711. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30712. /** UNSIGNED_INT_5_9_9_9_REV */
  30713. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30714. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30715. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30716. /** nearest is mag = nearest and min = nearest and mip = linear */
  30717. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30718. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30719. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30720. /** Trilinear is mag = linear and min = linear and mip = linear */
  30721. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30722. /** nearest is mag = nearest and min = nearest and mip = linear */
  30723. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30724. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30725. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30726. /** Trilinear is mag = linear and min = linear and mip = linear */
  30727. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30728. /** mag = nearest and min = nearest and mip = nearest */
  30729. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30730. /** mag = nearest and min = linear and mip = nearest */
  30731. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30732. /** mag = nearest and min = linear and mip = linear */
  30733. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30734. /** mag = nearest and min = linear and mip = none */
  30735. static readonly TEXTURE_NEAREST_LINEAR: number;
  30736. /** mag = nearest and min = nearest and mip = none */
  30737. static readonly TEXTURE_NEAREST_NEAREST: number;
  30738. /** mag = linear and min = nearest and mip = nearest */
  30739. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30740. /** mag = linear and min = nearest and mip = linear */
  30741. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30742. /** mag = linear and min = linear and mip = none */
  30743. static readonly TEXTURE_LINEAR_LINEAR: number;
  30744. /** mag = linear and min = nearest and mip = none */
  30745. static readonly TEXTURE_LINEAR_NEAREST: number;
  30746. /** Explicit coordinates mode */
  30747. static readonly TEXTURE_EXPLICIT_MODE: number;
  30748. /** Spherical coordinates mode */
  30749. static readonly TEXTURE_SPHERICAL_MODE: number;
  30750. /** Planar coordinates mode */
  30751. static readonly TEXTURE_PLANAR_MODE: number;
  30752. /** Cubic coordinates mode */
  30753. static readonly TEXTURE_CUBIC_MODE: number;
  30754. /** Projection coordinates mode */
  30755. static readonly TEXTURE_PROJECTION_MODE: number;
  30756. /** Skybox coordinates mode */
  30757. static readonly TEXTURE_SKYBOX_MODE: number;
  30758. /** Inverse Cubic coordinates mode */
  30759. static readonly TEXTURE_INVCUBIC_MODE: number;
  30760. /** Equirectangular coordinates mode */
  30761. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30762. /** Equirectangular Fixed coordinates mode */
  30763. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30764. /** Equirectangular Fixed Mirrored coordinates mode */
  30765. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30766. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30767. static readonly SCALEMODE_FLOOR: number;
  30768. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30769. static readonly SCALEMODE_NEAREST: number;
  30770. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30771. static readonly SCALEMODE_CEILING: number;
  30772. /**
  30773. * Returns the current npm package of the sdk
  30774. */
  30775. static readonly NpmPackage: string;
  30776. /**
  30777. * Returns the current version of the framework
  30778. */
  30779. static readonly Version: string;
  30780. /**
  30781. * Returns a string describing the current engine
  30782. */
  30783. readonly description: string;
  30784. /**
  30785. * Gets or sets the epsilon value used by collision engine
  30786. */
  30787. static CollisionsEpsilon: number;
  30788. /**
  30789. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30790. */
  30791. static ShadersRepository: string;
  30792. /**
  30793. * Method called to create the default loading screen.
  30794. * This can be overriden in your own app.
  30795. * @param canvas The rendering canvas element
  30796. * @returns The loading screen
  30797. */
  30798. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30799. /**
  30800. * Method called to create the default rescale post process on each engine.
  30801. */
  30802. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30803. /** @hidden */
  30804. _shaderProcessor: IShaderProcessor;
  30805. /**
  30806. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30807. */
  30808. forcePOTTextures: boolean;
  30809. /**
  30810. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30811. */
  30812. isFullscreen: boolean;
  30813. /**
  30814. * Gets a boolean indicating if the pointer is currently locked
  30815. */
  30816. isPointerLock: boolean;
  30817. /**
  30818. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30819. */
  30820. cullBackFaces: boolean;
  30821. /**
  30822. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30823. */
  30824. renderEvenInBackground: boolean;
  30825. /**
  30826. * Gets or sets a boolean indicating that cache can be kept between frames
  30827. */
  30828. preventCacheWipeBetweenFrames: boolean;
  30829. /**
  30830. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30831. **/
  30832. enableOfflineSupport: boolean;
  30833. /**
  30834. * 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)
  30835. **/
  30836. disableManifestCheck: boolean;
  30837. /**
  30838. * Gets the list of created scenes
  30839. */
  30840. scenes: Scene[];
  30841. /**
  30842. * Event raised when a new scene is created
  30843. */
  30844. onNewSceneAddedObservable: Observable<Scene>;
  30845. /**
  30846. * Gets the list of created postprocesses
  30847. */
  30848. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30849. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30850. validateShaderPrograms: boolean;
  30851. /**
  30852. * Observable event triggered each time the rendering canvas is resized
  30853. */
  30854. onResizeObservable: Observable<Engine>;
  30855. /**
  30856. * Observable event triggered each time the canvas loses focus
  30857. */
  30858. onCanvasBlurObservable: Observable<Engine>;
  30859. /**
  30860. * Observable event triggered each time the canvas gains focus
  30861. */
  30862. onCanvasFocusObservable: Observable<Engine>;
  30863. /**
  30864. * Observable event triggered each time the canvas receives pointerout event
  30865. */
  30866. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30867. /**
  30868. * Observable event triggered before each texture is initialized
  30869. */
  30870. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30871. /**
  30872. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30873. */
  30874. disableUniformBuffers: boolean;
  30875. /** @hidden */
  30876. _uniformBuffers: UniformBuffer[];
  30877. /**
  30878. * Gets a boolean indicating that the engine supports uniform buffers
  30879. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30880. */
  30881. readonly supportsUniformBuffers: boolean;
  30882. /**
  30883. * Observable raised when the engine begins a new frame
  30884. */
  30885. onBeginFrameObservable: Observable<Engine>;
  30886. /**
  30887. * If set, will be used to request the next animation frame for the render loop
  30888. */
  30889. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30890. /**
  30891. * Observable raised when the engine ends the current frame
  30892. */
  30893. onEndFrameObservable: Observable<Engine>;
  30894. /**
  30895. * Observable raised when the engine is about to compile a shader
  30896. */
  30897. onBeforeShaderCompilationObservable: Observable<Engine>;
  30898. /**
  30899. * Observable raised when the engine has jsut compiled a shader
  30900. */
  30901. onAfterShaderCompilationObservable: Observable<Engine>;
  30902. /** @hidden */
  30903. _gl: WebGLRenderingContext;
  30904. private _renderingCanvas;
  30905. private _windowIsBackground;
  30906. private _webGLVersion;
  30907. protected _highPrecisionShadersAllowed: boolean;
  30908. /** @hidden */
  30909. readonly _shouldUseHighPrecisionShader: boolean;
  30910. /**
  30911. * Gets a boolean indicating that only power of 2 textures are supported
  30912. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30913. */
  30914. readonly needPOTTextures: boolean;
  30915. /** @hidden */
  30916. _badOS: boolean;
  30917. /** @hidden */
  30918. _badDesktopOS: boolean;
  30919. /**
  30920. * Gets the audio engine
  30921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30922. * @ignorenaming
  30923. */
  30924. static audioEngine: IAudioEngine;
  30925. /**
  30926. * Default AudioEngine factory responsible of creating the Audio Engine.
  30927. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30928. */
  30929. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30930. /**
  30931. * Default offline support factory responsible of creating a tool used to store data locally.
  30932. * By default, this will create a Database object if the workload has been embedded.
  30933. */
  30934. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30935. private _onFocus;
  30936. private _onBlur;
  30937. private _onCanvasPointerOut;
  30938. private _onCanvasBlur;
  30939. private _onCanvasFocus;
  30940. private _onFullscreenChange;
  30941. private _onPointerLockChange;
  30942. private _hardwareScalingLevel;
  30943. /** @hidden */
  30944. _caps: EngineCapabilities;
  30945. private _pointerLockRequested;
  30946. private _isStencilEnable;
  30947. private _colorWrite;
  30948. private _loadingScreen;
  30949. /** @hidden */
  30950. _drawCalls: PerfCounter;
  30951. private _glVersion;
  30952. private _glRenderer;
  30953. private _glVendor;
  30954. private _videoTextureSupported;
  30955. private _renderingQueueLaunched;
  30956. private _activeRenderLoops;
  30957. private _deterministicLockstep;
  30958. private _lockstepMaxSteps;
  30959. /**
  30960. * Observable signaled when a context lost event is raised
  30961. */
  30962. onContextLostObservable: Observable<Engine>;
  30963. /**
  30964. * Observable signaled when a context restored event is raised
  30965. */
  30966. onContextRestoredObservable: Observable<Engine>;
  30967. private _onContextLost;
  30968. private _onContextRestored;
  30969. private _contextWasLost;
  30970. /** @hidden */
  30971. _doNotHandleContextLost: boolean;
  30972. /**
  30973. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30974. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30975. */
  30976. doNotHandleContextLost: boolean;
  30977. private _performanceMonitor;
  30978. private _fps;
  30979. private _deltaTime;
  30980. /**
  30981. * Turn this value on if you want to pause FPS computation when in background
  30982. */
  30983. disablePerformanceMonitorInBackground: boolean;
  30984. /**
  30985. * Gets the performance monitor attached to this engine
  30986. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30987. */
  30988. readonly performanceMonitor: PerformanceMonitor;
  30989. /**
  30990. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30991. */
  30992. disableVertexArrayObjects: boolean;
  30993. /** @hidden */
  30994. protected _depthCullingState: _DepthCullingState;
  30995. /** @hidden */
  30996. protected _stencilState: _StencilState;
  30997. /** @hidden */
  30998. protected _alphaState: _AlphaState;
  30999. /** @hidden */
  31000. protected _alphaMode: number;
  31001. /** @hidden */
  31002. _internalTexturesCache: InternalTexture[];
  31003. /** @hidden */
  31004. protected _activeChannel: number;
  31005. private _currentTextureChannel;
  31006. /** @hidden */
  31007. protected _boundTexturesCache: {
  31008. [key: string]: Nullable<InternalTexture>;
  31009. };
  31010. /** @hidden */
  31011. protected _currentEffect: Nullable<Effect>;
  31012. /** @hidden */
  31013. protected _currentProgram: Nullable<WebGLProgram>;
  31014. private _compiledEffects;
  31015. private _vertexAttribArraysEnabled;
  31016. /** @hidden */
  31017. protected _cachedViewport: Nullable<IViewportLike>;
  31018. private _cachedVertexArrayObject;
  31019. /** @hidden */
  31020. protected _cachedVertexBuffers: any;
  31021. /** @hidden */
  31022. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31023. /** @hidden */
  31024. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31025. /** @hidden */
  31026. _currentRenderTarget: Nullable<InternalTexture>;
  31027. private _uintIndicesCurrentlySet;
  31028. private _currentBoundBuffer;
  31029. /** @hidden */
  31030. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31031. private _currentBufferPointers;
  31032. private _currentInstanceLocations;
  31033. private _currentInstanceBuffers;
  31034. private _textureUnits;
  31035. /** @hidden */
  31036. _workingCanvas: Nullable<HTMLCanvasElement>;
  31037. /** @hidden */
  31038. _workingContext: Nullable<CanvasRenderingContext2D>;
  31039. private _rescalePostProcess;
  31040. private _dummyFramebuffer;
  31041. private _externalData;
  31042. /** @hidden */
  31043. _bindedRenderFunction: any;
  31044. private _vaoRecordInProgress;
  31045. private _mustWipeVertexAttributes;
  31046. private _emptyTexture;
  31047. private _emptyCubeTexture;
  31048. private _emptyTexture3D;
  31049. /** @hidden */
  31050. _frameHandler: number;
  31051. private _nextFreeTextureSlots;
  31052. private _maxSimultaneousTextures;
  31053. private _activeRequests;
  31054. private _texturesSupported;
  31055. /** @hidden */
  31056. _textureFormatInUse: Nullable<string>;
  31057. /**
  31058. * Gets the list of texture formats supported
  31059. */
  31060. readonly texturesSupported: Array<string>;
  31061. /**
  31062. * Gets the list of texture formats in use
  31063. */
  31064. readonly textureFormatInUse: Nullable<string>;
  31065. /**
  31066. * Gets the current viewport
  31067. */
  31068. readonly currentViewport: Nullable<IViewportLike>;
  31069. /**
  31070. * Gets the default empty texture
  31071. */
  31072. readonly emptyTexture: InternalTexture;
  31073. /**
  31074. * Gets the default empty 3D texture
  31075. */
  31076. readonly emptyTexture3D: InternalTexture;
  31077. /**
  31078. * Gets the default empty cube texture
  31079. */
  31080. readonly emptyCubeTexture: InternalTexture;
  31081. /**
  31082. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31083. */
  31084. readonly premultipliedAlpha: boolean;
  31085. /**
  31086. * Creates a new engine
  31087. * @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
  31088. * @param antialias defines enable antialiasing (default: false)
  31089. * @param options defines further options to be sent to the getContext() function
  31090. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31091. */
  31092. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31093. /**
  31094. * Initializes a webVR display and starts listening to display change events
  31095. * The onVRDisplayChangedObservable will be notified upon these changes
  31096. * @returns The onVRDisplayChangedObservable
  31097. */
  31098. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31099. /** @hidden */
  31100. _prepareVRComponent(): void;
  31101. /** @hidden */
  31102. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31103. /** @hidden */
  31104. _submitVRFrame(): void;
  31105. /**
  31106. * Call this function to leave webVR mode
  31107. * Will do nothing if webVR is not supported or if there is no webVR device
  31108. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31109. */
  31110. disableVR(): void;
  31111. /**
  31112. * Gets a boolean indicating that the system is in VR mode and is presenting
  31113. * @returns true if VR mode is engaged
  31114. */
  31115. isVRPresenting(): boolean;
  31116. /** @hidden */
  31117. _requestVRFrame(): void;
  31118. private _disableTouchAction;
  31119. private _rebuildInternalTextures;
  31120. private _rebuildEffects;
  31121. /**
  31122. * Gets a boolean indicating if all created effects are ready
  31123. * @returns true if all effects are ready
  31124. */
  31125. areAllEffectsReady(): boolean;
  31126. private _rebuildBuffers;
  31127. private _initGLContext;
  31128. /**
  31129. * Gets version of the current webGL context
  31130. */
  31131. readonly webGLVersion: number;
  31132. /**
  31133. * Gets a string idenfifying the name of the class
  31134. * @returns "Engine" string
  31135. */
  31136. getClassName(): string;
  31137. /**
  31138. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31139. */
  31140. readonly isStencilEnable: boolean;
  31141. /** @hidden */
  31142. _prepareWorkingCanvas(): void;
  31143. /**
  31144. * Reset the texture cache to empty state
  31145. */
  31146. resetTextureCache(): void;
  31147. /**
  31148. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31149. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31150. * @returns true if engine is in deterministic lock step mode
  31151. */
  31152. isDeterministicLockStep(): boolean;
  31153. /**
  31154. * Gets the max steps when engine is running in deterministic lock step
  31155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31156. * @returns the max steps
  31157. */
  31158. getLockstepMaxSteps(): number;
  31159. /**
  31160. * Gets an object containing information about the current webGL context
  31161. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31162. */
  31163. getGlInfo(): {
  31164. vendor: string;
  31165. renderer: string;
  31166. version: string;
  31167. };
  31168. /**
  31169. * Gets current aspect ratio
  31170. * @param viewportOwner defines the camera to use to get the aspect ratio
  31171. * @param useScreen defines if screen size must be used (or the current render target if any)
  31172. * @returns a number defining the aspect ratio
  31173. */
  31174. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31175. /**
  31176. * Gets current screen aspect ratio
  31177. * @returns a number defining the aspect ratio
  31178. */
  31179. getScreenAspectRatio(): number;
  31180. /**
  31181. * Gets the current render width
  31182. * @param useScreen defines if screen size must be used (or the current render target if any)
  31183. * @returns a number defining the current render width
  31184. */
  31185. getRenderWidth(useScreen?: boolean): number;
  31186. /**
  31187. * Gets the current render height
  31188. * @param useScreen defines if screen size must be used (or the current render target if any)
  31189. * @returns a number defining the current render height
  31190. */
  31191. getRenderHeight(useScreen?: boolean): number;
  31192. /**
  31193. * Gets the HTML canvas attached with the current webGL context
  31194. * @returns a HTML canvas
  31195. */
  31196. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31197. /**
  31198. * Gets host window
  31199. * @returns the host window object
  31200. */
  31201. getHostWindow(): Window;
  31202. /**
  31203. * Gets host document
  31204. * @returns the host document object
  31205. */
  31206. getHostDocument(): Document;
  31207. /**
  31208. * Gets the client rect of the HTML canvas attached with the current webGL context
  31209. * @returns a client rectanglee
  31210. */
  31211. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31212. /**
  31213. * Defines the hardware scaling level.
  31214. * By default the hardware scaling level is computed from the window device ratio.
  31215. * 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.
  31216. * @param level defines the level to use
  31217. */
  31218. setHardwareScalingLevel(level: number): void;
  31219. /**
  31220. * Gets the current hardware scaling level.
  31221. * By default the hardware scaling level is computed from the window device ratio.
  31222. * 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.
  31223. * @returns a number indicating the current hardware scaling level
  31224. */
  31225. getHardwareScalingLevel(): number;
  31226. /**
  31227. * Gets the list of loaded textures
  31228. * @returns an array containing all loaded textures
  31229. */
  31230. getLoadedTexturesCache(): InternalTexture[];
  31231. /**
  31232. * Gets the object containing all engine capabilities
  31233. * @returns the EngineCapabilities object
  31234. */
  31235. getCaps(): EngineCapabilities;
  31236. /**
  31237. * Gets the current depth function
  31238. * @returns a number defining the depth function
  31239. */
  31240. getDepthFunction(): Nullable<number>;
  31241. /**
  31242. * Sets the current depth function
  31243. * @param depthFunc defines the function to use
  31244. */
  31245. setDepthFunction(depthFunc: number): void;
  31246. /**
  31247. * Sets the current depth function to GREATER
  31248. */
  31249. setDepthFunctionToGreater(): void;
  31250. /**
  31251. * Sets the current depth function to GEQUAL
  31252. */
  31253. setDepthFunctionToGreaterOrEqual(): void;
  31254. /**
  31255. * Sets the current depth function to LESS
  31256. */
  31257. setDepthFunctionToLess(): void;
  31258. private _cachedStencilBuffer;
  31259. private _cachedStencilFunction;
  31260. private _cachedStencilMask;
  31261. private _cachedStencilOperationPass;
  31262. private _cachedStencilOperationFail;
  31263. private _cachedStencilOperationDepthFail;
  31264. private _cachedStencilReference;
  31265. /**
  31266. * Caches the the state of the stencil buffer
  31267. */
  31268. cacheStencilState(): void;
  31269. /**
  31270. * Restores the state of the stencil buffer
  31271. */
  31272. restoreStencilState(): void;
  31273. /**
  31274. * Sets the current depth function to LEQUAL
  31275. */
  31276. setDepthFunctionToLessOrEqual(): void;
  31277. /**
  31278. * Gets a boolean indicating if stencil buffer is enabled
  31279. * @returns the current stencil buffer state
  31280. */
  31281. getStencilBuffer(): boolean;
  31282. /**
  31283. * Enable or disable the stencil buffer
  31284. * @param enable defines if the stencil buffer must be enabled or disabled
  31285. */
  31286. setStencilBuffer(enable: boolean): void;
  31287. /**
  31288. * Gets the current stencil mask
  31289. * @returns a number defining the new stencil mask to use
  31290. */
  31291. getStencilMask(): number;
  31292. /**
  31293. * Sets the current stencil mask
  31294. * @param mask defines the new stencil mask to use
  31295. */
  31296. setStencilMask(mask: number): void;
  31297. /**
  31298. * Gets the current stencil function
  31299. * @returns a number defining the stencil function to use
  31300. */
  31301. getStencilFunction(): number;
  31302. /**
  31303. * Gets the current stencil reference value
  31304. * @returns a number defining the stencil reference value to use
  31305. */
  31306. getStencilFunctionReference(): number;
  31307. /**
  31308. * Gets the current stencil mask
  31309. * @returns a number defining the stencil mask to use
  31310. */
  31311. getStencilFunctionMask(): number;
  31312. /**
  31313. * Sets the current stencil function
  31314. * @param stencilFunc defines the new stencil function to use
  31315. */
  31316. setStencilFunction(stencilFunc: number): void;
  31317. /**
  31318. * Sets the current stencil reference
  31319. * @param reference defines the new stencil reference to use
  31320. */
  31321. setStencilFunctionReference(reference: number): void;
  31322. /**
  31323. * Sets the current stencil mask
  31324. * @param mask defines the new stencil mask to use
  31325. */
  31326. setStencilFunctionMask(mask: number): void;
  31327. /**
  31328. * Gets the current stencil operation when stencil fails
  31329. * @returns a number defining stencil operation to use when stencil fails
  31330. */
  31331. getStencilOperationFail(): number;
  31332. /**
  31333. * Gets the current stencil operation when depth fails
  31334. * @returns a number defining stencil operation to use when depth fails
  31335. */
  31336. getStencilOperationDepthFail(): number;
  31337. /**
  31338. * Gets the current stencil operation when stencil passes
  31339. * @returns a number defining stencil operation to use when stencil passes
  31340. */
  31341. getStencilOperationPass(): number;
  31342. /**
  31343. * Sets the stencil operation to use when stencil fails
  31344. * @param operation defines the stencil operation to use when stencil fails
  31345. */
  31346. setStencilOperationFail(operation: number): void;
  31347. /**
  31348. * Sets the stencil operation to use when depth fails
  31349. * @param operation defines the stencil operation to use when depth fails
  31350. */
  31351. setStencilOperationDepthFail(operation: number): void;
  31352. /**
  31353. * Sets the stencil operation to use when stencil passes
  31354. * @param operation defines the stencil operation to use when stencil passes
  31355. */
  31356. setStencilOperationPass(operation: number): void;
  31357. /**
  31358. * Sets a boolean indicating if the dithering state is enabled or disabled
  31359. * @param value defines the dithering state
  31360. */
  31361. setDitheringState(value: boolean): void;
  31362. /**
  31363. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31364. * @param value defines the rasterizer state
  31365. */
  31366. setRasterizerState(value: boolean): void;
  31367. /**
  31368. * stop executing a render loop function and remove it from the execution array
  31369. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31370. */
  31371. stopRenderLoop(renderFunction?: () => void): void;
  31372. /** @hidden */
  31373. _renderLoop(): void;
  31374. /**
  31375. * Register and execute a render loop. The engine can have more than one render function
  31376. * @param renderFunction defines the function to continuously execute
  31377. */
  31378. runRenderLoop(renderFunction: () => void): void;
  31379. /**
  31380. * Toggle full screen mode
  31381. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31382. */
  31383. switchFullscreen(requestPointerLock: boolean): void;
  31384. /**
  31385. * Enters full screen mode
  31386. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31387. */
  31388. enterFullscreen(requestPointerLock: boolean): void;
  31389. /**
  31390. * Exits full screen mode
  31391. */
  31392. exitFullscreen(): void;
  31393. /**
  31394. * Enters Pointerlock mode
  31395. */
  31396. enterPointerlock(): void;
  31397. /**
  31398. * Exits Pointerlock mode
  31399. */
  31400. exitPointerlock(): void;
  31401. /**
  31402. * Clear the current render buffer or the current render target (if any is set up)
  31403. * @param color defines the color to use
  31404. * @param backBuffer defines if the back buffer must be cleared
  31405. * @param depth defines if the depth buffer must be cleared
  31406. * @param stencil defines if the stencil buffer must be cleared
  31407. */
  31408. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31409. /**
  31410. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31411. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31412. * @param y defines the y-coordinate of the corner of the clear rectangle
  31413. * @param width defines the width of the clear rectangle
  31414. * @param height defines the height of the clear rectangle
  31415. * @param clearColor defines the clear color
  31416. */
  31417. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31418. /**
  31419. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31420. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31421. * @param y defines the y-coordinate of the corner of the clear rectangle
  31422. * @param width defines the width of the clear rectangle
  31423. * @param height defines the height of the clear rectangle
  31424. */
  31425. enableScissor(x: number, y: number, width: number, height: number): void;
  31426. /**
  31427. * Disable previously set scissor test rectangle
  31428. */
  31429. disableScissor(): void;
  31430. private _viewportCached;
  31431. /** @hidden */
  31432. _viewport(x: number, y: number, width: number, height: number): void;
  31433. /**
  31434. * Set the WebGL's viewport
  31435. * @param viewport defines the viewport element to be used
  31436. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31437. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31438. */
  31439. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31440. /**
  31441. * Directly set the WebGL Viewport
  31442. * @param x defines the x coordinate of the viewport (in screen space)
  31443. * @param y defines the y coordinate of the viewport (in screen space)
  31444. * @param width defines the width of the viewport (in screen space)
  31445. * @param height defines the height of the viewport (in screen space)
  31446. * @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
  31447. */
  31448. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31449. /**
  31450. * Begin a new frame
  31451. */
  31452. beginFrame(): void;
  31453. /**
  31454. * Enf the current frame
  31455. */
  31456. endFrame(): void;
  31457. /**
  31458. * Resize the view according to the canvas' size
  31459. */
  31460. resize(): void;
  31461. /**
  31462. * Force a specific size of the canvas
  31463. * @param width defines the new canvas' width
  31464. * @param height defines the new canvas' height
  31465. */
  31466. setSize(width: number, height: number): void;
  31467. /**
  31468. * Binds the frame buffer to the specified texture.
  31469. * @param texture The texture to render to or null for the default canvas
  31470. * @param faceIndex The face of the texture to render to in case of cube texture
  31471. * @param requiredWidth The width of the target to render to
  31472. * @param requiredHeight The height of the target to render to
  31473. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31474. * @param depthStencilTexture The depth stencil texture to use to render
  31475. * @param lodLevel defines le lod level to bind to the frame buffer
  31476. */
  31477. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31478. /** @hidden */
  31479. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31480. /**
  31481. * Unbind the current render target texture from the webGL context
  31482. * @param texture defines the render target texture to unbind
  31483. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31484. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31485. */
  31486. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31487. /**
  31488. * Force the mipmap generation for the given render target texture
  31489. * @param texture defines the render target texture to use
  31490. */
  31491. generateMipMapsForCubemap(texture: InternalTexture): void;
  31492. /**
  31493. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31494. */
  31495. flushFramebuffer(): void;
  31496. /**
  31497. * Unbind the current render target and bind the default framebuffer
  31498. */
  31499. restoreDefaultFramebuffer(): void;
  31500. /**
  31501. * Create an uniform buffer
  31502. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31503. * @param elements defines the content of the uniform buffer
  31504. * @returns the webGL uniform buffer
  31505. */
  31506. createUniformBuffer(elements: FloatArray): DataBuffer;
  31507. /**
  31508. * Create a dynamic uniform buffer
  31509. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31510. * @param elements defines the content of the uniform buffer
  31511. * @returns the webGL uniform buffer
  31512. */
  31513. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31514. /**
  31515. * Update an existing uniform buffer
  31516. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31517. * @param uniformBuffer defines the target uniform buffer
  31518. * @param elements defines the content to update
  31519. * @param offset defines the offset in the uniform buffer where update should start
  31520. * @param count defines the size of the data to update
  31521. */
  31522. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31523. private _resetVertexBufferBinding;
  31524. /**
  31525. * Creates a vertex buffer
  31526. * @param data the data for the vertex buffer
  31527. * @returns the new WebGL static buffer
  31528. */
  31529. createVertexBuffer(data: DataArray): DataBuffer;
  31530. /**
  31531. * Creates a dynamic vertex buffer
  31532. * @param data the data for the dynamic vertex buffer
  31533. * @returns the new WebGL dynamic buffer
  31534. */
  31535. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31536. /**
  31537. * Update a dynamic index buffer
  31538. * @param indexBuffer defines the target index buffer
  31539. * @param indices defines the data to update
  31540. * @param offset defines the offset in the target index buffer where update should start
  31541. */
  31542. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31543. /**
  31544. * Updates a dynamic vertex buffer.
  31545. * @param vertexBuffer the vertex buffer to update
  31546. * @param data the data used to update the vertex buffer
  31547. * @param byteOffset the byte offset of the data
  31548. * @param byteLength the byte length of the data
  31549. */
  31550. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31551. private _resetIndexBufferBinding;
  31552. /**
  31553. * Creates a new index buffer
  31554. * @param indices defines the content of the index buffer
  31555. * @param updatable defines if the index buffer must be updatable
  31556. * @returns a new webGL buffer
  31557. */
  31558. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31559. /**
  31560. * Bind a webGL buffer to the webGL context
  31561. * @param buffer defines the buffer to bind
  31562. */
  31563. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31564. /**
  31565. * Bind an uniform buffer to the current webGL context
  31566. * @param buffer defines the buffer to bind
  31567. */
  31568. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31569. /**
  31570. * Bind a buffer to the current webGL context at a given location
  31571. * @param buffer defines the buffer to bind
  31572. * @param location defines the index where to bind the buffer
  31573. */
  31574. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31575. /**
  31576. * Bind a specific block at a given index in a specific shader program
  31577. * @param pipelineContext defines the pipeline context to use
  31578. * @param blockName defines the block name
  31579. * @param index defines the index where to bind the block
  31580. */
  31581. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31582. private bindIndexBuffer;
  31583. private bindBuffer;
  31584. /**
  31585. * update the bound buffer with the given data
  31586. * @param data defines the data to update
  31587. */
  31588. updateArrayBuffer(data: Float32Array): void;
  31589. private _vertexAttribPointer;
  31590. private _bindIndexBufferWithCache;
  31591. private _bindVertexBuffersAttributes;
  31592. /**
  31593. * Records a vertex array object
  31594. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31595. * @param vertexBuffers defines the list of vertex buffers to store
  31596. * @param indexBuffer defines the index buffer to store
  31597. * @param effect defines the effect to store
  31598. * @returns the new vertex array object
  31599. */
  31600. recordVertexArrayObject(vertexBuffers: {
  31601. [key: string]: VertexBuffer;
  31602. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31603. /**
  31604. * Bind a specific vertex array object
  31605. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31606. * @param vertexArrayObject defines the vertex array object to bind
  31607. * @param indexBuffer defines the index buffer to bind
  31608. */
  31609. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31610. /**
  31611. * Bind webGl buffers directly to the webGL context
  31612. * @param vertexBuffer defines the vertex buffer to bind
  31613. * @param indexBuffer defines the index buffer to bind
  31614. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31615. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31616. * @param effect defines the effect associated with the vertex buffer
  31617. */
  31618. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31619. private _unbindVertexArrayObject;
  31620. /**
  31621. * Bind a list of vertex buffers to the webGL context
  31622. * @param vertexBuffers defines the list of vertex buffers to bind
  31623. * @param indexBuffer defines the index buffer to bind
  31624. * @param effect defines the effect associated with the vertex buffers
  31625. */
  31626. bindBuffers(vertexBuffers: {
  31627. [key: string]: Nullable<VertexBuffer>;
  31628. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31629. /**
  31630. * Unbind all instance attributes
  31631. */
  31632. unbindInstanceAttributes(): void;
  31633. /**
  31634. * Release and free the memory of a vertex array object
  31635. * @param vao defines the vertex array object to delete
  31636. */
  31637. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31638. /** @hidden */
  31639. _releaseBuffer(buffer: DataBuffer): boolean;
  31640. /**
  31641. * Creates a webGL buffer to use with instanciation
  31642. * @param capacity defines the size of the buffer
  31643. * @returns the webGL buffer
  31644. */
  31645. createInstancesBuffer(capacity: number): DataBuffer;
  31646. /**
  31647. * Delete a webGL buffer used with instanciation
  31648. * @param buffer defines the webGL buffer to delete
  31649. */
  31650. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31651. /**
  31652. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31653. * @param instancesBuffer defines the webGL buffer to update and bind
  31654. * @param data defines the data to store in the buffer
  31655. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31656. */
  31657. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31658. /**
  31659. * Apply all cached states (depth, culling, stencil and alpha)
  31660. */
  31661. applyStates(): void;
  31662. /**
  31663. * Send a draw order
  31664. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31665. * @param indexStart defines the starting index
  31666. * @param indexCount defines the number of index to draw
  31667. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31668. */
  31669. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31670. /**
  31671. * Draw a list of points
  31672. * @param verticesStart defines the index of first vertex to draw
  31673. * @param verticesCount defines the count of vertices to draw
  31674. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31675. */
  31676. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31677. /**
  31678. * Draw a list of unindexed primitives
  31679. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31680. * @param verticesStart defines the index of first vertex to draw
  31681. * @param verticesCount defines the count of vertices to draw
  31682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31683. */
  31684. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31685. /**
  31686. * Draw a list of indexed primitives
  31687. * @param fillMode defines the primitive to use
  31688. * @param indexStart defines the starting index
  31689. * @param indexCount defines the number of index to draw
  31690. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31691. */
  31692. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31693. /**
  31694. * Draw a list of unindexed primitives
  31695. * @param fillMode defines the primitive to use
  31696. * @param verticesStart defines the index of first vertex to draw
  31697. * @param verticesCount defines the count of vertices to draw
  31698. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31699. */
  31700. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31701. private _drawMode;
  31702. /** @hidden */
  31703. _releaseEffect(effect: Effect): void;
  31704. /** @hidden */
  31705. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31706. /**
  31707. * Create a new effect (used to store vertex/fragment shaders)
  31708. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31709. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31710. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31711. * @param samplers defines an array of string used to represent textures
  31712. * @param defines defines the string containing the defines to use to compile the shaders
  31713. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31714. * @param onCompiled defines a function to call when the effect creation is successful
  31715. * @param onError defines a function to call when the effect creation has failed
  31716. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31717. * @returns the new Effect
  31718. */
  31719. 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;
  31720. private _compileShader;
  31721. private _compileRawShader;
  31722. /**
  31723. * Directly creates a webGL program
  31724. * @param pipelineContext defines the pipeline context to attach to
  31725. * @param vertexCode defines the vertex shader code to use
  31726. * @param fragmentCode defines the fragment shader code to use
  31727. * @param context defines the webGL context to use (if not set, the current one will be used)
  31728. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31729. * @returns the new webGL program
  31730. */
  31731. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31732. /**
  31733. * Creates a webGL program
  31734. * @param pipelineContext defines the pipeline context to attach to
  31735. * @param vertexCode defines the vertex shader code to use
  31736. * @param fragmentCode defines the fragment shader code to use
  31737. * @param defines defines the string containing the defines to use to compile the shaders
  31738. * @param context defines the webGL context to use (if not set, the current one will be used)
  31739. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31740. * @returns the new webGL program
  31741. */
  31742. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31743. /**
  31744. * Creates a new pipeline context
  31745. * @returns the new pipeline
  31746. */
  31747. createPipelineContext(): WebGLPipelineContext;
  31748. private _createShaderProgram;
  31749. private _finalizePipelineContext;
  31750. /** @hidden */
  31751. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31752. /** @hidden */
  31753. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31754. /** @hidden */
  31755. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31756. /**
  31757. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31758. * @param pipelineContext defines the pipeline context to use
  31759. * @param uniformsNames defines the list of uniform names
  31760. * @returns an array of webGL uniform locations
  31761. */
  31762. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31763. /**
  31764. * Gets the lsit of active attributes for a given webGL program
  31765. * @param pipelineContext defines the pipeline context to use
  31766. * @param attributesNames defines the list of attribute names to get
  31767. * @returns an array of indices indicating the offset of each attribute
  31768. */
  31769. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31770. /**
  31771. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31772. * @param effect defines the effect to activate
  31773. */
  31774. enableEffect(effect: Nullable<Effect>): void;
  31775. /**
  31776. * Set the value of an uniform to an array of int32
  31777. * @param uniform defines the webGL uniform location where to store the value
  31778. * @param array defines the array of int32 to store
  31779. */
  31780. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31781. /**
  31782. * Set the value of an uniform to an array of int32 (stored as vec2)
  31783. * @param uniform defines the webGL uniform location where to store the value
  31784. * @param array defines the array of int32 to store
  31785. */
  31786. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31787. /**
  31788. * Set the value of an uniform to an array of int32 (stored as vec3)
  31789. * @param uniform defines the webGL uniform location where to store the value
  31790. * @param array defines the array of int32 to store
  31791. */
  31792. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31793. /**
  31794. * Set the value of an uniform to an array of int32 (stored as vec4)
  31795. * @param uniform defines the webGL uniform location where to store the value
  31796. * @param array defines the array of int32 to store
  31797. */
  31798. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31799. /**
  31800. * Set the value of an uniform to an array of float32
  31801. * @param uniform defines the webGL uniform location where to store the value
  31802. * @param array defines the array of float32 to store
  31803. */
  31804. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31805. /**
  31806. * Set the value of an uniform to an array of float32 (stored as vec2)
  31807. * @param uniform defines the webGL uniform location where to store the value
  31808. * @param array defines the array of float32 to store
  31809. */
  31810. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31811. /**
  31812. * Set the value of an uniform to an array of float32 (stored as vec3)
  31813. * @param uniform defines the webGL uniform location where to store the value
  31814. * @param array defines the array of float32 to store
  31815. */
  31816. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31817. /**
  31818. * Set the value of an uniform to an array of float32 (stored as vec4)
  31819. * @param uniform defines the webGL uniform location where to store the value
  31820. * @param array defines the array of float32 to store
  31821. */
  31822. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31823. /**
  31824. * Set the value of an uniform to an array of number
  31825. * @param uniform defines the webGL uniform location where to store the value
  31826. * @param array defines the array of number to store
  31827. */
  31828. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31829. /**
  31830. * Set the value of an uniform to an array of number (stored as vec2)
  31831. * @param uniform defines the webGL uniform location where to store the value
  31832. * @param array defines the array of number to store
  31833. */
  31834. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31835. /**
  31836. * Set the value of an uniform to an array of number (stored as vec3)
  31837. * @param uniform defines the webGL uniform location where to store the value
  31838. * @param array defines the array of number to store
  31839. */
  31840. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31841. /**
  31842. * Set the value of an uniform to an array of number (stored as vec4)
  31843. * @param uniform defines the webGL uniform location where to store the value
  31844. * @param array defines the array of number to store
  31845. */
  31846. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31847. /**
  31848. * Set the value of an uniform to an array of float32 (stored as matrices)
  31849. * @param uniform defines the webGL uniform location where to store the value
  31850. * @param matrices defines the array of float32 to store
  31851. */
  31852. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31853. /**
  31854. * Set the value of an uniform to a matrix (3x3)
  31855. * @param uniform defines the webGL uniform location where to store the value
  31856. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31857. */
  31858. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31859. /**
  31860. * Set the value of an uniform to a matrix (2x2)
  31861. * @param uniform defines the webGL uniform location where to store the value
  31862. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31863. */
  31864. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31865. /**
  31866. * Set the value of an uniform to a number (int)
  31867. * @param uniform defines the webGL uniform location where to store the value
  31868. * @param value defines the int number to store
  31869. */
  31870. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31871. /**
  31872. * Set the value of an uniform to a number (float)
  31873. * @param uniform defines the webGL uniform location where to store the value
  31874. * @param value defines the float number to store
  31875. */
  31876. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31877. /**
  31878. * Set the value of an uniform to a vec2
  31879. * @param uniform defines the webGL uniform location where to store the value
  31880. * @param x defines the 1st component of the value
  31881. * @param y defines the 2nd component of the value
  31882. */
  31883. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31884. /**
  31885. * Set the value of an uniform to a vec3
  31886. * @param uniform defines the webGL uniform location where to store the value
  31887. * @param x defines the 1st component of the value
  31888. * @param y defines the 2nd component of the value
  31889. * @param z defines the 3rd component of the value
  31890. */
  31891. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31892. /**
  31893. * Set the value of an uniform to a boolean
  31894. * @param uniform defines the webGL uniform location where to store the value
  31895. * @param bool defines the boolean to store
  31896. */
  31897. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31898. /**
  31899. * Set the value of an uniform to a vec4
  31900. * @param uniform defines the webGL uniform location where to store the value
  31901. * @param x defines the 1st component of the value
  31902. * @param y defines the 2nd component of the value
  31903. * @param z defines the 3rd component of the value
  31904. * @param w defines the 4th component of the value
  31905. */
  31906. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31907. /**
  31908. * Sets a Color4 on a uniform variable
  31909. * @param uniform defines the uniform location
  31910. * @param color4 defines the value to be set
  31911. */
  31912. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31913. /**
  31914. * Set various states to the webGL context
  31915. * @param culling defines backface culling state
  31916. * @param zOffset defines the value to apply to zOffset (0 by default)
  31917. * @param force defines if states must be applied even if cache is up to date
  31918. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31919. */
  31920. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31921. /**
  31922. * Set the z offset to apply to current rendering
  31923. * @param value defines the offset to apply
  31924. */
  31925. setZOffset(value: number): void;
  31926. /**
  31927. * Gets the current value of the zOffset
  31928. * @returns the current zOffset state
  31929. */
  31930. getZOffset(): number;
  31931. /**
  31932. * Enable or disable depth buffering
  31933. * @param enable defines the state to set
  31934. */
  31935. setDepthBuffer(enable: boolean): void;
  31936. /**
  31937. * Gets a boolean indicating if depth writing is enabled
  31938. * @returns the current depth writing state
  31939. */
  31940. getDepthWrite(): boolean;
  31941. /**
  31942. * Enable or disable depth writing
  31943. * @param enable defines the state to set
  31944. */
  31945. setDepthWrite(enable: boolean): void;
  31946. /**
  31947. * Enable or disable color writing
  31948. * @param enable defines the state to set
  31949. */
  31950. setColorWrite(enable: boolean): void;
  31951. /**
  31952. * Gets a boolean indicating if color writing is enabled
  31953. * @returns the current color writing state
  31954. */
  31955. getColorWrite(): boolean;
  31956. /**
  31957. * Sets alpha constants used by some alpha blending modes
  31958. * @param r defines the red component
  31959. * @param g defines the green component
  31960. * @param b defines the blue component
  31961. * @param a defines the alpha component
  31962. */
  31963. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31964. /**
  31965. * Sets the current alpha mode
  31966. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31967. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31968. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31969. */
  31970. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31971. /**
  31972. * Gets the current alpha mode
  31973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31974. * @returns the current alpha mode
  31975. */
  31976. getAlphaMode(): number;
  31977. /**
  31978. * Clears the list of texture accessible through engine.
  31979. * This can help preventing texture load conflict due to name collision.
  31980. */
  31981. clearInternalTexturesCache(): void;
  31982. /**
  31983. * Force the entire cache to be cleared
  31984. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31985. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31986. */
  31987. wipeCaches(bruteForce?: boolean): void;
  31988. /**
  31989. * Set the compressed texture format to use, based on the formats you have, and the formats
  31990. * supported by the hardware / browser.
  31991. *
  31992. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31993. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31994. * to API arguments needed to compressed textures. This puts the burden on the container
  31995. * generator to house the arcane code for determining these for current & future formats.
  31996. *
  31997. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31998. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31999. *
  32000. * Note: The result of this call is not taken into account when a texture is base64.
  32001. *
  32002. * @param formatsAvailable defines the list of those format families you have created
  32003. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32004. *
  32005. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32006. * @returns The extension selected.
  32007. */
  32008. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32009. /** @hidden */
  32010. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32011. min: number;
  32012. mag: number;
  32013. };
  32014. /** @hidden */
  32015. _createTexture(): WebGLTexture;
  32016. /**
  32017. * Usually called from Texture.ts.
  32018. * Passed information to create a WebGLTexture
  32019. * @param urlArg defines a value which contains one of the following:
  32020. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32021. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32022. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32023. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32024. * @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)
  32025. * @param scene needed for loading to the correct scene
  32026. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32027. * @param onLoad optional callback to be called upon successful completion
  32028. * @param onError optional callback to be called upon failure
  32029. * @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
  32030. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32031. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32032. * @param forcedExtension defines the extension to use to pick the right loader
  32033. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32034. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32035. */
  32036. 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;
  32037. /**
  32038. * @hidden
  32039. * Rescales a texture
  32040. * @param source input texutre
  32041. * @param destination destination texture
  32042. * @param scene scene to use to render the resize
  32043. * @param internalFormat format to use when resizing
  32044. * @param onComplete callback to be called when resize has completed
  32045. */
  32046. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32047. private _unpackFlipYCached;
  32048. /**
  32049. * In case you are sharing the context with other applications, it might
  32050. * be interested to not cache the unpack flip y state to ensure a consistent
  32051. * value would be set.
  32052. */
  32053. enableUnpackFlipYCached: boolean;
  32054. /** @hidden */
  32055. _unpackFlipY(value: boolean): void;
  32056. /** @hidden */
  32057. _getUnpackAlignement(): number;
  32058. /**
  32059. * Creates a dynamic texture
  32060. * @param width defines the width of the texture
  32061. * @param height defines the height of the texture
  32062. * @param generateMipMaps defines if the engine should generate the mip levels
  32063. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32064. * @returns the dynamic texture inside an InternalTexture
  32065. */
  32066. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32067. /**
  32068. * Update the sampling mode of a given texture
  32069. * @param samplingMode defines the required sampling mode
  32070. * @param texture defines the texture to update
  32071. */
  32072. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32073. /**
  32074. * Update the content of a dynamic texture
  32075. * @param texture defines the texture to update
  32076. * @param canvas defines the canvas containing the source
  32077. * @param invertY defines if data must be stored with Y axis inverted
  32078. * @param premulAlpha defines if alpha is stored as premultiplied
  32079. * @param format defines the format of the data
  32080. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32081. */
  32082. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32083. /**
  32084. * Update a video texture
  32085. * @param texture defines the texture to update
  32086. * @param video defines the video element to use
  32087. * @param invertY defines if data must be stored with Y axis inverted
  32088. */
  32089. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32090. /**
  32091. * Updates a depth texture Comparison Mode and Function.
  32092. * If the comparison Function is equal to 0, the mode will be set to none.
  32093. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32094. * @param texture The texture to set the comparison function for
  32095. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32096. */
  32097. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32098. /** @hidden */
  32099. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32100. width: number;
  32101. height: number;
  32102. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32103. /**
  32104. * Creates a depth stencil texture.
  32105. * This is only available in WebGL 2 or with the depth texture extension available.
  32106. * @param size The size of face edge in the texture.
  32107. * @param options The options defining the texture.
  32108. * @returns The texture
  32109. */
  32110. createDepthStencilTexture(size: number | {
  32111. width: number;
  32112. height: number;
  32113. }, options: DepthTextureCreationOptions): InternalTexture;
  32114. /**
  32115. * Creates a depth stencil texture.
  32116. * This is only available in WebGL 2 or with the depth texture extension available.
  32117. * @param size The size of face edge in the texture.
  32118. * @param options The options defining the texture.
  32119. * @returns The texture
  32120. */
  32121. private _createDepthStencilTexture;
  32122. /**
  32123. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32124. * @param renderTarget The render target to set the frame buffer for
  32125. */
  32126. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32127. /**
  32128. * Creates a new render target texture
  32129. * @param size defines the size of the texture
  32130. * @param options defines the options used to create the texture
  32131. * @returns a new render target texture stored in an InternalTexture
  32132. */
  32133. createRenderTargetTexture(size: number | {
  32134. width: number;
  32135. height: number;
  32136. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32137. /** @hidden */
  32138. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32139. /**
  32140. * Updates the sample count of a render target texture
  32141. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32142. * @param texture defines the texture to update
  32143. * @param samples defines the sample count to set
  32144. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32145. */
  32146. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32147. /** @hidden */
  32148. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32149. /** @hidden */
  32150. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32151. /** @hidden */
  32152. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32153. /** @hidden */
  32154. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32155. /**
  32156. * @hidden
  32157. */
  32158. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32159. private _prepareWebGLTextureContinuation;
  32160. private _prepareWebGLTexture;
  32161. /** @hidden */
  32162. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32163. /** @hidden */
  32164. _releaseFramebufferObjects(texture: InternalTexture): void;
  32165. /** @hidden */
  32166. _releaseTexture(texture: InternalTexture): void;
  32167. private setProgram;
  32168. private _boundUniforms;
  32169. /**
  32170. * Binds an effect to the webGL context
  32171. * @param effect defines the effect to bind
  32172. */
  32173. bindSamplers(effect: Effect): void;
  32174. private _activateCurrentTexture;
  32175. /** @hidden */
  32176. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32177. /** @hidden */
  32178. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32179. /**
  32180. * Sets a texture to the webGL context from a postprocess
  32181. * @param channel defines the channel to use
  32182. * @param postProcess defines the source postprocess
  32183. */
  32184. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32185. /**
  32186. * Binds the output of the passed in post process to the texture channel specified
  32187. * @param channel The channel the texture should be bound to
  32188. * @param postProcess The post process which's output should be bound
  32189. */
  32190. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32191. /**
  32192. * Unbind all textures from the webGL context
  32193. */
  32194. unbindAllTextures(): void;
  32195. /**
  32196. * Sets a texture to the according uniform.
  32197. * @param channel The texture channel
  32198. * @param uniform The uniform to set
  32199. * @param texture The texture to apply
  32200. */
  32201. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32202. /**
  32203. * Sets a depth stencil texture from a render target to the according uniform.
  32204. * @param channel The texture channel
  32205. * @param uniform The uniform to set
  32206. * @param texture The render target texture containing the depth stencil texture to apply
  32207. */
  32208. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32209. private _bindSamplerUniformToChannel;
  32210. private _getTextureWrapMode;
  32211. private _setTexture;
  32212. /**
  32213. * Sets an array of texture to the webGL context
  32214. * @param channel defines the channel where the texture array must be set
  32215. * @param uniform defines the associated uniform location
  32216. * @param textures defines the array of textures to bind
  32217. */
  32218. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32219. /** @hidden */
  32220. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32221. private _setTextureParameterFloat;
  32222. private _setTextureParameterInteger;
  32223. /**
  32224. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32225. * @param x defines the x coordinate of the rectangle where pixels must be read
  32226. * @param y defines the y coordinate of the rectangle where pixels must be read
  32227. * @param width defines the width of the rectangle where pixels must be read
  32228. * @param height defines the height of the rectangle where pixels must be read
  32229. * @returns a Uint8Array containing RGBA colors
  32230. */
  32231. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32232. /**
  32233. * Add an externaly attached data from its key.
  32234. * This method call will fail and return false, if such key already exists.
  32235. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32236. * @param key the unique key that identifies the data
  32237. * @param data the data object to associate to the key for this Engine instance
  32238. * @return true if no such key were already present and the data was added successfully, false otherwise
  32239. */
  32240. addExternalData<T>(key: string, data: T): boolean;
  32241. /**
  32242. * Get an externaly attached data from its key
  32243. * @param key the unique key that identifies the data
  32244. * @return the associated data, if present (can be null), or undefined if not present
  32245. */
  32246. getExternalData<T>(key: string): T;
  32247. /**
  32248. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32249. * @param key the unique key that identifies the data
  32250. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32251. * @return the associated data, can be null if the factory returned null.
  32252. */
  32253. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32254. /**
  32255. * Remove an externaly attached data from the Engine instance
  32256. * @param key the unique key that identifies the data
  32257. * @return true if the data was successfully removed, false if it doesn't exist
  32258. */
  32259. removeExternalData(key: string): boolean;
  32260. /**
  32261. * Unbind all vertex attributes from the webGL context
  32262. */
  32263. unbindAllAttributes(): void;
  32264. /**
  32265. * 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
  32266. */
  32267. releaseEffects(): void;
  32268. /**
  32269. * Dispose and release all associated resources
  32270. */
  32271. dispose(): void;
  32272. /**
  32273. * Display the loading screen
  32274. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32275. */
  32276. displayLoadingUI(): void;
  32277. /**
  32278. * Hide the loading screen
  32279. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32280. */
  32281. hideLoadingUI(): void;
  32282. /**
  32283. * Gets the current loading screen object
  32284. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32285. */
  32286. /**
  32287. * Sets the current loading screen object
  32288. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32289. */
  32290. loadingScreen: ILoadingScreen;
  32291. /**
  32292. * Sets the current loading screen text
  32293. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32294. */
  32295. loadingUIText: string;
  32296. /**
  32297. * Sets the current loading screen background color
  32298. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32299. */
  32300. loadingUIBackgroundColor: string;
  32301. /**
  32302. * Attach a new callback raised when context lost event is fired
  32303. * @param callback defines the callback to call
  32304. */
  32305. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32306. /**
  32307. * Attach a new callback raised when context restored event is fired
  32308. * @param callback defines the callback to call
  32309. */
  32310. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32311. /**
  32312. * Gets the source code of the vertex shader associated with a specific webGL program
  32313. * @param program defines the program to use
  32314. * @returns a string containing the source code of the vertex shader associated with the program
  32315. */
  32316. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32317. /**
  32318. * Gets the source code of the fragment shader associated with a specific webGL program
  32319. * @param program defines the program to use
  32320. * @returns a string containing the source code of the fragment shader associated with the program
  32321. */
  32322. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32323. /**
  32324. * Get the current error code of the webGL context
  32325. * @returns the error code
  32326. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32327. */
  32328. getError(): number;
  32329. /**
  32330. * Gets the current framerate
  32331. * @returns a number representing the framerate
  32332. */
  32333. getFps(): number;
  32334. /**
  32335. * Gets the time spent between current and previous frame
  32336. * @returns a number representing the delta time in ms
  32337. */
  32338. getDeltaTime(): number;
  32339. private _measureFps;
  32340. /** @hidden */
  32341. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32342. private _canRenderToFloatFramebuffer;
  32343. private _canRenderToHalfFloatFramebuffer;
  32344. private _canRenderToFramebuffer;
  32345. /** @hidden */
  32346. _getWebGLTextureType(type: number): number;
  32347. /** @hidden */
  32348. _getInternalFormat(format: number): number;
  32349. /** @hidden */
  32350. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32351. /** @hidden */
  32352. _getRGBAMultiSampleBufferFormat(type: number): number;
  32353. /** @hidden */
  32354. _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;
  32355. /** @hidden */
  32356. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32357. /**
  32358. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32359. * @returns true if the engine can be created
  32360. * @ignorenaming
  32361. */
  32362. static isSupported(): boolean;
  32363. /**
  32364. * Find the next highest power of two.
  32365. * @param x Number to start search from.
  32366. * @return Next highest power of two.
  32367. */
  32368. static CeilingPOT(x: number): number;
  32369. /**
  32370. * Find the next lowest power of two.
  32371. * @param x Number to start search from.
  32372. * @return Next lowest power of two.
  32373. */
  32374. static FloorPOT(x: number): number;
  32375. /**
  32376. * Find the nearest power of two.
  32377. * @param x Number to start search from.
  32378. * @return Next nearest power of two.
  32379. */
  32380. static NearestPOT(x: number): number;
  32381. /**
  32382. * Get the closest exponent of two
  32383. * @param value defines the value to approximate
  32384. * @param max defines the maximum value to return
  32385. * @param mode defines how to define the closest value
  32386. * @returns closest exponent of two of the given value
  32387. */
  32388. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32389. /**
  32390. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32391. * @param func - the function to be called
  32392. * @param requester - the object that will request the next frame. Falls back to window.
  32393. * @returns frame number
  32394. */
  32395. static QueueNewFrame(func: () => void, requester?: any): number;
  32396. /**
  32397. * Ask the browser to promote the current element to pointerlock mode
  32398. * @param element defines the DOM element to promote
  32399. */
  32400. static _RequestPointerlock(element: HTMLElement): void;
  32401. /**
  32402. * Asks the browser to exit pointerlock mode
  32403. */
  32404. static _ExitPointerlock(): void;
  32405. /**
  32406. * Ask the browser to promote the current element to fullscreen rendering mode
  32407. * @param element defines the DOM element to promote
  32408. */
  32409. static _RequestFullscreen(element: HTMLElement): void;
  32410. /**
  32411. * Asks the browser to exit fullscreen mode
  32412. */
  32413. static _ExitFullscreen(): void;
  32414. }
  32415. }
  32416. declare module "babylonjs/Engines/engineStore" {
  32417. import { Nullable } from "babylonjs/types";
  32418. import { Engine } from "babylonjs/Engines/engine";
  32419. import { Scene } from "babylonjs/scene";
  32420. /**
  32421. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32422. * during the life time of the application.
  32423. */
  32424. export class EngineStore {
  32425. /** Gets the list of created engines */
  32426. static Instances: import("babylonjs/Engines/engine").Engine[];
  32427. /** @hidden */
  32428. static _LastCreatedScene: Nullable<Scene>;
  32429. /**
  32430. * Gets the latest created engine
  32431. */
  32432. static readonly LastCreatedEngine: Nullable<Engine>;
  32433. /**
  32434. * Gets the latest created scene
  32435. */
  32436. static readonly LastCreatedScene: Nullable<Scene>;
  32437. /**
  32438. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32439. * @ignorenaming
  32440. */
  32441. static UseFallbackTexture: boolean;
  32442. /**
  32443. * Texture content used if a texture cannot loaded
  32444. * @ignorenaming
  32445. */
  32446. static FallbackTexture: string;
  32447. }
  32448. }
  32449. declare module "babylonjs/Misc/promise" {
  32450. /**
  32451. * Helper class that provides a small promise polyfill
  32452. */
  32453. export class PromisePolyfill {
  32454. /**
  32455. * Static function used to check if the polyfill is required
  32456. * If this is the case then the function will inject the polyfill to window.Promise
  32457. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32458. */
  32459. static Apply(force?: boolean): void;
  32460. }
  32461. }
  32462. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32463. /**
  32464. * Interface for screenshot methods with describe argument called `size` as object with options
  32465. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32466. */
  32467. export interface IScreenshotSize {
  32468. /**
  32469. * number in pixels for canvas height
  32470. */
  32471. height?: number;
  32472. /**
  32473. * multiplier allowing render at a higher or lower resolution
  32474. * If value is defined then height and width will be ignored and taken from camera
  32475. */
  32476. precision?: number;
  32477. /**
  32478. * number in pixels for canvas width
  32479. */
  32480. width?: number;
  32481. }
  32482. }
  32483. declare module "babylonjs/Misc/tools" {
  32484. import { Nullable, float } from "babylonjs/types";
  32485. import { DomManagement } from "babylonjs/Misc/domManagement";
  32486. import { WebRequest } from "babylonjs/Misc/webRequest";
  32487. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32488. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32489. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32490. import { Camera } from "babylonjs/Cameras/camera";
  32491. import { Engine } from "babylonjs/Engines/engine";
  32492. interface IColor4Like {
  32493. r: float;
  32494. g: float;
  32495. b: float;
  32496. a: float;
  32497. }
  32498. /**
  32499. * Class containing a set of static utilities functions
  32500. */
  32501. export class Tools {
  32502. /**
  32503. * Gets or sets the base URL to use to load assets
  32504. */
  32505. static BaseUrl: string;
  32506. /**
  32507. * Enable/Disable Custom HTTP Request Headers globally.
  32508. * default = false
  32509. * @see CustomRequestHeaders
  32510. */
  32511. static UseCustomRequestHeaders: boolean;
  32512. /**
  32513. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32514. * i.e. when loading files, where the server/service expects an Authorization header
  32515. */
  32516. static CustomRequestHeaders: {
  32517. [key: string]: string;
  32518. };
  32519. /**
  32520. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32521. */
  32522. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32523. /**
  32524. * Default behaviour for cors in the application.
  32525. * It can be a string if the expected behavior is identical in the entire app.
  32526. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32527. */
  32528. static CorsBehavior: string | ((url: string | string[]) => string);
  32529. /**
  32530. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32531. * @ignorenaming
  32532. */
  32533. static UseFallbackTexture: boolean;
  32534. /**
  32535. * Use this object to register external classes like custom textures or material
  32536. * to allow the laoders to instantiate them
  32537. */
  32538. static RegisteredExternalClasses: {
  32539. [key: string]: Object;
  32540. };
  32541. /**
  32542. * Texture content used if a texture cannot loaded
  32543. * @ignorenaming
  32544. */
  32545. static fallbackTexture: string;
  32546. /**
  32547. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32548. * @param u defines the coordinate on X axis
  32549. * @param v defines the coordinate on Y axis
  32550. * @param width defines the width of the source data
  32551. * @param height defines the height of the source data
  32552. * @param pixels defines the source byte array
  32553. * @param color defines the output color
  32554. */
  32555. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32556. /**
  32557. * Interpolates between a and b via alpha
  32558. * @param a The lower value (returned when alpha = 0)
  32559. * @param b The upper value (returned when alpha = 1)
  32560. * @param alpha The interpolation-factor
  32561. * @return The mixed value
  32562. */
  32563. static Mix(a: number, b: number, alpha: number): number;
  32564. /**
  32565. * Tries to instantiate a new object from a given class name
  32566. * @param className defines the class name to instantiate
  32567. * @returns the new object or null if the system was not able to do the instantiation
  32568. */
  32569. static Instantiate(className: string): any;
  32570. /**
  32571. * Provides a slice function that will work even on IE
  32572. * @param data defines the array to slice
  32573. * @param start defines the start of the data (optional)
  32574. * @param end defines the end of the data (optional)
  32575. * @returns the new sliced array
  32576. */
  32577. static Slice<T>(data: T, start?: number, end?: number): T;
  32578. /**
  32579. * Polyfill for setImmediate
  32580. * @param action defines the action to execute after the current execution block
  32581. */
  32582. static SetImmediate(action: () => void): void;
  32583. /**
  32584. * Function indicating if a number is an exponent of 2
  32585. * @param value defines the value to test
  32586. * @returns true if the value is an exponent of 2
  32587. */
  32588. static IsExponentOfTwo(value: number): boolean;
  32589. private static _tmpFloatArray;
  32590. /**
  32591. * Returns the nearest 32-bit single precision float representation of a Number
  32592. * @param value A Number. If the parameter is of a different type, it will get converted
  32593. * to a number or to NaN if it cannot be converted
  32594. * @returns number
  32595. */
  32596. static FloatRound(value: number): number;
  32597. /**
  32598. * Extracts the filename from a path
  32599. * @param path defines the path to use
  32600. * @returns the filename
  32601. */
  32602. static GetFilename(path: string): string;
  32603. /**
  32604. * Extracts the "folder" part of a path (everything before the filename).
  32605. * @param uri The URI to extract the info from
  32606. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32607. * @returns The "folder" part of the path
  32608. */
  32609. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32610. /**
  32611. * Extracts text content from a DOM element hierarchy
  32612. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32613. */
  32614. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32615. /**
  32616. * Convert an angle in radians to degrees
  32617. * @param angle defines the angle to convert
  32618. * @returns the angle in degrees
  32619. */
  32620. static ToDegrees(angle: number): number;
  32621. /**
  32622. * Convert an angle in degrees to radians
  32623. * @param angle defines the angle to convert
  32624. * @returns the angle in radians
  32625. */
  32626. static ToRadians(angle: number): number;
  32627. /**
  32628. * Encode a buffer to a base64 string
  32629. * @param buffer defines the buffer to encode
  32630. * @returns the encoded string
  32631. */
  32632. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32633. /**
  32634. * Returns an array if obj is not an array
  32635. * @param obj defines the object to evaluate as an array
  32636. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32637. * @returns either obj directly if obj is an array or a new array containing obj
  32638. */
  32639. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32640. /**
  32641. * Gets the pointer prefix to use
  32642. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32643. */
  32644. static GetPointerPrefix(): string;
  32645. /**
  32646. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32647. * @param url define the url we are trying
  32648. * @param element define the dom element where to configure the cors policy
  32649. */
  32650. static SetCorsBehavior(url: string | string[], element: {
  32651. crossOrigin: string | null;
  32652. }): void;
  32653. /**
  32654. * Removes unwanted characters from an url
  32655. * @param url defines the url to clean
  32656. * @returns the cleaned url
  32657. */
  32658. static CleanUrl(url: string): string;
  32659. /**
  32660. * Gets or sets a function used to pre-process url before using them to load assets
  32661. */
  32662. static PreprocessUrl: (url: string) => string;
  32663. /**
  32664. * Loads an image as an HTMLImageElement.
  32665. * @param input url string, ArrayBuffer, or Blob to load
  32666. * @param onLoad callback called when the image successfully loads
  32667. * @param onError callback called when the image fails to load
  32668. * @param offlineProvider offline provider for caching
  32669. * @returns the HTMLImageElement of the loaded image
  32670. */
  32671. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32672. /**
  32673. * Loads a file
  32674. * @param url url string, ArrayBuffer, or Blob to load
  32675. * @param onSuccess callback called when the file successfully loads
  32676. * @param onProgress callback called while file is loading (if the server supports this mode)
  32677. * @param offlineProvider defines the offline provider for caching
  32678. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32679. * @param onError callback called when the file fails to load
  32680. * @returns a file request object
  32681. */
  32682. 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;
  32683. /**
  32684. * Loads a file from a url
  32685. * @param url the file url to load
  32686. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32687. */
  32688. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32689. /**
  32690. * Load a script (identified by an url). When the url returns, the
  32691. * content of this file is added into a new script element, attached to the DOM (body element)
  32692. * @param scriptUrl defines the url of the script to laod
  32693. * @param onSuccess defines the callback called when the script is loaded
  32694. * @param onError defines the callback to call if an error occurs
  32695. * @param scriptId defines the id of the script element
  32696. */
  32697. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32698. /**
  32699. * Load an asynchronous script (identified by an url). When the url returns, the
  32700. * content of this file is added into a new script element, attached to the DOM (body element)
  32701. * @param scriptUrl defines the url of the script to laod
  32702. * @param scriptId defines the id of the script element
  32703. * @returns a promise request object
  32704. */
  32705. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32706. /**
  32707. * Loads a file from a blob
  32708. * @param fileToLoad defines the blob to use
  32709. * @param callback defines the callback to call when data is loaded
  32710. * @param progressCallback defines the callback to call during loading process
  32711. * @returns a file request object
  32712. */
  32713. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32714. /**
  32715. * Loads a file
  32716. * @param fileToLoad defines the file to load
  32717. * @param callback defines the callback to call when data is loaded
  32718. * @param progressCallBack defines the callback to call during loading process
  32719. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32720. * @returns a file request object
  32721. */
  32722. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32723. /**
  32724. * Creates a data url from a given string content
  32725. * @param content defines the content to convert
  32726. * @returns the new data url link
  32727. */
  32728. static FileAsURL(content: string): string;
  32729. /**
  32730. * Format the given number to a specific decimal format
  32731. * @param value defines the number to format
  32732. * @param decimals defines the number of decimals to use
  32733. * @returns the formatted string
  32734. */
  32735. static Format(value: number, decimals?: number): string;
  32736. /**
  32737. * Tries to copy an object by duplicating every property
  32738. * @param source defines the source object
  32739. * @param destination defines the target object
  32740. * @param doNotCopyList defines a list of properties to avoid
  32741. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32742. */
  32743. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32744. /**
  32745. * Gets a boolean indicating if the given object has no own property
  32746. * @param obj defines the object to test
  32747. * @returns true if object has no own property
  32748. */
  32749. static IsEmpty(obj: any): boolean;
  32750. /**
  32751. * Function used to register events at window level
  32752. * @param windowElement defines the Window object to use
  32753. * @param events defines the events to register
  32754. */
  32755. static RegisterTopRootEvents(windowElement: Window, events: {
  32756. name: string;
  32757. handler: Nullable<(e: FocusEvent) => any>;
  32758. }[]): void;
  32759. /**
  32760. * Function used to unregister events from window level
  32761. * @param windowElement defines the Window object to use
  32762. * @param events defines the events to unregister
  32763. */
  32764. static UnregisterTopRootEvents(windowElement: Window, events: {
  32765. name: string;
  32766. handler: Nullable<(e: FocusEvent) => any>;
  32767. }[]): void;
  32768. /**
  32769. * @ignore
  32770. */
  32771. static _ScreenshotCanvas: HTMLCanvasElement;
  32772. /**
  32773. * Dumps the current bound framebuffer
  32774. * @param width defines the rendering width
  32775. * @param height defines the rendering height
  32776. * @param engine defines the hosting engine
  32777. * @param successCallback defines the callback triggered once the data are available
  32778. * @param mimeType defines the mime type of the result
  32779. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32780. */
  32781. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32782. /**
  32783. * Converts the canvas data to blob.
  32784. * This acts as a polyfill for browsers not supporting the to blob function.
  32785. * @param canvas Defines the canvas to extract the data from
  32786. * @param successCallback Defines the callback triggered once the data are available
  32787. * @param mimeType Defines the mime type of the result
  32788. */
  32789. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32790. /**
  32791. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32792. * @param successCallback defines the callback triggered once the data are available
  32793. * @param mimeType defines the mime type of the result
  32794. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32795. */
  32796. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32797. /**
  32798. * Downloads a blob in the browser
  32799. * @param blob defines the blob to download
  32800. * @param fileName defines the name of the downloaded file
  32801. */
  32802. static Download(blob: Blob, fileName: string): void;
  32803. /**
  32804. * Captures a screenshot of the current rendering
  32805. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32806. * @param engine defines the rendering engine
  32807. * @param camera defines the source camera
  32808. * @param size This parameter can be set to a single number or to an object with the
  32809. * following (optional) properties: precision, width, height. If a single number is passed,
  32810. * it will be used for both width and height. If an object is passed, the screenshot size
  32811. * will be derived from the parameters. The precision property is a multiplier allowing
  32812. * rendering at a higher or lower resolution
  32813. * @param successCallback defines the callback receives a single parameter which contains the
  32814. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32815. * src parameter of an <img> to display it
  32816. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32817. * Check your browser for supported MIME types
  32818. */
  32819. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32820. /**
  32821. * Captures a screenshot of the current rendering
  32822. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32823. * @param engine defines the rendering engine
  32824. * @param camera defines the source camera
  32825. * @param size This parameter can be set to a single number or to an object with the
  32826. * following (optional) properties: precision, width, height. If a single number is passed,
  32827. * it will be used for both width and height. If an object is passed, the screenshot size
  32828. * will be derived from the parameters. The precision property is a multiplier allowing
  32829. * rendering at a higher or lower resolution
  32830. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32831. * Check your browser for supported MIME types
  32832. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32833. * to the src parameter of an <img> to display it
  32834. */
  32835. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32836. /**
  32837. * Generates an image screenshot from the specified camera.
  32838. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32839. * @param engine The engine to use for rendering
  32840. * @param camera The camera to use for rendering
  32841. * @param size This parameter can be set to a single number or to an object with the
  32842. * following (optional) properties: precision, width, height. If a single number is passed,
  32843. * it will be used for both width and height. If an object is passed, the screenshot size
  32844. * will be derived from the parameters. The precision property is a multiplier allowing
  32845. * rendering at a higher or lower resolution
  32846. * @param successCallback The callback receives a single parameter which contains the
  32847. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32848. * src parameter of an <img> to display it
  32849. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32850. * Check your browser for supported MIME types
  32851. * @param samples Texture samples (default: 1)
  32852. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32853. * @param fileName A name for for the downloaded file.
  32854. */
  32855. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32856. /**
  32857. * Generates an image screenshot from the specified camera.
  32858. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32859. * @param engine The engine to use for rendering
  32860. * @param camera The camera to use for rendering
  32861. * @param size This parameter can be set to a single number or to an object with the
  32862. * following (optional) properties: precision, width, height. If a single number is passed,
  32863. * it will be used for both width and height. If an object is passed, the screenshot size
  32864. * will be derived from the parameters. The precision property is a multiplier allowing
  32865. * rendering at a higher or lower resolution
  32866. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32867. * Check your browser for supported MIME types
  32868. * @param samples Texture samples (default: 1)
  32869. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32870. * @param fileName A name for for the downloaded file.
  32871. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32872. * to the src parameter of an <img> to display it
  32873. */
  32874. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32875. /**
  32876. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32877. * Be aware Math.random() could cause collisions, but:
  32878. * "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"
  32879. * @returns a pseudo random id
  32880. */
  32881. static RandomId(): string;
  32882. /**
  32883. * Test if the given uri is a base64 string
  32884. * @param uri The uri to test
  32885. * @return True if the uri is a base64 string or false otherwise
  32886. */
  32887. static IsBase64(uri: string): boolean;
  32888. /**
  32889. * Decode the given base64 uri.
  32890. * @param uri The uri to decode
  32891. * @return The decoded base64 data.
  32892. */
  32893. static DecodeBase64(uri: string): ArrayBuffer;
  32894. /**
  32895. * Gets the absolute url.
  32896. * @param url the input url
  32897. * @return the absolute url
  32898. */
  32899. static GetAbsoluteUrl(url: string): string;
  32900. /**
  32901. * No log
  32902. */
  32903. static readonly NoneLogLevel: number;
  32904. /**
  32905. * Only message logs
  32906. */
  32907. static readonly MessageLogLevel: number;
  32908. /**
  32909. * Only warning logs
  32910. */
  32911. static readonly WarningLogLevel: number;
  32912. /**
  32913. * Only error logs
  32914. */
  32915. static readonly ErrorLogLevel: number;
  32916. /**
  32917. * All logs
  32918. */
  32919. static readonly AllLogLevel: number;
  32920. /**
  32921. * Gets a value indicating the number of loading errors
  32922. * @ignorenaming
  32923. */
  32924. static readonly errorsCount: number;
  32925. /**
  32926. * Callback called when a new log is added
  32927. */
  32928. static OnNewCacheEntry: (entry: string) => void;
  32929. /**
  32930. * Log a message to the console
  32931. * @param message defines the message to log
  32932. */
  32933. static Log(message: string): void;
  32934. /**
  32935. * Write a warning message to the console
  32936. * @param message defines the message to log
  32937. */
  32938. static Warn(message: string): void;
  32939. /**
  32940. * Write an error message to the console
  32941. * @param message defines the message to log
  32942. */
  32943. static Error(message: string): void;
  32944. /**
  32945. * Gets current log cache (list of logs)
  32946. */
  32947. static readonly LogCache: string;
  32948. /**
  32949. * Clears the log cache
  32950. */
  32951. static ClearLogCache(): void;
  32952. /**
  32953. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32954. */
  32955. static LogLevels: number;
  32956. /**
  32957. * Checks if the window object exists
  32958. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32959. */
  32960. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32961. /**
  32962. * No performance log
  32963. */
  32964. static readonly PerformanceNoneLogLevel: number;
  32965. /**
  32966. * Use user marks to log performance
  32967. */
  32968. static readonly PerformanceUserMarkLogLevel: number;
  32969. /**
  32970. * Log performance to the console
  32971. */
  32972. static readonly PerformanceConsoleLogLevel: number;
  32973. private static _performance;
  32974. /**
  32975. * Sets the current performance log level
  32976. */
  32977. static PerformanceLogLevel: number;
  32978. private static _StartPerformanceCounterDisabled;
  32979. private static _EndPerformanceCounterDisabled;
  32980. private static _StartUserMark;
  32981. private static _EndUserMark;
  32982. private static _StartPerformanceConsole;
  32983. private static _EndPerformanceConsole;
  32984. /**
  32985. * Starts a performance counter
  32986. */
  32987. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32988. /**
  32989. * Ends a specific performance coutner
  32990. */
  32991. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32992. /**
  32993. * Gets either window.performance.now() if supported or Date.now() else
  32994. */
  32995. static readonly Now: number;
  32996. /**
  32997. * This method will return the name of the class used to create the instance of the given object.
  32998. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32999. * @param object the object to get the class name from
  33000. * @param isType defines if the object is actually a type
  33001. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33002. */
  33003. static GetClassName(object: any, isType?: boolean): string;
  33004. /**
  33005. * Gets the first element of an array satisfying a given predicate
  33006. * @param array defines the array to browse
  33007. * @param predicate defines the predicate to use
  33008. * @returns null if not found or the element
  33009. */
  33010. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33011. /**
  33012. * This method will return the name of the full name of the class, including its owning module (if any).
  33013. * 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).
  33014. * @param object the object to get the class name from
  33015. * @param isType defines if the object is actually a type
  33016. * @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.
  33017. * @ignorenaming
  33018. */
  33019. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33020. /**
  33021. * Returns a promise that resolves after the given amount of time.
  33022. * @param delay Number of milliseconds to delay
  33023. * @returns Promise that resolves after the given amount of time
  33024. */
  33025. static DelayAsync(delay: number): Promise<void>;
  33026. }
  33027. /**
  33028. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33029. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33030. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33031. * @param name The name of the class, case should be preserved
  33032. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33033. */
  33034. export function className(name: string, module?: string): (target: Object) => void;
  33035. /**
  33036. * An implementation of a loop for asynchronous functions.
  33037. */
  33038. export class AsyncLoop {
  33039. /**
  33040. * Defines the number of iterations for the loop
  33041. */
  33042. iterations: number;
  33043. /**
  33044. * Defines the current index of the loop.
  33045. */
  33046. index: number;
  33047. private _done;
  33048. private _fn;
  33049. private _successCallback;
  33050. /**
  33051. * Constructor.
  33052. * @param iterations the number of iterations.
  33053. * @param func the function to run each iteration
  33054. * @param successCallback the callback that will be called upon succesful execution
  33055. * @param offset starting offset.
  33056. */
  33057. constructor(
  33058. /**
  33059. * Defines the number of iterations for the loop
  33060. */
  33061. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33062. /**
  33063. * Execute the next iteration. Must be called after the last iteration was finished.
  33064. */
  33065. executeNext(): void;
  33066. /**
  33067. * Break the loop and run the success callback.
  33068. */
  33069. breakLoop(): void;
  33070. /**
  33071. * Create and run an async loop.
  33072. * @param iterations the number of iterations.
  33073. * @param fn the function to run each iteration
  33074. * @param successCallback the callback that will be called upon succesful execution
  33075. * @param offset starting offset.
  33076. * @returns the created async loop object
  33077. */
  33078. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33079. /**
  33080. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33081. * @param iterations total number of iterations
  33082. * @param syncedIterations number of synchronous iterations in each async iteration.
  33083. * @param fn the function to call each iteration.
  33084. * @param callback a success call back that will be called when iterating stops.
  33085. * @param breakFunction a break condition (optional)
  33086. * @param timeout timeout settings for the setTimeout function. default - 0.
  33087. * @returns the created async loop object
  33088. */
  33089. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33090. }
  33091. }
  33092. declare module "babylonjs/Collisions/collisionCoordinator" {
  33093. import { Nullable } from "babylonjs/types";
  33094. import { Scene } from "babylonjs/scene";
  33095. import { Vector3 } from "babylonjs/Maths/math.vector";
  33096. import { Collider } from "babylonjs/Collisions/collider";
  33097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33098. /** @hidden */
  33099. export interface ICollisionCoordinator {
  33100. createCollider(): Collider;
  33101. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33102. init(scene: Scene): void;
  33103. }
  33104. /** @hidden */
  33105. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33106. private _scene;
  33107. private _scaledPosition;
  33108. private _scaledVelocity;
  33109. private _finalPosition;
  33110. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33111. createCollider(): Collider;
  33112. init(scene: Scene): void;
  33113. private _collideWithWorld;
  33114. }
  33115. }
  33116. declare module "babylonjs/Inputs/scene.inputManager" {
  33117. import { Nullable } from "babylonjs/types";
  33118. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33119. import { Vector2 } from "babylonjs/Maths/math.vector";
  33120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33121. import { Scene } from "babylonjs/scene";
  33122. /**
  33123. * Class used to manage all inputs for the scene.
  33124. */
  33125. export class InputManager {
  33126. /** The distance in pixel that you have to move to prevent some events */
  33127. static DragMovementThreshold: number;
  33128. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33129. static LongPressDelay: number;
  33130. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33131. static DoubleClickDelay: number;
  33132. /** If you need to check double click without raising a single click at first click, enable this flag */
  33133. static ExclusiveDoubleClickMode: boolean;
  33134. private _wheelEventName;
  33135. private _onPointerMove;
  33136. private _onPointerDown;
  33137. private _onPointerUp;
  33138. private _initClickEvent;
  33139. private _initActionManager;
  33140. private _delayedSimpleClick;
  33141. private _delayedSimpleClickTimeout;
  33142. private _previousDelayedSimpleClickTimeout;
  33143. private _meshPickProceed;
  33144. private _previousButtonPressed;
  33145. private _currentPickResult;
  33146. private _previousPickResult;
  33147. private _totalPointersPressed;
  33148. private _doubleClickOccured;
  33149. private _pointerOverMesh;
  33150. private _pickedDownMesh;
  33151. private _pickedUpMesh;
  33152. private _pointerX;
  33153. private _pointerY;
  33154. private _unTranslatedPointerX;
  33155. private _unTranslatedPointerY;
  33156. private _startingPointerPosition;
  33157. private _previousStartingPointerPosition;
  33158. private _startingPointerTime;
  33159. private _previousStartingPointerTime;
  33160. private _pointerCaptures;
  33161. private _onKeyDown;
  33162. private _onKeyUp;
  33163. private _onCanvasFocusObserver;
  33164. private _onCanvasBlurObserver;
  33165. private _scene;
  33166. /**
  33167. * Creates a new InputManager
  33168. * @param scene defines the hosting scene
  33169. */
  33170. constructor(scene: Scene);
  33171. /**
  33172. * Gets the mesh that is currently under the pointer
  33173. */
  33174. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33175. /**
  33176. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33177. */
  33178. readonly unTranslatedPointer: Vector2;
  33179. /**
  33180. * Gets or sets the current on-screen X position of the pointer
  33181. */
  33182. pointerX: number;
  33183. /**
  33184. * Gets or sets the current on-screen Y position of the pointer
  33185. */
  33186. pointerY: number;
  33187. private _updatePointerPosition;
  33188. private _processPointerMove;
  33189. private _setRayOnPointerInfo;
  33190. private _checkPrePointerObservable;
  33191. /**
  33192. * Use this method to simulate a pointer move on a mesh
  33193. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33194. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33195. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33196. */
  33197. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33198. /**
  33199. * Use this method to simulate a pointer down on a mesh
  33200. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33201. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33202. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33203. */
  33204. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33205. private _processPointerDown;
  33206. /** @hidden */
  33207. _isPointerSwiping(): boolean;
  33208. /**
  33209. * Use this method to simulate a pointer up on a mesh
  33210. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33211. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33212. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33213. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33214. */
  33215. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33216. private _processPointerUp;
  33217. /**
  33218. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33219. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33220. * @returns true if the pointer was captured
  33221. */
  33222. isPointerCaptured(pointerId?: number): boolean;
  33223. /**
  33224. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33225. * @param attachUp defines if you want to attach events to pointerup
  33226. * @param attachDown defines if you want to attach events to pointerdown
  33227. * @param attachMove defines if you want to attach events to pointermove
  33228. */
  33229. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33230. /**
  33231. * Detaches all event handlers
  33232. */
  33233. detachControl(): void;
  33234. /**
  33235. * Force the value of meshUnderPointer
  33236. * @param mesh defines the mesh to use
  33237. */
  33238. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33239. /**
  33240. * Gets the mesh under the pointer
  33241. * @returns a Mesh or null if no mesh is under the pointer
  33242. */
  33243. getPointerOverMesh(): Nullable<AbstractMesh>;
  33244. }
  33245. }
  33246. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33247. /**
  33248. * Helper class used to generate session unique ID
  33249. */
  33250. export class UniqueIdGenerator {
  33251. private static _UniqueIdCounter;
  33252. /**
  33253. * Gets an unique (relatively to the current scene) Id
  33254. */
  33255. static readonly UniqueId: number;
  33256. }
  33257. }
  33258. declare module "babylonjs/Animations/animationGroup" {
  33259. import { Animatable } from "babylonjs/Animations/animatable";
  33260. import { Animation } from "babylonjs/Animations/animation";
  33261. import { Scene, IDisposable } from "babylonjs/scene";
  33262. import { Observable } from "babylonjs/Misc/observable";
  33263. import { Nullable } from "babylonjs/types";
  33264. import "babylonjs/Animations/animatable";
  33265. /**
  33266. * This class defines the direct association between an animation and a target
  33267. */
  33268. export class TargetedAnimation {
  33269. /**
  33270. * Animation to perform
  33271. */
  33272. animation: Animation;
  33273. /**
  33274. * Target to animate
  33275. */
  33276. target: any;
  33277. /**
  33278. * Serialize the object
  33279. * @returns the JSON object representing the current entity
  33280. */
  33281. serialize(): any;
  33282. }
  33283. /**
  33284. * Use this class to create coordinated animations on multiple targets
  33285. */
  33286. export class AnimationGroup implements IDisposable {
  33287. /** The name of the animation group */
  33288. name: string;
  33289. private _scene;
  33290. private _targetedAnimations;
  33291. private _animatables;
  33292. private _from;
  33293. private _to;
  33294. private _isStarted;
  33295. private _isPaused;
  33296. private _speedRatio;
  33297. private _loopAnimation;
  33298. /**
  33299. * Gets or sets the unique id of the node
  33300. */
  33301. uniqueId: number;
  33302. /**
  33303. * This observable will notify when one animation have ended
  33304. */
  33305. onAnimationEndObservable: Observable<TargetedAnimation>;
  33306. /**
  33307. * Observer raised when one animation loops
  33308. */
  33309. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33310. /**
  33311. * This observable will notify when all animations have ended.
  33312. */
  33313. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33314. /**
  33315. * This observable will notify when all animations have paused.
  33316. */
  33317. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33318. /**
  33319. * This observable will notify when all animations are playing.
  33320. */
  33321. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33322. /**
  33323. * Gets the first frame
  33324. */
  33325. readonly from: number;
  33326. /**
  33327. * Gets the last frame
  33328. */
  33329. readonly to: number;
  33330. /**
  33331. * Define if the animations are started
  33332. */
  33333. readonly isStarted: boolean;
  33334. /**
  33335. * Gets a value indicating that the current group is playing
  33336. */
  33337. readonly isPlaying: boolean;
  33338. /**
  33339. * Gets or sets the speed ratio to use for all animations
  33340. */
  33341. /**
  33342. * Gets or sets the speed ratio to use for all animations
  33343. */
  33344. speedRatio: number;
  33345. /**
  33346. * Gets or sets if all animations should loop or not
  33347. */
  33348. loopAnimation: boolean;
  33349. /**
  33350. * Gets the targeted animations for this animation group
  33351. */
  33352. readonly targetedAnimations: Array<TargetedAnimation>;
  33353. /**
  33354. * returning the list of animatables controlled by this animation group.
  33355. */
  33356. readonly animatables: Array<Animatable>;
  33357. /**
  33358. * Instantiates a new Animation Group.
  33359. * This helps managing several animations at once.
  33360. * @see http://doc.babylonjs.com/how_to/group
  33361. * @param name Defines the name of the group
  33362. * @param scene Defines the scene the group belongs to
  33363. */
  33364. constructor(
  33365. /** The name of the animation group */
  33366. name: string, scene?: Nullable<Scene>);
  33367. /**
  33368. * Add an animation (with its target) in the group
  33369. * @param animation defines the animation we want to add
  33370. * @param target defines the target of the animation
  33371. * @returns the TargetedAnimation object
  33372. */
  33373. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33374. /**
  33375. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33376. * It can add constant keys at begin or end
  33377. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33378. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33379. * @returns the animation group
  33380. */
  33381. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33382. /**
  33383. * Start all animations on given targets
  33384. * @param loop defines if animations must loop
  33385. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33386. * @param from defines the from key (optional)
  33387. * @param to defines the to key (optional)
  33388. * @returns the current animation group
  33389. */
  33390. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33391. /**
  33392. * Pause all animations
  33393. * @returns the animation group
  33394. */
  33395. pause(): AnimationGroup;
  33396. /**
  33397. * Play all animations to initial state
  33398. * This function will start() the animations if they were not started or will restart() them if they were paused
  33399. * @param loop defines if animations must loop
  33400. * @returns the animation group
  33401. */
  33402. play(loop?: boolean): AnimationGroup;
  33403. /**
  33404. * Reset all animations to initial state
  33405. * @returns the animation group
  33406. */
  33407. reset(): AnimationGroup;
  33408. /**
  33409. * Restart animations from key 0
  33410. * @returns the animation group
  33411. */
  33412. restart(): AnimationGroup;
  33413. /**
  33414. * Stop all animations
  33415. * @returns the animation group
  33416. */
  33417. stop(): AnimationGroup;
  33418. /**
  33419. * Set animation weight for all animatables
  33420. * @param weight defines the weight to use
  33421. * @return the animationGroup
  33422. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33423. */
  33424. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33425. /**
  33426. * Synchronize and normalize all animatables with a source animatable
  33427. * @param root defines the root animatable to synchronize with
  33428. * @return the animationGroup
  33429. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33430. */
  33431. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33432. /**
  33433. * Goes to a specific frame in this animation group
  33434. * @param frame the frame number to go to
  33435. * @return the animationGroup
  33436. */
  33437. goToFrame(frame: number): AnimationGroup;
  33438. /**
  33439. * Dispose all associated resources
  33440. */
  33441. dispose(): void;
  33442. private _checkAnimationGroupEnded;
  33443. /**
  33444. * Clone the current animation group and returns a copy
  33445. * @param newName defines the name of the new group
  33446. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33447. * @returns the new aniamtion group
  33448. */
  33449. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33450. /**
  33451. * Serializes the animationGroup to an object
  33452. * @returns Serialized object
  33453. */
  33454. serialize(): any;
  33455. /**
  33456. * Returns a new AnimationGroup object parsed from the source provided.
  33457. * @param parsedAnimationGroup defines the source
  33458. * @param scene defines the scene that will receive the animationGroup
  33459. * @returns a new AnimationGroup
  33460. */
  33461. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33462. /**
  33463. * Returns the string "AnimationGroup"
  33464. * @returns "AnimationGroup"
  33465. */
  33466. getClassName(): string;
  33467. /**
  33468. * Creates a detailled string about the object
  33469. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33470. * @returns a string representing the object
  33471. */
  33472. toString(fullDetails?: boolean): string;
  33473. }
  33474. }
  33475. declare module "babylonjs/scene" {
  33476. import { Nullable } from "babylonjs/types";
  33477. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33478. import { Observable } from "babylonjs/Misc/observable";
  33479. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33480. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33481. import { Geometry } from "babylonjs/Meshes/geometry";
  33482. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33483. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33485. import { Mesh } from "babylonjs/Meshes/mesh";
  33486. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33487. import { Bone } from "babylonjs/Bones/bone";
  33488. import { Skeleton } from "babylonjs/Bones/skeleton";
  33489. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33490. import { Camera } from "babylonjs/Cameras/camera";
  33491. import { AbstractScene } from "babylonjs/abstractScene";
  33492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33493. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33494. import { Material } from "babylonjs/Materials/material";
  33495. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33496. import { Effect } from "babylonjs/Materials/effect";
  33497. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33498. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33499. import { Light } from "babylonjs/Lights/light";
  33500. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33501. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33502. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33503. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33504. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33505. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33506. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33507. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33508. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33509. import { Engine } from "babylonjs/Engines/engine";
  33510. import { Node } from "babylonjs/node";
  33511. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33512. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33513. import { WebRequest } from "babylonjs/Misc/webRequest";
  33514. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33515. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33516. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33517. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33518. import { Plane } from "babylonjs/Maths/math.plane";
  33519. import { Ray } from "babylonjs/Culling/ray";
  33520. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33521. import { Animation } from "babylonjs/Animations/animation";
  33522. import { Animatable } from "babylonjs/Animations/animatable";
  33523. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33524. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33525. import { Collider } from "babylonjs/Collisions/collider";
  33526. /**
  33527. * Define an interface for all classes that will hold resources
  33528. */
  33529. export interface IDisposable {
  33530. /**
  33531. * Releases all held resources
  33532. */
  33533. dispose(): void;
  33534. }
  33535. /** Interface defining initialization parameters for Scene class */
  33536. export interface SceneOptions {
  33537. /**
  33538. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33539. * It will improve performance when the number of geometries becomes important.
  33540. */
  33541. useGeometryUniqueIdsMap?: boolean;
  33542. /**
  33543. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33544. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33545. */
  33546. useMaterialMeshMap?: boolean;
  33547. /**
  33548. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33549. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33550. */
  33551. useClonedMeshhMap?: boolean;
  33552. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33553. virtual?: boolean;
  33554. }
  33555. /**
  33556. * Represents a scene to be rendered by the engine.
  33557. * @see http://doc.babylonjs.com/features/scene
  33558. */
  33559. export class Scene extends AbstractScene implements IAnimatable {
  33560. /** The fog is deactivated */
  33561. static readonly FOGMODE_NONE: number;
  33562. /** The fog density is following an exponential function */
  33563. static readonly FOGMODE_EXP: number;
  33564. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33565. static readonly FOGMODE_EXP2: number;
  33566. /** The fog density is following a linear function. */
  33567. static readonly FOGMODE_LINEAR: number;
  33568. /**
  33569. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33570. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33571. */
  33572. static MinDeltaTime: number;
  33573. /**
  33574. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33575. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33576. */
  33577. static MaxDeltaTime: number;
  33578. /**
  33579. * Factory used to create the default material.
  33580. * @param name The name of the material to create
  33581. * @param scene The scene to create the material for
  33582. * @returns The default material
  33583. */
  33584. static DefaultMaterialFactory(scene: Scene): Material;
  33585. /**
  33586. * Factory used to create the a collision coordinator.
  33587. * @returns The collision coordinator
  33588. */
  33589. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33590. /** @hidden */
  33591. _inputManager: InputManager;
  33592. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33593. cameraToUseForPointers: Nullable<Camera>;
  33594. /** @hidden */
  33595. readonly _isScene: boolean;
  33596. /**
  33597. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33598. */
  33599. autoClear: boolean;
  33600. /**
  33601. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33602. */
  33603. autoClearDepthAndStencil: boolean;
  33604. /**
  33605. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33606. */
  33607. clearColor: Color4;
  33608. /**
  33609. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33610. */
  33611. ambientColor: Color3;
  33612. /**
  33613. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33614. * It should only be one of the following (if not the default embedded one):
  33615. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33616. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33617. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33618. * The material properties need to be setup according to the type of texture in use.
  33619. */
  33620. environmentBRDFTexture: BaseTexture;
  33621. /** @hidden */
  33622. protected _environmentTexture: Nullable<BaseTexture>;
  33623. /**
  33624. * Texture used in all pbr material as the reflection texture.
  33625. * As in the majority of the scene they are the same (exception for multi room and so on),
  33626. * this is easier to reference from here than from all the materials.
  33627. */
  33628. /**
  33629. * Texture used in all pbr material as the reflection texture.
  33630. * As in the majority of the scene they are the same (exception for multi room and so on),
  33631. * this is easier to set here than in all the materials.
  33632. */
  33633. environmentTexture: Nullable<BaseTexture>;
  33634. /** @hidden */
  33635. protected _environmentIntensity: number;
  33636. /**
  33637. * Intensity of the environment in all pbr material.
  33638. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33639. * As in the majority of the scene they are the same (exception for multi room and so on),
  33640. * this is easier to reference from here than from all the materials.
  33641. */
  33642. /**
  33643. * Intensity of the environment in all pbr material.
  33644. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33645. * As in the majority of the scene they are the same (exception for multi room and so on),
  33646. * this is easier to set here than in all the materials.
  33647. */
  33648. environmentIntensity: number;
  33649. /** @hidden */
  33650. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33651. /**
  33652. * Default image processing configuration used either in the rendering
  33653. * Forward main pass or through the imageProcessingPostProcess if present.
  33654. * As in the majority of the scene they are the same (exception for multi camera),
  33655. * this is easier to reference from here than from all the materials and post process.
  33656. *
  33657. * No setter as we it is a shared configuration, you can set the values instead.
  33658. */
  33659. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33660. private _forceWireframe;
  33661. /**
  33662. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33663. */
  33664. forceWireframe: boolean;
  33665. private _forcePointsCloud;
  33666. /**
  33667. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33668. */
  33669. forcePointsCloud: boolean;
  33670. /**
  33671. * Gets or sets the active clipplane 1
  33672. */
  33673. clipPlane: Nullable<Plane>;
  33674. /**
  33675. * Gets or sets the active clipplane 2
  33676. */
  33677. clipPlane2: Nullable<Plane>;
  33678. /**
  33679. * Gets or sets the active clipplane 3
  33680. */
  33681. clipPlane3: Nullable<Plane>;
  33682. /**
  33683. * Gets or sets the active clipplane 4
  33684. */
  33685. clipPlane4: Nullable<Plane>;
  33686. /**
  33687. * Gets or sets a boolean indicating if animations are enabled
  33688. */
  33689. animationsEnabled: boolean;
  33690. private _animationPropertiesOverride;
  33691. /**
  33692. * Gets or sets the animation properties override
  33693. */
  33694. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33695. /**
  33696. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33697. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33698. */
  33699. useConstantAnimationDeltaTime: boolean;
  33700. /**
  33701. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33702. * Please note that it requires to run a ray cast through the scene on every frame
  33703. */
  33704. constantlyUpdateMeshUnderPointer: boolean;
  33705. /**
  33706. * Defines the HTML cursor to use when hovering over interactive elements
  33707. */
  33708. hoverCursor: string;
  33709. /**
  33710. * Defines the HTML default cursor to use (empty by default)
  33711. */
  33712. defaultCursor: string;
  33713. /**
  33714. * This is used to call preventDefault() on pointer down
  33715. * in order to block unwanted artifacts like system double clicks
  33716. */
  33717. preventDefaultOnPointerDown: boolean;
  33718. /**
  33719. * This is used to call preventDefault() on pointer up
  33720. * in order to block unwanted artifacts like system double clicks
  33721. */
  33722. preventDefaultOnPointerUp: boolean;
  33723. /**
  33724. * Gets or sets user defined metadata
  33725. */
  33726. metadata: any;
  33727. /**
  33728. * For internal use only. Please do not use.
  33729. */
  33730. reservedDataStore: any;
  33731. /**
  33732. * Gets the name of the plugin used to load this scene (null by default)
  33733. */
  33734. loadingPluginName: string;
  33735. /**
  33736. * Use this array to add regular expressions used to disable offline support for specific urls
  33737. */
  33738. disableOfflineSupportExceptionRules: RegExp[];
  33739. /**
  33740. * An event triggered when the scene is disposed.
  33741. */
  33742. onDisposeObservable: Observable<Scene>;
  33743. private _onDisposeObserver;
  33744. /** Sets a function to be executed when this scene is disposed. */
  33745. onDispose: () => void;
  33746. /**
  33747. * An event triggered before rendering the scene (right after animations and physics)
  33748. */
  33749. onBeforeRenderObservable: Observable<Scene>;
  33750. private _onBeforeRenderObserver;
  33751. /** Sets a function to be executed before rendering this scene */
  33752. beforeRender: Nullable<() => void>;
  33753. /**
  33754. * An event triggered after rendering the scene
  33755. */
  33756. onAfterRenderObservable: Observable<Scene>;
  33757. /**
  33758. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33759. */
  33760. onAfterRenderCameraObservable: Observable<Camera>;
  33761. private _onAfterRenderObserver;
  33762. /** Sets a function to be executed after rendering this scene */
  33763. afterRender: Nullable<() => void>;
  33764. /**
  33765. * An event triggered before animating the scene
  33766. */
  33767. onBeforeAnimationsObservable: Observable<Scene>;
  33768. /**
  33769. * An event triggered after animations processing
  33770. */
  33771. onAfterAnimationsObservable: Observable<Scene>;
  33772. /**
  33773. * An event triggered before draw calls are ready to be sent
  33774. */
  33775. onBeforeDrawPhaseObservable: Observable<Scene>;
  33776. /**
  33777. * An event triggered after draw calls have been sent
  33778. */
  33779. onAfterDrawPhaseObservable: Observable<Scene>;
  33780. /**
  33781. * An event triggered when the scene is ready
  33782. */
  33783. onReadyObservable: Observable<Scene>;
  33784. /**
  33785. * An event triggered before rendering a camera
  33786. */
  33787. onBeforeCameraRenderObservable: Observable<Camera>;
  33788. private _onBeforeCameraRenderObserver;
  33789. /** Sets a function to be executed before rendering a camera*/
  33790. beforeCameraRender: () => void;
  33791. /**
  33792. * An event triggered after rendering a camera
  33793. */
  33794. onAfterCameraRenderObservable: Observable<Camera>;
  33795. private _onAfterCameraRenderObserver;
  33796. /** Sets a function to be executed after rendering a camera*/
  33797. afterCameraRender: () => void;
  33798. /**
  33799. * An event triggered when active meshes evaluation is about to start
  33800. */
  33801. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33802. /**
  33803. * An event triggered when active meshes evaluation is done
  33804. */
  33805. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33806. /**
  33807. * An event triggered when particles rendering is about to start
  33808. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33809. */
  33810. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33811. /**
  33812. * An event triggered when particles rendering is done
  33813. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33814. */
  33815. onAfterParticlesRenderingObservable: Observable<Scene>;
  33816. /**
  33817. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33818. */
  33819. onDataLoadedObservable: Observable<Scene>;
  33820. /**
  33821. * An event triggered when a camera is created
  33822. */
  33823. onNewCameraAddedObservable: Observable<Camera>;
  33824. /**
  33825. * An event triggered when a camera is removed
  33826. */
  33827. onCameraRemovedObservable: Observable<Camera>;
  33828. /**
  33829. * An event triggered when a light is created
  33830. */
  33831. onNewLightAddedObservable: Observable<Light>;
  33832. /**
  33833. * An event triggered when a light is removed
  33834. */
  33835. onLightRemovedObservable: Observable<Light>;
  33836. /**
  33837. * An event triggered when a geometry is created
  33838. */
  33839. onNewGeometryAddedObservable: Observable<Geometry>;
  33840. /**
  33841. * An event triggered when a geometry is removed
  33842. */
  33843. onGeometryRemovedObservable: Observable<Geometry>;
  33844. /**
  33845. * An event triggered when a transform node is created
  33846. */
  33847. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33848. /**
  33849. * An event triggered when a transform node is removed
  33850. */
  33851. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33852. /**
  33853. * An event triggered when a mesh is created
  33854. */
  33855. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33856. /**
  33857. * An event triggered when a mesh is removed
  33858. */
  33859. onMeshRemovedObservable: Observable<AbstractMesh>;
  33860. /**
  33861. * An event triggered when a skeleton is created
  33862. */
  33863. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33864. /**
  33865. * An event triggered when a skeleton is removed
  33866. */
  33867. onSkeletonRemovedObservable: Observable<Skeleton>;
  33868. /**
  33869. * An event triggered when a material is created
  33870. */
  33871. onNewMaterialAddedObservable: Observable<Material>;
  33872. /**
  33873. * An event triggered when a material is removed
  33874. */
  33875. onMaterialRemovedObservable: Observable<Material>;
  33876. /**
  33877. * An event triggered when a texture is created
  33878. */
  33879. onNewTextureAddedObservable: Observable<BaseTexture>;
  33880. /**
  33881. * An event triggered when a texture is removed
  33882. */
  33883. onTextureRemovedObservable: Observable<BaseTexture>;
  33884. /**
  33885. * An event triggered when render targets are about to be rendered
  33886. * Can happen multiple times per frame.
  33887. */
  33888. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33889. /**
  33890. * An event triggered when render targets were rendered.
  33891. * Can happen multiple times per frame.
  33892. */
  33893. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33894. /**
  33895. * An event triggered before calculating deterministic simulation step
  33896. */
  33897. onBeforeStepObservable: Observable<Scene>;
  33898. /**
  33899. * An event triggered after calculating deterministic simulation step
  33900. */
  33901. onAfterStepObservable: Observable<Scene>;
  33902. /**
  33903. * An event triggered when the activeCamera property is updated
  33904. */
  33905. onActiveCameraChanged: Observable<Scene>;
  33906. /**
  33907. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33908. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33909. * 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)
  33910. */
  33911. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33912. /**
  33913. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33914. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33915. * 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)
  33916. */
  33917. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33918. /**
  33919. * This Observable will when a mesh has been imported into the scene.
  33920. */
  33921. onMeshImportedObservable: Observable<AbstractMesh>;
  33922. /**
  33923. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33924. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33925. */
  33926. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33927. /** @hidden */
  33928. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33929. /**
  33930. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33931. */
  33932. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33933. /**
  33934. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33935. */
  33936. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33937. /**
  33938. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33939. */
  33940. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33941. /** Callback called when a pointer move is detected */
  33942. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33943. /** Callback called when a pointer down is detected */
  33944. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33945. /** Callback called when a pointer up is detected */
  33946. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33947. /** Callback called when a pointer pick is detected */
  33948. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33949. /**
  33950. * 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).
  33951. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33952. */
  33953. onPrePointerObservable: Observable<PointerInfoPre>;
  33954. /**
  33955. * Observable event triggered each time an input event is received from the rendering canvas
  33956. */
  33957. onPointerObservable: Observable<PointerInfo>;
  33958. /**
  33959. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33960. */
  33961. readonly unTranslatedPointer: Vector2;
  33962. /**
  33963. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33964. */
  33965. static DragMovementThreshold: number;
  33966. /**
  33967. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33968. */
  33969. static LongPressDelay: number;
  33970. /**
  33971. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33972. */
  33973. static DoubleClickDelay: number;
  33974. /** If you need to check double click without raising a single click at first click, enable this flag */
  33975. static ExclusiveDoubleClickMode: boolean;
  33976. /** @hidden */
  33977. _mirroredCameraPosition: Nullable<Vector3>;
  33978. /**
  33979. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33980. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33981. */
  33982. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33983. /**
  33984. * Observable event triggered each time an keyboard event is received from the hosting window
  33985. */
  33986. onKeyboardObservable: Observable<KeyboardInfo>;
  33987. private _useRightHandedSystem;
  33988. /**
  33989. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33990. */
  33991. useRightHandedSystem: boolean;
  33992. private _timeAccumulator;
  33993. private _currentStepId;
  33994. private _currentInternalStep;
  33995. /**
  33996. * Sets the step Id used by deterministic lock step
  33997. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33998. * @param newStepId defines the step Id
  33999. */
  34000. setStepId(newStepId: number): void;
  34001. /**
  34002. * Gets the step Id used by deterministic lock step
  34003. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34004. * @returns the step Id
  34005. */
  34006. getStepId(): number;
  34007. /**
  34008. * Gets the internal step used by deterministic lock step
  34009. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34010. * @returns the internal step
  34011. */
  34012. getInternalStep(): number;
  34013. private _fogEnabled;
  34014. /**
  34015. * Gets or sets a boolean indicating if fog is enabled on this scene
  34016. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34017. * (Default is true)
  34018. */
  34019. fogEnabled: boolean;
  34020. private _fogMode;
  34021. /**
  34022. * Gets or sets the fog mode to use
  34023. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34024. * | mode | value |
  34025. * | --- | --- |
  34026. * | FOGMODE_NONE | 0 |
  34027. * | FOGMODE_EXP | 1 |
  34028. * | FOGMODE_EXP2 | 2 |
  34029. * | FOGMODE_LINEAR | 3 |
  34030. */
  34031. fogMode: number;
  34032. /**
  34033. * Gets or sets the fog color to use
  34034. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34035. * (Default is Color3(0.2, 0.2, 0.3))
  34036. */
  34037. fogColor: Color3;
  34038. /**
  34039. * Gets or sets the fog density to use
  34040. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34041. * (Default is 0.1)
  34042. */
  34043. fogDensity: number;
  34044. /**
  34045. * Gets or sets the fog start distance to use
  34046. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34047. * (Default is 0)
  34048. */
  34049. fogStart: number;
  34050. /**
  34051. * Gets or sets the fog end distance to use
  34052. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34053. * (Default is 1000)
  34054. */
  34055. fogEnd: number;
  34056. private _shadowsEnabled;
  34057. /**
  34058. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34059. */
  34060. shadowsEnabled: boolean;
  34061. private _lightsEnabled;
  34062. /**
  34063. * Gets or sets a boolean indicating if lights are enabled on this scene
  34064. */
  34065. lightsEnabled: boolean;
  34066. /** All of the active cameras added to this scene. */
  34067. activeCameras: Camera[];
  34068. /** @hidden */
  34069. _activeCamera: Nullable<Camera>;
  34070. /** Gets or sets the current active camera */
  34071. activeCamera: Nullable<Camera>;
  34072. private _defaultMaterial;
  34073. /** The default material used on meshes when no material is affected */
  34074. /** The default material used on meshes when no material is affected */
  34075. defaultMaterial: Material;
  34076. private _texturesEnabled;
  34077. /**
  34078. * Gets or sets a boolean indicating if textures are enabled on this scene
  34079. */
  34080. texturesEnabled: boolean;
  34081. /**
  34082. * Gets or sets a boolean indicating if particles are enabled on this scene
  34083. */
  34084. particlesEnabled: boolean;
  34085. /**
  34086. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34087. */
  34088. spritesEnabled: boolean;
  34089. private _skeletonsEnabled;
  34090. /**
  34091. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34092. */
  34093. skeletonsEnabled: boolean;
  34094. /**
  34095. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34096. */
  34097. lensFlaresEnabled: boolean;
  34098. /**
  34099. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34100. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34101. */
  34102. collisionsEnabled: boolean;
  34103. private _collisionCoordinator;
  34104. /** @hidden */
  34105. readonly collisionCoordinator: ICollisionCoordinator;
  34106. /**
  34107. * Defines the gravity applied to this scene (used only for collisions)
  34108. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34109. */
  34110. gravity: Vector3;
  34111. /**
  34112. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34113. */
  34114. postProcessesEnabled: boolean;
  34115. /**
  34116. * The list of postprocesses added to the scene
  34117. */
  34118. postProcesses: PostProcess[];
  34119. /**
  34120. * Gets the current postprocess manager
  34121. */
  34122. postProcessManager: PostProcessManager;
  34123. /**
  34124. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34125. */
  34126. renderTargetsEnabled: boolean;
  34127. /**
  34128. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34129. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34130. */
  34131. dumpNextRenderTargets: boolean;
  34132. /**
  34133. * The list of user defined render targets added to the scene
  34134. */
  34135. customRenderTargets: RenderTargetTexture[];
  34136. /**
  34137. * Defines if texture loading must be delayed
  34138. * If true, textures will only be loaded when they need to be rendered
  34139. */
  34140. useDelayedTextureLoading: boolean;
  34141. /**
  34142. * Gets the list of meshes imported to the scene through SceneLoader
  34143. */
  34144. importedMeshesFiles: String[];
  34145. /**
  34146. * Gets or sets a boolean indicating if probes are enabled on this scene
  34147. */
  34148. probesEnabled: boolean;
  34149. /**
  34150. * Gets or sets the current offline provider to use to store scene data
  34151. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34152. */
  34153. offlineProvider: IOfflineProvider;
  34154. /**
  34155. * Gets or sets the action manager associated with the scene
  34156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34157. */
  34158. actionManager: AbstractActionManager;
  34159. private _meshesForIntersections;
  34160. /**
  34161. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34162. */
  34163. proceduralTexturesEnabled: boolean;
  34164. private _engine;
  34165. private _totalVertices;
  34166. /** @hidden */
  34167. _activeIndices: PerfCounter;
  34168. /** @hidden */
  34169. _activeParticles: PerfCounter;
  34170. /** @hidden */
  34171. _activeBones: PerfCounter;
  34172. private _animationRatio;
  34173. /** @hidden */
  34174. _animationTimeLast: number;
  34175. /** @hidden */
  34176. _animationTime: number;
  34177. /**
  34178. * Gets or sets a general scale for animation speed
  34179. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34180. */
  34181. animationTimeScale: number;
  34182. /** @hidden */
  34183. _cachedMaterial: Nullable<Material>;
  34184. /** @hidden */
  34185. _cachedEffect: Nullable<Effect>;
  34186. /** @hidden */
  34187. _cachedVisibility: Nullable<number>;
  34188. private _renderId;
  34189. private _frameId;
  34190. private _executeWhenReadyTimeoutId;
  34191. private _intermediateRendering;
  34192. private _viewUpdateFlag;
  34193. private _projectionUpdateFlag;
  34194. /** @hidden */
  34195. _toBeDisposed: Nullable<IDisposable>[];
  34196. private _activeRequests;
  34197. /** @hidden */
  34198. _pendingData: any[];
  34199. private _isDisposed;
  34200. /**
  34201. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34202. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34203. */
  34204. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34205. private _activeMeshes;
  34206. private _processedMaterials;
  34207. private _renderTargets;
  34208. /** @hidden */
  34209. _activeParticleSystems: SmartArray<IParticleSystem>;
  34210. private _activeSkeletons;
  34211. private _softwareSkinnedMeshes;
  34212. private _renderingManager;
  34213. /** @hidden */
  34214. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34215. private _transformMatrix;
  34216. private _sceneUbo;
  34217. /** @hidden */
  34218. _viewMatrix: Matrix;
  34219. private _projectionMatrix;
  34220. /** @hidden */
  34221. _forcedViewPosition: Nullable<Vector3>;
  34222. /** @hidden */
  34223. _frustumPlanes: Plane[];
  34224. /**
  34225. * Gets the list of frustum planes (built from the active camera)
  34226. */
  34227. readonly frustumPlanes: Plane[];
  34228. /**
  34229. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34230. * This is useful if there are more lights that the maximum simulteanous authorized
  34231. */
  34232. requireLightSorting: boolean;
  34233. /** @hidden */
  34234. readonly useMaterialMeshMap: boolean;
  34235. /** @hidden */
  34236. readonly useClonedMeshhMap: boolean;
  34237. private _externalData;
  34238. private _uid;
  34239. /**
  34240. * @hidden
  34241. * Backing store of defined scene components.
  34242. */
  34243. _components: ISceneComponent[];
  34244. /**
  34245. * @hidden
  34246. * Backing store of defined scene components.
  34247. */
  34248. _serializableComponents: ISceneSerializableComponent[];
  34249. /**
  34250. * List of components to register on the next registration step.
  34251. */
  34252. private _transientComponents;
  34253. /**
  34254. * Registers the transient components if needed.
  34255. */
  34256. private _registerTransientComponents;
  34257. /**
  34258. * @hidden
  34259. * Add a component to the scene.
  34260. * Note that the ccomponent could be registered on th next frame if this is called after
  34261. * the register component stage.
  34262. * @param component Defines the component to add to the scene
  34263. */
  34264. _addComponent(component: ISceneComponent): void;
  34265. /**
  34266. * @hidden
  34267. * Gets a component from the scene.
  34268. * @param name defines the name of the component to retrieve
  34269. * @returns the component or null if not present
  34270. */
  34271. _getComponent(name: string): Nullable<ISceneComponent>;
  34272. /**
  34273. * @hidden
  34274. * Defines the actions happening before camera updates.
  34275. */
  34276. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34277. /**
  34278. * @hidden
  34279. * Defines the actions happening before clear the canvas.
  34280. */
  34281. _beforeClearStage: Stage<SimpleStageAction>;
  34282. /**
  34283. * @hidden
  34284. * Defines the actions when collecting render targets for the frame.
  34285. */
  34286. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34287. /**
  34288. * @hidden
  34289. * Defines the actions happening for one camera in the frame.
  34290. */
  34291. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34292. /**
  34293. * @hidden
  34294. * Defines the actions happening during the per mesh ready checks.
  34295. */
  34296. _isReadyForMeshStage: Stage<MeshStageAction>;
  34297. /**
  34298. * @hidden
  34299. * Defines the actions happening before evaluate active mesh checks.
  34300. */
  34301. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34302. /**
  34303. * @hidden
  34304. * Defines the actions happening during the evaluate sub mesh checks.
  34305. */
  34306. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34307. /**
  34308. * @hidden
  34309. * Defines the actions happening during the active mesh stage.
  34310. */
  34311. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34312. /**
  34313. * @hidden
  34314. * Defines the actions happening during the per camera render target step.
  34315. */
  34316. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34317. /**
  34318. * @hidden
  34319. * Defines the actions happening just before the active camera is drawing.
  34320. */
  34321. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34322. /**
  34323. * @hidden
  34324. * Defines the actions happening just before a render target is drawing.
  34325. */
  34326. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34327. /**
  34328. * @hidden
  34329. * Defines the actions happening just before a rendering group is drawing.
  34330. */
  34331. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34332. /**
  34333. * @hidden
  34334. * Defines the actions happening just before a mesh is drawing.
  34335. */
  34336. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34337. /**
  34338. * @hidden
  34339. * Defines the actions happening just after a mesh has been drawn.
  34340. */
  34341. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34342. /**
  34343. * @hidden
  34344. * Defines the actions happening just after a rendering group has been drawn.
  34345. */
  34346. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34347. /**
  34348. * @hidden
  34349. * Defines the actions happening just after the active camera has been drawn.
  34350. */
  34351. _afterCameraDrawStage: Stage<CameraStageAction>;
  34352. /**
  34353. * @hidden
  34354. * Defines the actions happening just after a render target has been drawn.
  34355. */
  34356. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34357. /**
  34358. * @hidden
  34359. * Defines the actions happening just after rendering all cameras and computing intersections.
  34360. */
  34361. _afterRenderStage: Stage<SimpleStageAction>;
  34362. /**
  34363. * @hidden
  34364. * Defines the actions happening when a pointer move event happens.
  34365. */
  34366. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34367. /**
  34368. * @hidden
  34369. * Defines the actions happening when a pointer down event happens.
  34370. */
  34371. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34372. /**
  34373. * @hidden
  34374. * Defines the actions happening when a pointer up event happens.
  34375. */
  34376. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34377. /**
  34378. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34379. */
  34380. private geometriesByUniqueId;
  34381. /**
  34382. * Creates a new Scene
  34383. * @param engine defines the engine to use to render this scene
  34384. * @param options defines the scene options
  34385. */
  34386. constructor(engine: Engine, options?: SceneOptions);
  34387. /**
  34388. * Gets a string idenfifying the name of the class
  34389. * @returns "Scene" string
  34390. */
  34391. getClassName(): string;
  34392. private _defaultMeshCandidates;
  34393. /**
  34394. * @hidden
  34395. */
  34396. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34397. private _defaultSubMeshCandidates;
  34398. /**
  34399. * @hidden
  34400. */
  34401. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34402. /**
  34403. * Sets the default candidate providers for the scene.
  34404. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34405. * and getCollidingSubMeshCandidates to their default function
  34406. */
  34407. setDefaultCandidateProviders(): void;
  34408. /**
  34409. * Gets the mesh that is currently under the pointer
  34410. */
  34411. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34412. /**
  34413. * Gets or sets the current on-screen X position of the pointer
  34414. */
  34415. pointerX: number;
  34416. /**
  34417. * Gets or sets the current on-screen Y position of the pointer
  34418. */
  34419. pointerY: number;
  34420. /**
  34421. * Gets the cached material (ie. the latest rendered one)
  34422. * @returns the cached material
  34423. */
  34424. getCachedMaterial(): Nullable<Material>;
  34425. /**
  34426. * Gets the cached effect (ie. the latest rendered one)
  34427. * @returns the cached effect
  34428. */
  34429. getCachedEffect(): Nullable<Effect>;
  34430. /**
  34431. * Gets the cached visibility state (ie. the latest rendered one)
  34432. * @returns the cached visibility state
  34433. */
  34434. getCachedVisibility(): Nullable<number>;
  34435. /**
  34436. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34437. * @param material defines the current material
  34438. * @param effect defines the current effect
  34439. * @param visibility defines the current visibility state
  34440. * @returns true if one parameter is not cached
  34441. */
  34442. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34443. /**
  34444. * Gets the engine associated with the scene
  34445. * @returns an Engine
  34446. */
  34447. getEngine(): Engine;
  34448. /**
  34449. * Gets the total number of vertices rendered per frame
  34450. * @returns the total number of vertices rendered per frame
  34451. */
  34452. getTotalVertices(): number;
  34453. /**
  34454. * Gets the performance counter for total vertices
  34455. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34456. */
  34457. readonly totalVerticesPerfCounter: PerfCounter;
  34458. /**
  34459. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34460. * @returns the total number of active indices rendered per frame
  34461. */
  34462. getActiveIndices(): number;
  34463. /**
  34464. * Gets the performance counter for active indices
  34465. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34466. */
  34467. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34468. /**
  34469. * Gets the total number of active particles rendered per frame
  34470. * @returns the total number of active particles rendered per frame
  34471. */
  34472. getActiveParticles(): number;
  34473. /**
  34474. * Gets the performance counter for active particles
  34475. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34476. */
  34477. readonly activeParticlesPerfCounter: PerfCounter;
  34478. /**
  34479. * Gets the total number of active bones rendered per frame
  34480. * @returns the total number of active bones rendered per frame
  34481. */
  34482. getActiveBones(): number;
  34483. /**
  34484. * Gets the performance counter for active bones
  34485. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34486. */
  34487. readonly activeBonesPerfCounter: PerfCounter;
  34488. /**
  34489. * Gets the array of active meshes
  34490. * @returns an array of AbstractMesh
  34491. */
  34492. getActiveMeshes(): SmartArray<AbstractMesh>;
  34493. /**
  34494. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34495. * @returns a number
  34496. */
  34497. getAnimationRatio(): number;
  34498. /**
  34499. * Gets an unique Id for the current render phase
  34500. * @returns a number
  34501. */
  34502. getRenderId(): number;
  34503. /**
  34504. * Gets an unique Id for the current frame
  34505. * @returns a number
  34506. */
  34507. getFrameId(): number;
  34508. /** Call this function if you want to manually increment the render Id*/
  34509. incrementRenderId(): void;
  34510. private _createUbo;
  34511. /**
  34512. * Use this method to simulate a pointer move on a mesh
  34513. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34514. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34515. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34516. * @returns the current scene
  34517. */
  34518. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34519. /**
  34520. * Use this method to simulate a pointer down on a mesh
  34521. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34522. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34523. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34524. * @returns the current scene
  34525. */
  34526. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34527. /**
  34528. * Use this method to simulate a pointer up on a mesh
  34529. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34530. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34531. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34532. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34533. * @returns the current scene
  34534. */
  34535. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34536. /**
  34537. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34538. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34539. * @returns true if the pointer was captured
  34540. */
  34541. isPointerCaptured(pointerId?: number): boolean;
  34542. /**
  34543. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34544. * @param attachUp defines if you want to attach events to pointerup
  34545. * @param attachDown defines if you want to attach events to pointerdown
  34546. * @param attachMove defines if you want to attach events to pointermove
  34547. */
  34548. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34549. /** Detaches all event handlers*/
  34550. detachControl(): void;
  34551. /**
  34552. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34553. * Delay loaded resources are not taking in account
  34554. * @return true if all required resources are ready
  34555. */
  34556. isReady(): boolean;
  34557. /** Resets all cached information relative to material (including effect and visibility) */
  34558. resetCachedMaterial(): void;
  34559. /**
  34560. * Registers a function to be called before every frame render
  34561. * @param func defines the function to register
  34562. */
  34563. registerBeforeRender(func: () => void): void;
  34564. /**
  34565. * Unregisters a function called before every frame render
  34566. * @param func defines the function to unregister
  34567. */
  34568. unregisterBeforeRender(func: () => void): void;
  34569. /**
  34570. * Registers a function to be called after every frame render
  34571. * @param func defines the function to register
  34572. */
  34573. registerAfterRender(func: () => void): void;
  34574. /**
  34575. * Unregisters a function called after every frame render
  34576. * @param func defines the function to unregister
  34577. */
  34578. unregisterAfterRender(func: () => void): void;
  34579. private _executeOnceBeforeRender;
  34580. /**
  34581. * The provided function will run before render once and will be disposed afterwards.
  34582. * A timeout delay can be provided so that the function will be executed in N ms.
  34583. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34584. * @param func The function to be executed.
  34585. * @param timeout optional delay in ms
  34586. */
  34587. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34588. /** @hidden */
  34589. _addPendingData(data: any): void;
  34590. /** @hidden */
  34591. _removePendingData(data: any): void;
  34592. /**
  34593. * Returns the number of items waiting to be loaded
  34594. * @returns the number of items waiting to be loaded
  34595. */
  34596. getWaitingItemsCount(): number;
  34597. /**
  34598. * Returns a boolean indicating if the scene is still loading data
  34599. */
  34600. readonly isLoading: boolean;
  34601. /**
  34602. * Registers a function to be executed when the scene is ready
  34603. * @param {Function} func - the function to be executed
  34604. */
  34605. executeWhenReady(func: () => void): void;
  34606. /**
  34607. * Returns a promise that resolves when the scene is ready
  34608. * @returns A promise that resolves when the scene is ready
  34609. */
  34610. whenReadyAsync(): Promise<void>;
  34611. /** @hidden */
  34612. _checkIsReady(): void;
  34613. /**
  34614. * Gets all animatable attached to the scene
  34615. */
  34616. readonly animatables: Animatable[];
  34617. /**
  34618. * Resets the last animation time frame.
  34619. * Useful to override when animations start running when loading a scene for the first time.
  34620. */
  34621. resetLastAnimationTimeFrame(): void;
  34622. /**
  34623. * Gets the current view matrix
  34624. * @returns a Matrix
  34625. */
  34626. getViewMatrix(): Matrix;
  34627. /**
  34628. * Gets the current projection matrix
  34629. * @returns a Matrix
  34630. */
  34631. getProjectionMatrix(): Matrix;
  34632. /**
  34633. * Gets the current transform matrix
  34634. * @returns a Matrix made of View * Projection
  34635. */
  34636. getTransformMatrix(): Matrix;
  34637. /**
  34638. * Sets the current transform matrix
  34639. * @param viewL defines the View matrix to use
  34640. * @param projectionL defines the Projection matrix to use
  34641. * @param viewR defines the right View matrix to use (if provided)
  34642. * @param projectionR defines the right Projection matrix to use (if provided)
  34643. */
  34644. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34645. /**
  34646. * Gets the uniform buffer used to store scene data
  34647. * @returns a UniformBuffer
  34648. */
  34649. getSceneUniformBuffer(): UniformBuffer;
  34650. /**
  34651. * Gets an unique (relatively to the current scene) Id
  34652. * @returns an unique number for the scene
  34653. */
  34654. getUniqueId(): number;
  34655. /**
  34656. * Add a mesh to the list of scene's meshes
  34657. * @param newMesh defines the mesh to add
  34658. * @param recursive if all child meshes should also be added to the scene
  34659. */
  34660. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34661. /**
  34662. * Remove a mesh for the list of scene's meshes
  34663. * @param toRemove defines the mesh to remove
  34664. * @param recursive if all child meshes should also be removed from the scene
  34665. * @returns the index where the mesh was in the mesh list
  34666. */
  34667. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34668. /**
  34669. * Add a transform node to the list of scene's transform nodes
  34670. * @param newTransformNode defines the transform node to add
  34671. */
  34672. addTransformNode(newTransformNode: TransformNode): void;
  34673. /**
  34674. * Remove a transform node for the list of scene's transform nodes
  34675. * @param toRemove defines the transform node to remove
  34676. * @returns the index where the transform node was in the transform node list
  34677. */
  34678. removeTransformNode(toRemove: TransformNode): number;
  34679. /**
  34680. * Remove a skeleton for the list of scene's skeletons
  34681. * @param toRemove defines the skeleton to remove
  34682. * @returns the index where the skeleton was in the skeleton list
  34683. */
  34684. removeSkeleton(toRemove: Skeleton): number;
  34685. /**
  34686. * Remove a morph target for the list of scene's morph targets
  34687. * @param toRemove defines the morph target to remove
  34688. * @returns the index where the morph target was in the morph target list
  34689. */
  34690. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34691. /**
  34692. * Remove a light for the list of scene's lights
  34693. * @param toRemove defines the light to remove
  34694. * @returns the index where the light was in the light list
  34695. */
  34696. removeLight(toRemove: Light): number;
  34697. /**
  34698. * Remove a camera for the list of scene's cameras
  34699. * @param toRemove defines the camera to remove
  34700. * @returns the index where the camera was in the camera list
  34701. */
  34702. removeCamera(toRemove: Camera): number;
  34703. /**
  34704. * Remove a particle system for the list of scene's particle systems
  34705. * @param toRemove defines the particle system to remove
  34706. * @returns the index where the particle system was in the particle system list
  34707. */
  34708. removeParticleSystem(toRemove: IParticleSystem): number;
  34709. /**
  34710. * Remove a animation for the list of scene's animations
  34711. * @param toRemove defines the animation to remove
  34712. * @returns the index where the animation was in the animation list
  34713. */
  34714. removeAnimation(toRemove: Animation): number;
  34715. /**
  34716. * Will stop the animation of the given target
  34717. * @param target - the target
  34718. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34719. * @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)
  34720. */
  34721. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34722. /**
  34723. * Removes the given animation group from this scene.
  34724. * @param toRemove The animation group to remove
  34725. * @returns The index of the removed animation group
  34726. */
  34727. removeAnimationGroup(toRemove: AnimationGroup): number;
  34728. /**
  34729. * Removes the given multi-material from this scene.
  34730. * @param toRemove The multi-material to remove
  34731. * @returns The index of the removed multi-material
  34732. */
  34733. removeMultiMaterial(toRemove: MultiMaterial): number;
  34734. /**
  34735. * Removes the given material from this scene.
  34736. * @param toRemove The material to remove
  34737. * @returns The index of the removed material
  34738. */
  34739. removeMaterial(toRemove: Material): number;
  34740. /**
  34741. * Removes the given action manager from this scene.
  34742. * @param toRemove The action manager to remove
  34743. * @returns The index of the removed action manager
  34744. */
  34745. removeActionManager(toRemove: AbstractActionManager): number;
  34746. /**
  34747. * Removes the given texture from this scene.
  34748. * @param toRemove The texture to remove
  34749. * @returns The index of the removed texture
  34750. */
  34751. removeTexture(toRemove: BaseTexture): number;
  34752. /**
  34753. * Adds the given light to this scene
  34754. * @param newLight The light to add
  34755. */
  34756. addLight(newLight: Light): void;
  34757. /**
  34758. * Sorts the list list based on light priorities
  34759. */
  34760. sortLightsByPriority(): void;
  34761. /**
  34762. * Adds the given camera to this scene
  34763. * @param newCamera The camera to add
  34764. */
  34765. addCamera(newCamera: Camera): void;
  34766. /**
  34767. * Adds the given skeleton to this scene
  34768. * @param newSkeleton The skeleton to add
  34769. */
  34770. addSkeleton(newSkeleton: Skeleton): void;
  34771. /**
  34772. * Adds the given particle system to this scene
  34773. * @param newParticleSystem The particle system to add
  34774. */
  34775. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34776. /**
  34777. * Adds the given animation to this scene
  34778. * @param newAnimation The animation to add
  34779. */
  34780. addAnimation(newAnimation: Animation): void;
  34781. /**
  34782. * Adds the given animation group to this scene.
  34783. * @param newAnimationGroup The animation group to add
  34784. */
  34785. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34786. /**
  34787. * Adds the given multi-material to this scene
  34788. * @param newMultiMaterial The multi-material to add
  34789. */
  34790. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34791. /**
  34792. * Adds the given material to this scene
  34793. * @param newMaterial The material to add
  34794. */
  34795. addMaterial(newMaterial: Material): void;
  34796. /**
  34797. * Adds the given morph target to this scene
  34798. * @param newMorphTargetManager The morph target to add
  34799. */
  34800. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34801. /**
  34802. * Adds the given geometry to this scene
  34803. * @param newGeometry The geometry to add
  34804. */
  34805. addGeometry(newGeometry: Geometry): void;
  34806. /**
  34807. * Adds the given action manager to this scene
  34808. * @param newActionManager The action manager to add
  34809. */
  34810. addActionManager(newActionManager: AbstractActionManager): void;
  34811. /**
  34812. * Adds the given texture to this scene.
  34813. * @param newTexture The texture to add
  34814. */
  34815. addTexture(newTexture: BaseTexture): void;
  34816. /**
  34817. * Switch active camera
  34818. * @param newCamera defines the new active camera
  34819. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34820. */
  34821. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34822. /**
  34823. * sets the active camera of the scene using its ID
  34824. * @param id defines the camera's ID
  34825. * @return the new active camera or null if none found.
  34826. */
  34827. setActiveCameraByID(id: string): Nullable<Camera>;
  34828. /**
  34829. * sets the active camera of the scene using its name
  34830. * @param name defines the camera's name
  34831. * @returns the new active camera or null if none found.
  34832. */
  34833. setActiveCameraByName(name: string): Nullable<Camera>;
  34834. /**
  34835. * get an animation group using its name
  34836. * @param name defines the material's name
  34837. * @return the animation group or null if none found.
  34838. */
  34839. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34840. /**
  34841. * Get a material using its unique id
  34842. * @param uniqueId defines the material's unique id
  34843. * @return the material or null if none found.
  34844. */
  34845. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34846. /**
  34847. * get a material using its id
  34848. * @param id defines the material's ID
  34849. * @return the material or null if none found.
  34850. */
  34851. getMaterialByID(id: string): Nullable<Material>;
  34852. /**
  34853. * Gets a the last added material using a given id
  34854. * @param id defines the material's ID
  34855. * @return the last material with the given id or null if none found.
  34856. */
  34857. getLastMaterialByID(id: string): Nullable<Material>;
  34858. /**
  34859. * Gets a material using its name
  34860. * @param name defines the material's name
  34861. * @return the material or null if none found.
  34862. */
  34863. getMaterialByName(name: string): Nullable<Material>;
  34864. /**
  34865. * Get a texture using its unique id
  34866. * @param uniqueId defines the texture's unique id
  34867. * @return the texture or null if none found.
  34868. */
  34869. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34870. /**
  34871. * Gets a camera using its id
  34872. * @param id defines the id to look for
  34873. * @returns the camera or null if not found
  34874. */
  34875. getCameraByID(id: string): Nullable<Camera>;
  34876. /**
  34877. * Gets a camera using its unique id
  34878. * @param uniqueId defines the unique id to look for
  34879. * @returns the camera or null if not found
  34880. */
  34881. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34882. /**
  34883. * Gets a camera using its name
  34884. * @param name defines the camera's name
  34885. * @return the camera or null if none found.
  34886. */
  34887. getCameraByName(name: string): Nullable<Camera>;
  34888. /**
  34889. * Gets a bone using its id
  34890. * @param id defines the bone's id
  34891. * @return the bone or null if not found
  34892. */
  34893. getBoneByID(id: string): Nullable<Bone>;
  34894. /**
  34895. * Gets a bone using its id
  34896. * @param name defines the bone's name
  34897. * @return the bone or null if not found
  34898. */
  34899. getBoneByName(name: string): Nullable<Bone>;
  34900. /**
  34901. * Gets a light node using its name
  34902. * @param name defines the the light's name
  34903. * @return the light or null if none found.
  34904. */
  34905. getLightByName(name: string): Nullable<Light>;
  34906. /**
  34907. * Gets a light node using its id
  34908. * @param id defines the light's id
  34909. * @return the light or null if none found.
  34910. */
  34911. getLightByID(id: string): Nullable<Light>;
  34912. /**
  34913. * Gets a light node using its scene-generated unique ID
  34914. * @param uniqueId defines the light's unique id
  34915. * @return the light or null if none found.
  34916. */
  34917. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34918. /**
  34919. * Gets a particle system by id
  34920. * @param id defines the particle system id
  34921. * @return the corresponding system or null if none found
  34922. */
  34923. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34924. /**
  34925. * Gets a geometry using its ID
  34926. * @param id defines the geometry's id
  34927. * @return the geometry or null if none found.
  34928. */
  34929. getGeometryByID(id: string): Nullable<Geometry>;
  34930. private _getGeometryByUniqueID;
  34931. /**
  34932. * Add a new geometry to this scene
  34933. * @param geometry defines the geometry to be added to the scene.
  34934. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34935. * @return a boolean defining if the geometry was added or not
  34936. */
  34937. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34938. /**
  34939. * Removes an existing geometry
  34940. * @param geometry defines the geometry to be removed from the scene
  34941. * @return a boolean defining if the geometry was removed or not
  34942. */
  34943. removeGeometry(geometry: Geometry): boolean;
  34944. /**
  34945. * Gets the list of geometries attached to the scene
  34946. * @returns an array of Geometry
  34947. */
  34948. getGeometries(): Geometry[];
  34949. /**
  34950. * Gets the first added mesh found of a given ID
  34951. * @param id defines the id to search for
  34952. * @return the mesh found or null if not found at all
  34953. */
  34954. getMeshByID(id: string): Nullable<AbstractMesh>;
  34955. /**
  34956. * Gets a list of meshes using their id
  34957. * @param id defines the id to search for
  34958. * @returns a list of meshes
  34959. */
  34960. getMeshesByID(id: string): Array<AbstractMesh>;
  34961. /**
  34962. * Gets the first added transform node found of a given ID
  34963. * @param id defines the id to search for
  34964. * @return the found transform node or null if not found at all.
  34965. */
  34966. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34967. /**
  34968. * Gets a transform node with its auto-generated unique id
  34969. * @param uniqueId efines the unique id to search for
  34970. * @return the found transform node or null if not found at all.
  34971. */
  34972. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34973. /**
  34974. * Gets a list of transform nodes using their id
  34975. * @param id defines the id to search for
  34976. * @returns a list of transform nodes
  34977. */
  34978. getTransformNodesByID(id: string): Array<TransformNode>;
  34979. /**
  34980. * Gets a mesh with its auto-generated unique id
  34981. * @param uniqueId defines the unique id to search for
  34982. * @return the found mesh or null if not found at all.
  34983. */
  34984. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34985. /**
  34986. * Gets a the last added mesh using a given id
  34987. * @param id defines the id to search for
  34988. * @return the found mesh or null if not found at all.
  34989. */
  34990. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34991. /**
  34992. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34993. * @param id defines the id to search for
  34994. * @return the found node or null if not found at all
  34995. */
  34996. getLastEntryByID(id: string): Nullable<Node>;
  34997. /**
  34998. * Gets a node (Mesh, Camera, Light) using a given id
  34999. * @param id defines the id to search for
  35000. * @return the found node or null if not found at all
  35001. */
  35002. getNodeByID(id: string): Nullable<Node>;
  35003. /**
  35004. * Gets a node (Mesh, Camera, Light) using a given name
  35005. * @param name defines the name to search for
  35006. * @return the found node or null if not found at all.
  35007. */
  35008. getNodeByName(name: string): Nullable<Node>;
  35009. /**
  35010. * Gets a mesh using a given name
  35011. * @param name defines the name to search for
  35012. * @return the found mesh or null if not found at all.
  35013. */
  35014. getMeshByName(name: string): Nullable<AbstractMesh>;
  35015. /**
  35016. * Gets a transform node using a given name
  35017. * @param name defines the name to search for
  35018. * @return the found transform node or null if not found at all.
  35019. */
  35020. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35021. /**
  35022. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35023. * @param id defines the id to search for
  35024. * @return the found skeleton or null if not found at all.
  35025. */
  35026. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35027. /**
  35028. * Gets a skeleton using a given auto generated unique id
  35029. * @param uniqueId defines the unique id to search for
  35030. * @return the found skeleton or null if not found at all.
  35031. */
  35032. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35033. /**
  35034. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35035. * @param id defines the id to search for
  35036. * @return the found skeleton or null if not found at all.
  35037. */
  35038. getSkeletonById(id: string): Nullable<Skeleton>;
  35039. /**
  35040. * Gets a skeleton using a given name
  35041. * @param name defines the name to search for
  35042. * @return the found skeleton or null if not found at all.
  35043. */
  35044. getSkeletonByName(name: string): Nullable<Skeleton>;
  35045. /**
  35046. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35047. * @param id defines the id to search for
  35048. * @return the found morph target manager or null if not found at all.
  35049. */
  35050. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35051. /**
  35052. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35053. * @param id defines the id to search for
  35054. * @return the found morph target or null if not found at all.
  35055. */
  35056. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35057. /**
  35058. * Gets a boolean indicating if the given mesh is active
  35059. * @param mesh defines the mesh to look for
  35060. * @returns true if the mesh is in the active list
  35061. */
  35062. isActiveMesh(mesh: AbstractMesh): boolean;
  35063. /**
  35064. * Return a unique id as a string which can serve as an identifier for the scene
  35065. */
  35066. readonly uid: string;
  35067. /**
  35068. * Add an externaly attached data from its key.
  35069. * This method call will fail and return false, if such key already exists.
  35070. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35071. * @param key the unique key that identifies the data
  35072. * @param data the data object to associate to the key for this Engine instance
  35073. * @return true if no such key were already present and the data was added successfully, false otherwise
  35074. */
  35075. addExternalData<T>(key: string, data: T): boolean;
  35076. /**
  35077. * Get an externaly attached data from its key
  35078. * @param key the unique key that identifies the data
  35079. * @return the associated data, if present (can be null), or undefined if not present
  35080. */
  35081. getExternalData<T>(key: string): Nullable<T>;
  35082. /**
  35083. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35084. * @param key the unique key that identifies the data
  35085. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35086. * @return the associated data, can be null if the factory returned null.
  35087. */
  35088. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35089. /**
  35090. * Remove an externaly attached data from the Engine instance
  35091. * @param key the unique key that identifies the data
  35092. * @return true if the data was successfully removed, false if it doesn't exist
  35093. */
  35094. removeExternalData(key: string): boolean;
  35095. private _evaluateSubMesh;
  35096. /**
  35097. * Clear the processed materials smart array preventing retention point in material dispose.
  35098. */
  35099. freeProcessedMaterials(): void;
  35100. private _preventFreeActiveMeshesAndRenderingGroups;
  35101. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35102. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35103. * when disposing several meshes in a row or a hierarchy of meshes.
  35104. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35105. */
  35106. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35107. /**
  35108. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35109. */
  35110. freeActiveMeshes(): void;
  35111. /**
  35112. * Clear the info related to rendering groups preventing retention points during dispose.
  35113. */
  35114. freeRenderingGroups(): void;
  35115. /** @hidden */
  35116. _isInIntermediateRendering(): boolean;
  35117. /**
  35118. * Lambda returning the list of potentially active meshes.
  35119. */
  35120. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35121. /**
  35122. * Lambda returning the list of potentially active sub meshes.
  35123. */
  35124. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35125. /**
  35126. * Lambda returning the list of potentially intersecting sub meshes.
  35127. */
  35128. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35129. /**
  35130. * Lambda returning the list of potentially colliding sub meshes.
  35131. */
  35132. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35133. private _activeMeshesFrozen;
  35134. /**
  35135. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35136. * @returns the current scene
  35137. */
  35138. freezeActiveMeshes(): Scene;
  35139. /**
  35140. * Use this function to restart evaluating active meshes on every frame
  35141. * @returns the current scene
  35142. */
  35143. unfreezeActiveMeshes(): Scene;
  35144. private _evaluateActiveMeshes;
  35145. private _activeMesh;
  35146. /**
  35147. * Update the transform matrix to update from the current active camera
  35148. * @param force defines a boolean used to force the update even if cache is up to date
  35149. */
  35150. updateTransformMatrix(force?: boolean): void;
  35151. private _bindFrameBuffer;
  35152. /** @hidden */
  35153. _allowPostProcessClearColor: boolean;
  35154. /** @hidden */
  35155. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35156. private _processSubCameras;
  35157. private _checkIntersections;
  35158. /** @hidden */
  35159. _advancePhysicsEngineStep(step: number): void;
  35160. /**
  35161. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35162. */
  35163. getDeterministicFrameTime: () => number;
  35164. /** @hidden */
  35165. _animate(): void;
  35166. /** Execute all animations (for a frame) */
  35167. animate(): void;
  35168. /**
  35169. * Render the scene
  35170. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35171. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35172. */
  35173. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35174. /**
  35175. * Freeze all materials
  35176. * A frozen material will not be updatable but should be faster to render
  35177. */
  35178. freezeMaterials(): void;
  35179. /**
  35180. * Unfreeze all materials
  35181. * A frozen material will not be updatable but should be faster to render
  35182. */
  35183. unfreezeMaterials(): void;
  35184. /**
  35185. * Releases all held ressources
  35186. */
  35187. dispose(): void;
  35188. /**
  35189. * Gets if the scene is already disposed
  35190. */
  35191. readonly isDisposed: boolean;
  35192. /**
  35193. * Call this function to reduce memory footprint of the scene.
  35194. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35195. */
  35196. clearCachedVertexData(): void;
  35197. /**
  35198. * This function will remove the local cached buffer data from texture.
  35199. * It will save memory but will prevent the texture from being rebuilt
  35200. */
  35201. cleanCachedTextureBuffer(): void;
  35202. /**
  35203. * Get the world extend vectors with an optional filter
  35204. *
  35205. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35206. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35207. */
  35208. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35209. min: Vector3;
  35210. max: Vector3;
  35211. };
  35212. /**
  35213. * Creates a ray that can be used to pick in the scene
  35214. * @param x defines the x coordinate of the origin (on-screen)
  35215. * @param y defines the y coordinate of the origin (on-screen)
  35216. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35217. * @param camera defines the camera to use for the picking
  35218. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35219. * @returns a Ray
  35220. */
  35221. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35222. /**
  35223. * Creates a ray that can be used to pick in the scene
  35224. * @param x defines the x coordinate of the origin (on-screen)
  35225. * @param y defines the y coordinate of the origin (on-screen)
  35226. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35227. * @param result defines the ray where to store the picking ray
  35228. * @param camera defines the camera to use for the picking
  35229. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35230. * @returns the current scene
  35231. */
  35232. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35233. /**
  35234. * Creates a ray that can be used to pick in the scene
  35235. * @param x defines the x coordinate of the origin (on-screen)
  35236. * @param y defines the y coordinate of the origin (on-screen)
  35237. * @param camera defines the camera to use for the picking
  35238. * @returns a Ray
  35239. */
  35240. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35241. /**
  35242. * Creates a ray that can be used to pick in the scene
  35243. * @param x defines the x coordinate of the origin (on-screen)
  35244. * @param y defines the y coordinate of the origin (on-screen)
  35245. * @param result defines the ray where to store the picking ray
  35246. * @param camera defines the camera to use for the picking
  35247. * @returns the current scene
  35248. */
  35249. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35250. /** Launch a ray to try to pick a mesh in the scene
  35251. * @param x position on screen
  35252. * @param y position on screen
  35253. * @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
  35254. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35255. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35256. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35257. * @returns a PickingInfo
  35258. */
  35259. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35260. /** Use the given ray to pick a mesh in the scene
  35261. * @param ray The ray to use to pick meshes
  35262. * @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
  35263. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35264. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35265. * @returns a PickingInfo
  35266. */
  35267. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35268. /**
  35269. * Launch a ray to try to pick a mesh in the scene
  35270. * @param x X position on screen
  35271. * @param y Y position on screen
  35272. * @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
  35273. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35274. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35275. * @returns an array of PickingInfo
  35276. */
  35277. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35278. /**
  35279. * Launch a ray to try to pick a mesh in the scene
  35280. * @param ray Ray to use
  35281. * @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
  35282. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35283. * @returns an array of PickingInfo
  35284. */
  35285. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35286. /**
  35287. * Force the value of meshUnderPointer
  35288. * @param mesh defines the mesh to use
  35289. */
  35290. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35291. /**
  35292. * Gets the mesh under the pointer
  35293. * @returns a Mesh or null if no mesh is under the pointer
  35294. */
  35295. getPointerOverMesh(): Nullable<AbstractMesh>;
  35296. /** @hidden */
  35297. _rebuildGeometries(): void;
  35298. /** @hidden */
  35299. _rebuildTextures(): void;
  35300. private _getByTags;
  35301. /**
  35302. * Get a list of meshes by tags
  35303. * @param tagsQuery defines the tags query to use
  35304. * @param forEach defines a predicate used to filter results
  35305. * @returns an array of Mesh
  35306. */
  35307. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35308. /**
  35309. * Get a list of cameras by tags
  35310. * @param tagsQuery defines the tags query to use
  35311. * @param forEach defines a predicate used to filter results
  35312. * @returns an array of Camera
  35313. */
  35314. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35315. /**
  35316. * Get a list of lights by tags
  35317. * @param tagsQuery defines the tags query to use
  35318. * @param forEach defines a predicate used to filter results
  35319. * @returns an array of Light
  35320. */
  35321. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35322. /**
  35323. * Get a list of materials by tags
  35324. * @param tagsQuery defines the tags query to use
  35325. * @param forEach defines a predicate used to filter results
  35326. * @returns an array of Material
  35327. */
  35328. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35329. /**
  35330. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35331. * This allowed control for front to back rendering or reversly depending of the special needs.
  35332. *
  35333. * @param renderingGroupId The rendering group id corresponding to its index
  35334. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35335. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35336. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35337. */
  35338. 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;
  35339. /**
  35340. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35341. *
  35342. * @param renderingGroupId The rendering group id corresponding to its index
  35343. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35344. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35345. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35346. */
  35347. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35348. /**
  35349. * Gets the current auto clear configuration for one rendering group of the rendering
  35350. * manager.
  35351. * @param index the rendering group index to get the information for
  35352. * @returns The auto clear setup for the requested rendering group
  35353. */
  35354. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35355. private _blockMaterialDirtyMechanism;
  35356. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35357. blockMaterialDirtyMechanism: boolean;
  35358. /**
  35359. * Will flag all materials as dirty to trigger new shader compilation
  35360. * @param flag defines the flag used to specify which material part must be marked as dirty
  35361. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35362. */
  35363. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35364. /** @hidden */
  35365. _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;
  35366. /** @hidden */
  35367. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35368. }
  35369. }
  35370. declare module "babylonjs/assetContainer" {
  35371. import { AbstractScene } from "babylonjs/abstractScene";
  35372. import { Scene } from "babylonjs/scene";
  35373. import { Mesh } from "babylonjs/Meshes/mesh";
  35374. /**
  35375. * Set of assets to keep when moving a scene into an asset container.
  35376. */
  35377. export class KeepAssets extends AbstractScene {
  35378. }
  35379. /**
  35380. * Container with a set of assets that can be added or removed from a scene.
  35381. */
  35382. export class AssetContainer extends AbstractScene {
  35383. /**
  35384. * The scene the AssetContainer belongs to.
  35385. */
  35386. scene: Scene;
  35387. /**
  35388. * Instantiates an AssetContainer.
  35389. * @param scene The scene the AssetContainer belongs to.
  35390. */
  35391. constructor(scene: Scene);
  35392. /**
  35393. * Adds all the assets from the container to the scene.
  35394. */
  35395. addAllToScene(): void;
  35396. /**
  35397. * Removes all the assets in the container from the scene
  35398. */
  35399. removeAllFromScene(): void;
  35400. /**
  35401. * Disposes all the assets in the container
  35402. */
  35403. dispose(): void;
  35404. private _moveAssets;
  35405. /**
  35406. * Removes all the assets contained in the scene and adds them to the container.
  35407. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35408. */
  35409. moveAllFromScene(keepAssets?: KeepAssets): void;
  35410. /**
  35411. * 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.
  35412. * @returns the root mesh
  35413. */
  35414. createRootMesh(): Mesh;
  35415. }
  35416. }
  35417. declare module "babylonjs/abstractScene" {
  35418. import { Scene } from "babylonjs/scene";
  35419. import { Nullable } from "babylonjs/types";
  35420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35421. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35422. import { Geometry } from "babylonjs/Meshes/geometry";
  35423. import { Skeleton } from "babylonjs/Bones/skeleton";
  35424. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35425. import { AssetContainer } from "babylonjs/assetContainer";
  35426. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35427. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35429. import { Material } from "babylonjs/Materials/material";
  35430. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35431. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35432. import { Camera } from "babylonjs/Cameras/camera";
  35433. import { Light } from "babylonjs/Lights/light";
  35434. import { Node } from "babylonjs/node";
  35435. import { Animation } from "babylonjs/Animations/animation";
  35436. /**
  35437. * Defines how the parser contract is defined.
  35438. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35439. */
  35440. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35441. /**
  35442. * Defines how the individual parser contract is defined.
  35443. * These parser can parse an individual asset
  35444. */
  35445. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35446. /**
  35447. * Base class of the scene acting as a container for the different elements composing a scene.
  35448. * This class is dynamically extended by the different components of the scene increasing
  35449. * flexibility and reducing coupling
  35450. */
  35451. export abstract class AbstractScene {
  35452. /**
  35453. * Stores the list of available parsers in the application.
  35454. */
  35455. private static _BabylonFileParsers;
  35456. /**
  35457. * Stores the list of available individual parsers in the application.
  35458. */
  35459. private static _IndividualBabylonFileParsers;
  35460. /**
  35461. * Adds a parser in the list of available ones
  35462. * @param name Defines the name of the parser
  35463. * @param parser Defines the parser to add
  35464. */
  35465. static AddParser(name: string, parser: BabylonFileParser): void;
  35466. /**
  35467. * Gets a general parser from the list of avaialble ones
  35468. * @param name Defines the name of the parser
  35469. * @returns the requested parser or null
  35470. */
  35471. static GetParser(name: string): Nullable<BabylonFileParser>;
  35472. /**
  35473. * Adds n individual parser in the list of available ones
  35474. * @param name Defines the name of the parser
  35475. * @param parser Defines the parser to add
  35476. */
  35477. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35478. /**
  35479. * Gets an individual parser from the list of avaialble ones
  35480. * @param name Defines the name of the parser
  35481. * @returns the requested parser or null
  35482. */
  35483. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35484. /**
  35485. * Parser json data and populate both a scene and its associated container object
  35486. * @param jsonData Defines the data to parse
  35487. * @param scene Defines the scene to parse the data for
  35488. * @param container Defines the container attached to the parsing sequence
  35489. * @param rootUrl Defines the root url of the data
  35490. */
  35491. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35492. /**
  35493. * Gets the list of root nodes (ie. nodes with no parent)
  35494. */
  35495. rootNodes: Node[];
  35496. /** All of the cameras added to this scene
  35497. * @see http://doc.babylonjs.com/babylon101/cameras
  35498. */
  35499. cameras: Camera[];
  35500. /**
  35501. * All of the lights added to this scene
  35502. * @see http://doc.babylonjs.com/babylon101/lights
  35503. */
  35504. lights: Light[];
  35505. /**
  35506. * All of the (abstract) meshes added to this scene
  35507. */
  35508. meshes: AbstractMesh[];
  35509. /**
  35510. * The list of skeletons added to the scene
  35511. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35512. */
  35513. skeletons: Skeleton[];
  35514. /**
  35515. * All of the particle systems added to this scene
  35516. * @see http://doc.babylonjs.com/babylon101/particles
  35517. */
  35518. particleSystems: IParticleSystem[];
  35519. /**
  35520. * Gets a list of Animations associated with the scene
  35521. */
  35522. animations: Animation[];
  35523. /**
  35524. * All of the animation groups added to this scene
  35525. * @see http://doc.babylonjs.com/how_to/group
  35526. */
  35527. animationGroups: AnimationGroup[];
  35528. /**
  35529. * All of the multi-materials added to this scene
  35530. * @see http://doc.babylonjs.com/how_to/multi_materials
  35531. */
  35532. multiMaterials: MultiMaterial[];
  35533. /**
  35534. * All of the materials added to this scene
  35535. * In the context of a Scene, it is not supposed to be modified manually.
  35536. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35537. * Note also that the order of the Material wihin the array is not significant and might change.
  35538. * @see http://doc.babylonjs.com/babylon101/materials
  35539. */
  35540. materials: Material[];
  35541. /**
  35542. * The list of morph target managers added to the scene
  35543. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35544. */
  35545. morphTargetManagers: MorphTargetManager[];
  35546. /**
  35547. * The list of geometries used in the scene.
  35548. */
  35549. geometries: Geometry[];
  35550. /**
  35551. * All of the tranform nodes added to this scene
  35552. * In the context of a Scene, it is not supposed to be modified manually.
  35553. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35554. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35555. * @see http://doc.babylonjs.com/how_to/transformnode
  35556. */
  35557. transformNodes: TransformNode[];
  35558. /**
  35559. * ActionManagers available on the scene.
  35560. */
  35561. actionManagers: AbstractActionManager[];
  35562. /**
  35563. * Textures to keep.
  35564. */
  35565. textures: BaseTexture[];
  35566. /**
  35567. * Environment texture for the scene
  35568. */
  35569. environmentTexture: Nullable<BaseTexture>;
  35570. }
  35571. }
  35572. declare module "babylonjs/Audio/sound" {
  35573. import { Observable } from "babylonjs/Misc/observable";
  35574. import { Vector3 } from "babylonjs/Maths/math.vector";
  35575. import { Nullable } from "babylonjs/types";
  35576. import { Scene } from "babylonjs/scene";
  35577. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35578. /**
  35579. * Interface used to define options for Sound class
  35580. */
  35581. export interface ISoundOptions {
  35582. /**
  35583. * Does the sound autoplay once loaded.
  35584. */
  35585. autoplay?: boolean;
  35586. /**
  35587. * Does the sound loop after it finishes playing once.
  35588. */
  35589. loop?: boolean;
  35590. /**
  35591. * Sound's volume
  35592. */
  35593. volume?: number;
  35594. /**
  35595. * Is it a spatial sound?
  35596. */
  35597. spatialSound?: boolean;
  35598. /**
  35599. * Maximum distance to hear that sound
  35600. */
  35601. maxDistance?: number;
  35602. /**
  35603. * Uses user defined attenuation function
  35604. */
  35605. useCustomAttenuation?: boolean;
  35606. /**
  35607. * Define the roll off factor of spatial sounds.
  35608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35609. */
  35610. rolloffFactor?: number;
  35611. /**
  35612. * Define the reference distance the sound should be heard perfectly.
  35613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35614. */
  35615. refDistance?: number;
  35616. /**
  35617. * Define the distance attenuation model the sound will follow.
  35618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35619. */
  35620. distanceModel?: string;
  35621. /**
  35622. * Defines the playback speed (1 by default)
  35623. */
  35624. playbackRate?: number;
  35625. /**
  35626. * Defines if the sound is from a streaming source
  35627. */
  35628. streaming?: boolean;
  35629. /**
  35630. * Defines an optional length (in seconds) inside the sound file
  35631. */
  35632. length?: number;
  35633. /**
  35634. * Defines an optional offset (in seconds) inside the sound file
  35635. */
  35636. offset?: number;
  35637. /**
  35638. * If true, URLs will not be required to state the audio file codec to use.
  35639. */
  35640. skipCodecCheck?: boolean;
  35641. }
  35642. /**
  35643. * Defines a sound that can be played in the application.
  35644. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35646. */
  35647. export class Sound {
  35648. /**
  35649. * The name of the sound in the scene.
  35650. */
  35651. name: string;
  35652. /**
  35653. * Does the sound autoplay once loaded.
  35654. */
  35655. autoplay: boolean;
  35656. /**
  35657. * Does the sound loop after it finishes playing once.
  35658. */
  35659. loop: boolean;
  35660. /**
  35661. * Does the sound use a custom attenuation curve to simulate the falloff
  35662. * happening when the source gets further away from the camera.
  35663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35664. */
  35665. useCustomAttenuation: boolean;
  35666. /**
  35667. * The sound track id this sound belongs to.
  35668. */
  35669. soundTrackId: number;
  35670. /**
  35671. * Is this sound currently played.
  35672. */
  35673. isPlaying: boolean;
  35674. /**
  35675. * Is this sound currently paused.
  35676. */
  35677. isPaused: boolean;
  35678. /**
  35679. * Does this sound enables spatial sound.
  35680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35681. */
  35682. spatialSound: boolean;
  35683. /**
  35684. * Define the reference distance the sound should be heard perfectly.
  35685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35686. */
  35687. refDistance: number;
  35688. /**
  35689. * Define the roll off factor of spatial sounds.
  35690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35691. */
  35692. rolloffFactor: number;
  35693. /**
  35694. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35696. */
  35697. maxDistance: number;
  35698. /**
  35699. * Define the distance attenuation model the sound will follow.
  35700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35701. */
  35702. distanceModel: string;
  35703. /**
  35704. * @hidden
  35705. * Back Compat
  35706. **/
  35707. onended: () => any;
  35708. /**
  35709. * Observable event when the current playing sound finishes.
  35710. */
  35711. onEndedObservable: Observable<Sound>;
  35712. private _panningModel;
  35713. private _playbackRate;
  35714. private _streaming;
  35715. private _startTime;
  35716. private _startOffset;
  35717. private _position;
  35718. /** @hidden */
  35719. _positionInEmitterSpace: boolean;
  35720. private _localDirection;
  35721. private _volume;
  35722. private _isReadyToPlay;
  35723. private _isDirectional;
  35724. private _readyToPlayCallback;
  35725. private _audioBuffer;
  35726. private _soundSource;
  35727. private _streamingSource;
  35728. private _soundPanner;
  35729. private _soundGain;
  35730. private _inputAudioNode;
  35731. private _outputAudioNode;
  35732. private _coneInnerAngle;
  35733. private _coneOuterAngle;
  35734. private _coneOuterGain;
  35735. private _scene;
  35736. private _connectedTransformNode;
  35737. private _customAttenuationFunction;
  35738. private _registerFunc;
  35739. private _isOutputConnected;
  35740. private _htmlAudioElement;
  35741. private _urlType;
  35742. private _length?;
  35743. private _offset?;
  35744. /** @hidden */
  35745. static _SceneComponentInitialization: (scene: Scene) => void;
  35746. /**
  35747. * Create a sound and attach it to a scene
  35748. * @param name Name of your sound
  35749. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35750. * @param scene defines the scene the sound belongs to
  35751. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35752. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35753. */
  35754. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35755. /**
  35756. * Release the sound and its associated resources
  35757. */
  35758. dispose(): void;
  35759. /**
  35760. * Gets if the sounds is ready to be played or not.
  35761. * @returns true if ready, otherwise false
  35762. */
  35763. isReady(): boolean;
  35764. private _soundLoaded;
  35765. /**
  35766. * Sets the data of the sound from an audiobuffer
  35767. * @param audioBuffer The audioBuffer containing the data
  35768. */
  35769. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35770. /**
  35771. * Updates the current sounds options such as maxdistance, loop...
  35772. * @param options A JSON object containing values named as the object properties
  35773. */
  35774. updateOptions(options: ISoundOptions): void;
  35775. private _createSpatialParameters;
  35776. private _updateSpatialParameters;
  35777. /**
  35778. * Switch the panning model to HRTF:
  35779. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35781. */
  35782. switchPanningModelToHRTF(): void;
  35783. /**
  35784. * Switch the panning model to Equal Power:
  35785. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35787. */
  35788. switchPanningModelToEqualPower(): void;
  35789. private _switchPanningModel;
  35790. /**
  35791. * Connect this sound to a sound track audio node like gain...
  35792. * @param soundTrackAudioNode the sound track audio node to connect to
  35793. */
  35794. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35795. /**
  35796. * Transform this sound into a directional source
  35797. * @param coneInnerAngle Size of the inner cone in degree
  35798. * @param coneOuterAngle Size of the outer cone in degree
  35799. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35800. */
  35801. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35802. /**
  35803. * Gets or sets the inner angle for the directional cone.
  35804. */
  35805. /**
  35806. * Gets or sets the inner angle for the directional cone.
  35807. */
  35808. directionalConeInnerAngle: number;
  35809. /**
  35810. * Gets or sets the outer angle for the directional cone.
  35811. */
  35812. /**
  35813. * Gets or sets the outer angle for the directional cone.
  35814. */
  35815. directionalConeOuterAngle: number;
  35816. /**
  35817. * Sets the position of the emitter if spatial sound is enabled
  35818. * @param newPosition Defines the new posisiton
  35819. */
  35820. setPosition(newPosition: Vector3): void;
  35821. /**
  35822. * Sets the local direction of the emitter if spatial sound is enabled
  35823. * @param newLocalDirection Defines the new local direction
  35824. */
  35825. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35826. private _updateDirection;
  35827. /** @hidden */
  35828. updateDistanceFromListener(): void;
  35829. /**
  35830. * Sets a new custom attenuation function for the sound.
  35831. * @param callback Defines the function used for the attenuation
  35832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35833. */
  35834. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35835. /**
  35836. * Play the sound
  35837. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35838. * @param offset (optional) Start the sound at a specific time in seconds
  35839. * @param length (optional) Sound duration (in seconds)
  35840. */
  35841. play(time?: number, offset?: number, length?: number): void;
  35842. private _onended;
  35843. /**
  35844. * Stop the sound
  35845. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35846. */
  35847. stop(time?: number): void;
  35848. /**
  35849. * Put the sound in pause
  35850. */
  35851. pause(): void;
  35852. /**
  35853. * Sets a dedicated volume for this sounds
  35854. * @param newVolume Define the new volume of the sound
  35855. * @param time Define time for gradual change to new volume
  35856. */
  35857. setVolume(newVolume: number, time?: number): void;
  35858. /**
  35859. * Set the sound play back rate
  35860. * @param newPlaybackRate Define the playback rate the sound should be played at
  35861. */
  35862. setPlaybackRate(newPlaybackRate: number): void;
  35863. /**
  35864. * Gets the volume of the sound.
  35865. * @returns the volume of the sound
  35866. */
  35867. getVolume(): number;
  35868. /**
  35869. * Attach the sound to a dedicated mesh
  35870. * @param transformNode The transform node to connect the sound with
  35871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35872. */
  35873. attachToMesh(transformNode: TransformNode): void;
  35874. /**
  35875. * Detach the sound from the previously attached mesh
  35876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35877. */
  35878. detachFromMesh(): void;
  35879. private _onRegisterAfterWorldMatrixUpdate;
  35880. /**
  35881. * Clone the current sound in the scene.
  35882. * @returns the new sound clone
  35883. */
  35884. clone(): Nullable<Sound>;
  35885. /**
  35886. * Gets the current underlying audio buffer containing the data
  35887. * @returns the audio buffer
  35888. */
  35889. getAudioBuffer(): Nullable<AudioBuffer>;
  35890. /**
  35891. * Serializes the Sound in a JSON representation
  35892. * @returns the JSON representation of the sound
  35893. */
  35894. serialize(): any;
  35895. /**
  35896. * Parse a JSON representation of a sound to innstantiate in a given scene
  35897. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35898. * @param scene Define the scene the new parsed sound should be created in
  35899. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35900. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35901. * @returns the newly parsed sound
  35902. */
  35903. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35904. }
  35905. }
  35906. declare module "babylonjs/Actions/directAudioActions" {
  35907. import { Action } from "babylonjs/Actions/action";
  35908. import { Condition } from "babylonjs/Actions/condition";
  35909. import { Sound } from "babylonjs/Audio/sound";
  35910. /**
  35911. * This defines an action helpful to play a defined sound on a triggered action.
  35912. */
  35913. export class PlaySoundAction extends Action {
  35914. private _sound;
  35915. /**
  35916. * Instantiate the action
  35917. * @param triggerOptions defines the trigger options
  35918. * @param sound defines the sound to play
  35919. * @param condition defines the trigger related conditions
  35920. */
  35921. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35922. /** @hidden */
  35923. _prepare(): void;
  35924. /**
  35925. * Execute the action and play the sound.
  35926. */
  35927. execute(): void;
  35928. /**
  35929. * Serializes the actions and its related information.
  35930. * @param parent defines the object to serialize in
  35931. * @returns the serialized object
  35932. */
  35933. serialize(parent: any): any;
  35934. }
  35935. /**
  35936. * This defines an action helpful to stop a defined sound on a triggered action.
  35937. */
  35938. export class StopSoundAction extends Action {
  35939. private _sound;
  35940. /**
  35941. * Instantiate the action
  35942. * @param triggerOptions defines the trigger options
  35943. * @param sound defines the sound to stop
  35944. * @param condition defines the trigger related conditions
  35945. */
  35946. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35947. /** @hidden */
  35948. _prepare(): void;
  35949. /**
  35950. * Execute the action and stop the sound.
  35951. */
  35952. execute(): void;
  35953. /**
  35954. * Serializes the actions and its related information.
  35955. * @param parent defines the object to serialize in
  35956. * @returns the serialized object
  35957. */
  35958. serialize(parent: any): any;
  35959. }
  35960. }
  35961. declare module "babylonjs/Actions/interpolateValueAction" {
  35962. import { Action } from "babylonjs/Actions/action";
  35963. import { Condition } from "babylonjs/Actions/condition";
  35964. import { Observable } from "babylonjs/Misc/observable";
  35965. /**
  35966. * This defines an action responsible to change the value of a property
  35967. * by interpolating between its current value and the newly set one once triggered.
  35968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35969. */
  35970. export class InterpolateValueAction extends Action {
  35971. /**
  35972. * Defines the path of the property where the value should be interpolated
  35973. */
  35974. propertyPath: string;
  35975. /**
  35976. * Defines the target value at the end of the interpolation.
  35977. */
  35978. value: any;
  35979. /**
  35980. * Defines the time it will take for the property to interpolate to the value.
  35981. */
  35982. duration: number;
  35983. /**
  35984. * Defines if the other scene animations should be stopped when the action has been triggered
  35985. */
  35986. stopOtherAnimations?: boolean;
  35987. /**
  35988. * Defines a callback raised once the interpolation animation has been done.
  35989. */
  35990. onInterpolationDone?: () => void;
  35991. /**
  35992. * Observable triggered once the interpolation animation has been done.
  35993. */
  35994. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35995. private _target;
  35996. private _effectiveTarget;
  35997. private _property;
  35998. /**
  35999. * Instantiate the action
  36000. * @param triggerOptions defines the trigger options
  36001. * @param target defines the object containing the value to interpolate
  36002. * @param propertyPath defines the path to the property in the target object
  36003. * @param value defines the target value at the end of the interpolation
  36004. * @param duration deines the time it will take for the property to interpolate to the value.
  36005. * @param condition defines the trigger related conditions
  36006. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36007. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36008. */
  36009. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36010. /** @hidden */
  36011. _prepare(): void;
  36012. /**
  36013. * Execute the action starts the value interpolation.
  36014. */
  36015. execute(): void;
  36016. /**
  36017. * Serializes the actions and its related information.
  36018. * @param parent defines the object to serialize in
  36019. * @returns the serialized object
  36020. */
  36021. serialize(parent: any): any;
  36022. }
  36023. }
  36024. declare module "babylonjs/Actions/index" {
  36025. export * from "babylonjs/Actions/action";
  36026. export * from "babylonjs/Actions/actionEvent";
  36027. export * from "babylonjs/Actions/actionManager";
  36028. export * from "babylonjs/Actions/condition";
  36029. export * from "babylonjs/Actions/directActions";
  36030. export * from "babylonjs/Actions/directAudioActions";
  36031. export * from "babylonjs/Actions/interpolateValueAction";
  36032. }
  36033. declare module "babylonjs/Animations/index" {
  36034. export * from "babylonjs/Animations/animatable";
  36035. export * from "babylonjs/Animations/animation";
  36036. export * from "babylonjs/Animations/animationGroup";
  36037. export * from "babylonjs/Animations/animationPropertiesOverride";
  36038. export * from "babylonjs/Animations/easing";
  36039. export * from "babylonjs/Animations/runtimeAnimation";
  36040. export * from "babylonjs/Animations/animationEvent";
  36041. export * from "babylonjs/Animations/animationGroup";
  36042. export * from "babylonjs/Animations/animationKey";
  36043. export * from "babylonjs/Animations/animationRange";
  36044. export * from "babylonjs/Animations/animatable.interface";
  36045. }
  36046. declare module "babylonjs/Audio/soundTrack" {
  36047. import { Sound } from "babylonjs/Audio/sound";
  36048. import { Analyser } from "babylonjs/Audio/analyser";
  36049. import { Scene } from "babylonjs/scene";
  36050. /**
  36051. * Options allowed during the creation of a sound track.
  36052. */
  36053. export interface ISoundTrackOptions {
  36054. /**
  36055. * The volume the sound track should take during creation
  36056. */
  36057. volume?: number;
  36058. /**
  36059. * Define if the sound track is the main sound track of the scene
  36060. */
  36061. mainTrack?: boolean;
  36062. }
  36063. /**
  36064. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36065. * It will be also used in a future release to apply effects on a specific track.
  36066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36067. */
  36068. export class SoundTrack {
  36069. /**
  36070. * The unique identifier of the sound track in the scene.
  36071. */
  36072. id: number;
  36073. /**
  36074. * The list of sounds included in the sound track.
  36075. */
  36076. soundCollection: Array<Sound>;
  36077. private _outputAudioNode;
  36078. private _scene;
  36079. private _isMainTrack;
  36080. private _connectedAnalyser;
  36081. private _options;
  36082. private _isInitialized;
  36083. /**
  36084. * Creates a new sound track.
  36085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36086. * @param scene Define the scene the sound track belongs to
  36087. * @param options
  36088. */
  36089. constructor(scene: Scene, options?: ISoundTrackOptions);
  36090. private _initializeSoundTrackAudioGraph;
  36091. /**
  36092. * Release the sound track and its associated resources
  36093. */
  36094. dispose(): void;
  36095. /**
  36096. * Adds a sound to this sound track
  36097. * @param sound define the cound to add
  36098. * @ignoreNaming
  36099. */
  36100. AddSound(sound: Sound): void;
  36101. /**
  36102. * Removes a sound to this sound track
  36103. * @param sound define the cound to remove
  36104. * @ignoreNaming
  36105. */
  36106. RemoveSound(sound: Sound): void;
  36107. /**
  36108. * Set a global volume for the full sound track.
  36109. * @param newVolume Define the new volume of the sound track
  36110. */
  36111. setVolume(newVolume: number): void;
  36112. /**
  36113. * Switch the panning model to HRTF:
  36114. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36116. */
  36117. switchPanningModelToHRTF(): void;
  36118. /**
  36119. * Switch the panning model to Equal Power:
  36120. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36122. */
  36123. switchPanningModelToEqualPower(): void;
  36124. /**
  36125. * Connect the sound track to an audio analyser allowing some amazing
  36126. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36128. * @param analyser The analyser to connect to the engine
  36129. */
  36130. connectToAnalyser(analyser: Analyser): void;
  36131. }
  36132. }
  36133. declare module "babylonjs/Audio/audioSceneComponent" {
  36134. import { Sound } from "babylonjs/Audio/sound";
  36135. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36136. import { Nullable } from "babylonjs/types";
  36137. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36138. import { Scene } from "babylonjs/scene";
  36139. import { AbstractScene } from "babylonjs/abstractScene";
  36140. import "babylonjs/Audio/audioEngine";
  36141. module "babylonjs/abstractScene" {
  36142. interface AbstractScene {
  36143. /**
  36144. * The list of sounds used in the scene.
  36145. */
  36146. sounds: Nullable<Array<Sound>>;
  36147. }
  36148. }
  36149. module "babylonjs/scene" {
  36150. interface Scene {
  36151. /**
  36152. * @hidden
  36153. * Backing field
  36154. */
  36155. _mainSoundTrack: SoundTrack;
  36156. /**
  36157. * The main sound track played by the scene.
  36158. * It cotains your primary collection of sounds.
  36159. */
  36160. mainSoundTrack: SoundTrack;
  36161. /**
  36162. * The list of sound tracks added to the scene
  36163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36164. */
  36165. soundTracks: Nullable<Array<SoundTrack>>;
  36166. /**
  36167. * Gets a sound using a given name
  36168. * @param name defines the name to search for
  36169. * @return the found sound or null if not found at all.
  36170. */
  36171. getSoundByName(name: string): Nullable<Sound>;
  36172. /**
  36173. * Gets or sets if audio support is enabled
  36174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36175. */
  36176. audioEnabled: boolean;
  36177. /**
  36178. * Gets or sets if audio will be output to headphones
  36179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36180. */
  36181. headphone: boolean;
  36182. }
  36183. }
  36184. /**
  36185. * Defines the sound scene component responsible to manage any sounds
  36186. * in a given scene.
  36187. */
  36188. export class AudioSceneComponent implements ISceneSerializableComponent {
  36189. /**
  36190. * The component name helpfull to identify the component in the list of scene components.
  36191. */
  36192. readonly name: string;
  36193. /**
  36194. * The scene the component belongs to.
  36195. */
  36196. scene: Scene;
  36197. private _audioEnabled;
  36198. /**
  36199. * Gets whether audio is enabled or not.
  36200. * Please use related enable/disable method to switch state.
  36201. */
  36202. readonly audioEnabled: boolean;
  36203. private _headphone;
  36204. /**
  36205. * Gets whether audio is outputing to headphone or not.
  36206. * Please use the according Switch methods to change output.
  36207. */
  36208. readonly headphone: boolean;
  36209. /**
  36210. * Creates a new instance of the component for the given scene
  36211. * @param scene Defines the scene to register the component in
  36212. */
  36213. constructor(scene: Scene);
  36214. /**
  36215. * Registers the component in a given scene
  36216. */
  36217. register(): void;
  36218. /**
  36219. * Rebuilds the elements related to this component in case of
  36220. * context lost for instance.
  36221. */
  36222. rebuild(): void;
  36223. /**
  36224. * Serializes the component data to the specified json object
  36225. * @param serializationObject The object to serialize to
  36226. */
  36227. serialize(serializationObject: any): void;
  36228. /**
  36229. * Adds all the elements from the container to the scene
  36230. * @param container the container holding the elements
  36231. */
  36232. addFromContainer(container: AbstractScene): void;
  36233. /**
  36234. * Removes all the elements in the container from the scene
  36235. * @param container contains the elements to remove
  36236. * @param dispose if the removed element should be disposed (default: false)
  36237. */
  36238. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36239. /**
  36240. * Disposes the component and the associated ressources.
  36241. */
  36242. dispose(): void;
  36243. /**
  36244. * Disables audio in the associated scene.
  36245. */
  36246. disableAudio(): void;
  36247. /**
  36248. * Enables audio in the associated scene.
  36249. */
  36250. enableAudio(): void;
  36251. /**
  36252. * Switch audio to headphone output.
  36253. */
  36254. switchAudioModeForHeadphones(): void;
  36255. /**
  36256. * Switch audio to normal speakers.
  36257. */
  36258. switchAudioModeForNormalSpeakers(): void;
  36259. private _afterRender;
  36260. }
  36261. }
  36262. declare module "babylonjs/Audio/weightedsound" {
  36263. import { Sound } from "babylonjs/Audio/sound";
  36264. /**
  36265. * Wraps one or more Sound objects and selects one with random weight for playback.
  36266. */
  36267. export class WeightedSound {
  36268. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36269. loop: boolean;
  36270. private _coneInnerAngle;
  36271. private _coneOuterAngle;
  36272. private _volume;
  36273. /** A Sound is currently playing. */
  36274. isPlaying: boolean;
  36275. /** A Sound is currently paused. */
  36276. isPaused: boolean;
  36277. private _sounds;
  36278. private _weights;
  36279. private _currentIndex?;
  36280. /**
  36281. * Creates a new WeightedSound from the list of sounds given.
  36282. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36283. * @param sounds Array of Sounds that will be selected from.
  36284. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36285. */
  36286. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36287. /**
  36288. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36289. */
  36290. /**
  36291. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36292. */
  36293. directionalConeInnerAngle: number;
  36294. /**
  36295. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36296. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36297. */
  36298. /**
  36299. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36300. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36301. */
  36302. directionalConeOuterAngle: number;
  36303. /**
  36304. * Playback volume.
  36305. */
  36306. /**
  36307. * Playback volume.
  36308. */
  36309. volume: number;
  36310. private _onended;
  36311. /**
  36312. * Suspend playback
  36313. */
  36314. pause(): void;
  36315. /**
  36316. * Stop playback
  36317. */
  36318. stop(): void;
  36319. /**
  36320. * Start playback.
  36321. * @param startOffset Position the clip head at a specific time in seconds.
  36322. */
  36323. play(startOffset?: number): void;
  36324. }
  36325. }
  36326. declare module "babylonjs/Audio/index" {
  36327. export * from "babylonjs/Audio/analyser";
  36328. export * from "babylonjs/Audio/audioEngine";
  36329. export * from "babylonjs/Audio/audioSceneComponent";
  36330. export * from "babylonjs/Audio/sound";
  36331. export * from "babylonjs/Audio/soundTrack";
  36332. export * from "babylonjs/Audio/weightedsound";
  36333. }
  36334. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36335. import { Behavior } from "babylonjs/Behaviors/behavior";
  36336. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36337. import { BackEase } from "babylonjs/Animations/easing";
  36338. /**
  36339. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36340. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36341. */
  36342. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36343. /**
  36344. * Gets the name of the behavior.
  36345. */
  36346. readonly name: string;
  36347. /**
  36348. * The easing function used by animations
  36349. */
  36350. static EasingFunction: BackEase;
  36351. /**
  36352. * The easing mode used by animations
  36353. */
  36354. static EasingMode: number;
  36355. /**
  36356. * The duration of the animation, in milliseconds
  36357. */
  36358. transitionDuration: number;
  36359. /**
  36360. * Length of the distance animated by the transition when lower radius is reached
  36361. */
  36362. lowerRadiusTransitionRange: number;
  36363. /**
  36364. * Length of the distance animated by the transition when upper radius is reached
  36365. */
  36366. upperRadiusTransitionRange: number;
  36367. private _autoTransitionRange;
  36368. /**
  36369. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36370. */
  36371. /**
  36372. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36373. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36374. */
  36375. autoTransitionRange: boolean;
  36376. private _attachedCamera;
  36377. private _onAfterCheckInputsObserver;
  36378. private _onMeshTargetChangedObserver;
  36379. /**
  36380. * Initializes the behavior.
  36381. */
  36382. init(): void;
  36383. /**
  36384. * Attaches the behavior to its arc rotate camera.
  36385. * @param camera Defines the camera to attach the behavior to
  36386. */
  36387. attach(camera: ArcRotateCamera): void;
  36388. /**
  36389. * Detaches the behavior from its current arc rotate camera.
  36390. */
  36391. detach(): void;
  36392. private _radiusIsAnimating;
  36393. private _radiusBounceTransition;
  36394. private _animatables;
  36395. private _cachedWheelPrecision;
  36396. /**
  36397. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36398. * @param radiusLimit The limit to check against.
  36399. * @return Bool to indicate if at limit.
  36400. */
  36401. private _isRadiusAtLimit;
  36402. /**
  36403. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36404. * @param radiusDelta The delta by which to animate to. Can be negative.
  36405. */
  36406. private _applyBoundRadiusAnimation;
  36407. /**
  36408. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36409. */
  36410. protected _clearAnimationLocks(): void;
  36411. /**
  36412. * Stops and removes all animations that have been applied to the camera
  36413. */
  36414. stopAllAnimations(): void;
  36415. }
  36416. }
  36417. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36418. import { Behavior } from "babylonjs/Behaviors/behavior";
  36419. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36420. import { ExponentialEase } from "babylonjs/Animations/easing";
  36421. import { Nullable } from "babylonjs/types";
  36422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36423. import { Vector3 } from "babylonjs/Maths/math.vector";
  36424. /**
  36425. * 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.
  36426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36427. */
  36428. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36429. /**
  36430. * Gets the name of the behavior.
  36431. */
  36432. readonly name: string;
  36433. private _mode;
  36434. private _radiusScale;
  36435. private _positionScale;
  36436. private _defaultElevation;
  36437. private _elevationReturnTime;
  36438. private _elevationReturnWaitTime;
  36439. private _zoomStopsAnimation;
  36440. private _framingTime;
  36441. /**
  36442. * The easing function used by animations
  36443. */
  36444. static EasingFunction: ExponentialEase;
  36445. /**
  36446. * The easing mode used by animations
  36447. */
  36448. static EasingMode: number;
  36449. /**
  36450. * Sets the current mode used by the behavior
  36451. */
  36452. /**
  36453. * Gets current mode used by the behavior.
  36454. */
  36455. mode: number;
  36456. /**
  36457. * Sets the scale applied to the radius (1 by default)
  36458. */
  36459. /**
  36460. * Gets the scale applied to the radius
  36461. */
  36462. radiusScale: number;
  36463. /**
  36464. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36465. */
  36466. /**
  36467. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36468. */
  36469. positionScale: number;
  36470. /**
  36471. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36472. * behaviour is triggered, in radians.
  36473. */
  36474. /**
  36475. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36476. * behaviour is triggered, in radians.
  36477. */
  36478. defaultElevation: number;
  36479. /**
  36480. * Sets the time (in milliseconds) taken to return to the default beta position.
  36481. * Negative value indicates camera should not return to default.
  36482. */
  36483. /**
  36484. * Gets the time (in milliseconds) taken to return to the default beta position.
  36485. * Negative value indicates camera should not return to default.
  36486. */
  36487. elevationReturnTime: number;
  36488. /**
  36489. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36490. */
  36491. /**
  36492. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36493. */
  36494. elevationReturnWaitTime: number;
  36495. /**
  36496. * Sets the flag that indicates if user zooming should stop animation.
  36497. */
  36498. /**
  36499. * Gets the flag that indicates if user zooming should stop animation.
  36500. */
  36501. zoomStopsAnimation: boolean;
  36502. /**
  36503. * Sets the transition time when framing the mesh, in milliseconds
  36504. */
  36505. /**
  36506. * Gets the transition time when framing the mesh, in milliseconds
  36507. */
  36508. framingTime: number;
  36509. /**
  36510. * Define if the behavior should automatically change the configured
  36511. * camera limits and sensibilities.
  36512. */
  36513. autoCorrectCameraLimitsAndSensibility: boolean;
  36514. private _onPrePointerObservableObserver;
  36515. private _onAfterCheckInputsObserver;
  36516. private _onMeshTargetChangedObserver;
  36517. private _attachedCamera;
  36518. private _isPointerDown;
  36519. private _lastInteractionTime;
  36520. /**
  36521. * Initializes the behavior.
  36522. */
  36523. init(): void;
  36524. /**
  36525. * Attaches the behavior to its arc rotate camera.
  36526. * @param camera Defines the camera to attach the behavior to
  36527. */
  36528. attach(camera: ArcRotateCamera): void;
  36529. /**
  36530. * Detaches the behavior from its current arc rotate camera.
  36531. */
  36532. detach(): void;
  36533. private _animatables;
  36534. private _betaIsAnimating;
  36535. private _betaTransition;
  36536. private _radiusTransition;
  36537. private _vectorTransition;
  36538. /**
  36539. * Targets the given mesh and updates zoom level accordingly.
  36540. * @param mesh The mesh to target.
  36541. * @param radius Optional. If a cached radius position already exists, overrides default.
  36542. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36543. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36544. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36545. */
  36546. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36547. /**
  36548. * Targets the given mesh with its children and updates zoom level accordingly.
  36549. * @param mesh The mesh to target.
  36550. * @param radius Optional. If a cached radius position already exists, overrides default.
  36551. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36552. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36553. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36554. */
  36555. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36556. /**
  36557. * Targets the given meshes with their children and updates zoom level accordingly.
  36558. * @param meshes The mesh to target.
  36559. * @param radius Optional. If a cached radius position already exists, overrides default.
  36560. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36561. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36562. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36563. */
  36564. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36565. /**
  36566. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36567. * @param minimumWorld Determines the smaller position of the bounding box extend
  36568. * @param maximumWorld Determines the bigger position of the bounding box extend
  36569. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36570. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36571. */
  36572. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36573. /**
  36574. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36575. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36576. * frustum width.
  36577. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36578. * to fully enclose the mesh in the viewing frustum.
  36579. */
  36580. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36581. /**
  36582. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36583. * is automatically returned to its default position (expected to be above ground plane).
  36584. */
  36585. private _maintainCameraAboveGround;
  36586. /**
  36587. * Returns the frustum slope based on the canvas ratio and camera FOV
  36588. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36589. */
  36590. private _getFrustumSlope;
  36591. /**
  36592. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36593. */
  36594. private _clearAnimationLocks;
  36595. /**
  36596. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36597. */
  36598. private _applyUserInteraction;
  36599. /**
  36600. * Stops and removes all animations that have been applied to the camera
  36601. */
  36602. stopAllAnimations(): void;
  36603. /**
  36604. * Gets a value indicating if the user is moving the camera
  36605. */
  36606. readonly isUserIsMoving: boolean;
  36607. /**
  36608. * The camera can move all the way towards the mesh.
  36609. */
  36610. static IgnoreBoundsSizeMode: number;
  36611. /**
  36612. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36613. */
  36614. static FitFrustumSidesMode: number;
  36615. }
  36616. }
  36617. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36618. import { Nullable } from "babylonjs/types";
  36619. import { Camera } from "babylonjs/Cameras/camera";
  36620. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36621. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36622. /**
  36623. * Base class for Camera Pointer Inputs.
  36624. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36625. * for example usage.
  36626. */
  36627. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36628. /**
  36629. * Defines the camera the input is attached to.
  36630. */
  36631. abstract camera: Camera;
  36632. /**
  36633. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36634. */
  36635. protected _altKey: boolean;
  36636. protected _ctrlKey: boolean;
  36637. protected _metaKey: boolean;
  36638. protected _shiftKey: boolean;
  36639. /**
  36640. * Which mouse buttons were pressed at time of last mouse event.
  36641. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36642. */
  36643. protected _buttonsPressed: number;
  36644. /**
  36645. * Defines the buttons associated with the input to handle camera move.
  36646. */
  36647. buttons: number[];
  36648. /**
  36649. * Attach the input controls to a specific dom element to get the input from.
  36650. * @param element Defines the element the controls should be listened from
  36651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36652. */
  36653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36654. /**
  36655. * Detach the current controls from the specified dom element.
  36656. * @param element Defines the element to stop listening the inputs from
  36657. */
  36658. detachControl(element: Nullable<HTMLElement>): void;
  36659. /**
  36660. * Gets the class name of the current input.
  36661. * @returns the class name
  36662. */
  36663. getClassName(): string;
  36664. /**
  36665. * Get the friendly name associated with the input class.
  36666. * @returns the input friendly name
  36667. */
  36668. getSimpleName(): string;
  36669. /**
  36670. * Called on pointer POINTERDOUBLETAP event.
  36671. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36672. */
  36673. protected onDoubleTap(type: string): void;
  36674. /**
  36675. * Called on pointer POINTERMOVE event if only a single touch is active.
  36676. * Override this method to provide functionality.
  36677. */
  36678. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36679. /**
  36680. * Called on pointer POINTERMOVE event if multiple touches are active.
  36681. * Override this method to provide functionality.
  36682. */
  36683. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36684. /**
  36685. * Called on JS contextmenu event.
  36686. * Override this method to provide functionality.
  36687. */
  36688. protected onContextMenu(evt: PointerEvent): void;
  36689. /**
  36690. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36691. * press.
  36692. * Override this method to provide functionality.
  36693. */
  36694. protected onButtonDown(evt: PointerEvent): void;
  36695. /**
  36696. * Called each time a new POINTERUP event occurs. Ie, for each button
  36697. * release.
  36698. * Override this method to provide functionality.
  36699. */
  36700. protected onButtonUp(evt: PointerEvent): void;
  36701. /**
  36702. * Called when window becomes inactive.
  36703. * Override this method to provide functionality.
  36704. */
  36705. protected onLostFocus(): void;
  36706. private _pointerInput;
  36707. private _observer;
  36708. private _onLostFocus;
  36709. private pointA;
  36710. private pointB;
  36711. }
  36712. }
  36713. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36714. import { Nullable } from "babylonjs/types";
  36715. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36716. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36717. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36718. /**
  36719. * Manage the pointers inputs to control an arc rotate camera.
  36720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36721. */
  36722. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36723. /**
  36724. * Defines the camera the input is attached to.
  36725. */
  36726. camera: ArcRotateCamera;
  36727. /**
  36728. * Gets the class name of the current input.
  36729. * @returns the class name
  36730. */
  36731. getClassName(): string;
  36732. /**
  36733. * Defines the buttons associated with the input to handle camera move.
  36734. */
  36735. buttons: number[];
  36736. /**
  36737. * Defines the pointer angular sensibility along the X axis or how fast is
  36738. * the camera rotating.
  36739. */
  36740. angularSensibilityX: number;
  36741. /**
  36742. * Defines the pointer angular sensibility along the Y axis or how fast is
  36743. * the camera rotating.
  36744. */
  36745. angularSensibilityY: number;
  36746. /**
  36747. * Defines the pointer pinch precision or how fast is the camera zooming.
  36748. */
  36749. pinchPrecision: number;
  36750. /**
  36751. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36752. * from 0.
  36753. * It defines the percentage of current camera.radius to use as delta when
  36754. * pinch zoom is used.
  36755. */
  36756. pinchDeltaPercentage: number;
  36757. /**
  36758. * Defines the pointer panning sensibility or how fast is the camera moving.
  36759. */
  36760. panningSensibility: number;
  36761. /**
  36762. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36763. */
  36764. multiTouchPanning: boolean;
  36765. /**
  36766. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36767. * zoom (pinch) through multitouch.
  36768. */
  36769. multiTouchPanAndZoom: boolean;
  36770. /**
  36771. * Revers pinch action direction.
  36772. */
  36773. pinchInwards: boolean;
  36774. private _isPanClick;
  36775. private _twoFingerActivityCount;
  36776. private _isPinching;
  36777. /**
  36778. * Called on pointer POINTERMOVE event if only a single touch is active.
  36779. */
  36780. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36781. /**
  36782. * Called on pointer POINTERDOUBLETAP event.
  36783. */
  36784. protected onDoubleTap(type: string): void;
  36785. /**
  36786. * Called on pointer POINTERMOVE event if multiple touches are active.
  36787. */
  36788. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36789. /**
  36790. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36791. * press.
  36792. */
  36793. protected onButtonDown(evt: PointerEvent): void;
  36794. /**
  36795. * Called each time a new POINTERUP event occurs. Ie, for each button
  36796. * release.
  36797. */
  36798. protected onButtonUp(evt: PointerEvent): void;
  36799. /**
  36800. * Called when window becomes inactive.
  36801. */
  36802. protected onLostFocus(): void;
  36803. }
  36804. }
  36805. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36806. import { Nullable } from "babylonjs/types";
  36807. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36808. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36809. /**
  36810. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36812. */
  36813. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36814. /**
  36815. * Defines the camera the input is attached to.
  36816. */
  36817. camera: ArcRotateCamera;
  36818. /**
  36819. * Defines the list of key codes associated with the up action (increase alpha)
  36820. */
  36821. keysUp: number[];
  36822. /**
  36823. * Defines the list of key codes associated with the down action (decrease alpha)
  36824. */
  36825. keysDown: number[];
  36826. /**
  36827. * Defines the list of key codes associated with the left action (increase beta)
  36828. */
  36829. keysLeft: number[];
  36830. /**
  36831. * Defines the list of key codes associated with the right action (decrease beta)
  36832. */
  36833. keysRight: number[];
  36834. /**
  36835. * Defines the list of key codes associated with the reset action.
  36836. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36837. */
  36838. keysReset: number[];
  36839. /**
  36840. * Defines the panning sensibility of the inputs.
  36841. * (How fast is the camera paning)
  36842. */
  36843. panningSensibility: number;
  36844. /**
  36845. * Defines the zooming sensibility of the inputs.
  36846. * (How fast is the camera zooming)
  36847. */
  36848. zoomingSensibility: number;
  36849. /**
  36850. * Defines wether maintaining the alt key down switch the movement mode from
  36851. * orientation to zoom.
  36852. */
  36853. useAltToZoom: boolean;
  36854. /**
  36855. * Rotation speed of the camera
  36856. */
  36857. angularSpeed: number;
  36858. private _keys;
  36859. private _ctrlPressed;
  36860. private _altPressed;
  36861. private _onCanvasBlurObserver;
  36862. private _onKeyboardObserver;
  36863. private _engine;
  36864. private _scene;
  36865. /**
  36866. * Attach the input controls to a specific dom element to get the input from.
  36867. * @param element Defines the element the controls should be listened from
  36868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36869. */
  36870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36871. /**
  36872. * Detach the current controls from the specified dom element.
  36873. * @param element Defines the element to stop listening the inputs from
  36874. */
  36875. detachControl(element: Nullable<HTMLElement>): void;
  36876. /**
  36877. * Update the current camera state depending on the inputs that have been used this frame.
  36878. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36879. */
  36880. checkInputs(): void;
  36881. /**
  36882. * Gets the class name of the current intput.
  36883. * @returns the class name
  36884. */
  36885. getClassName(): string;
  36886. /**
  36887. * Get the friendly name associated with the input class.
  36888. * @returns the input friendly name
  36889. */
  36890. getSimpleName(): string;
  36891. }
  36892. }
  36893. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36894. import { Nullable } from "babylonjs/types";
  36895. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36896. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36897. /**
  36898. * Manage the mouse wheel inputs to control an arc rotate camera.
  36899. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36900. */
  36901. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36902. /**
  36903. * Defines the camera the input is attached to.
  36904. */
  36905. camera: ArcRotateCamera;
  36906. /**
  36907. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36908. */
  36909. wheelPrecision: number;
  36910. /**
  36911. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36912. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36913. */
  36914. wheelDeltaPercentage: number;
  36915. private _wheel;
  36916. private _observer;
  36917. private computeDeltaFromMouseWheelLegacyEvent;
  36918. /**
  36919. * Attach the input controls to a specific dom element to get the input from.
  36920. * @param element Defines the element the controls should be listened from
  36921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36922. */
  36923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36924. /**
  36925. * Detach the current controls from the specified dom element.
  36926. * @param element Defines the element to stop listening the inputs from
  36927. */
  36928. detachControl(element: Nullable<HTMLElement>): void;
  36929. /**
  36930. * Gets the class name of the current intput.
  36931. * @returns the class name
  36932. */
  36933. getClassName(): string;
  36934. /**
  36935. * Get the friendly name associated with the input class.
  36936. * @returns the input friendly name
  36937. */
  36938. getSimpleName(): string;
  36939. }
  36940. }
  36941. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36942. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36943. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36944. /**
  36945. * Default Inputs manager for the ArcRotateCamera.
  36946. * It groups all the default supported inputs for ease of use.
  36947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36948. */
  36949. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36950. /**
  36951. * Instantiates a new ArcRotateCameraInputsManager.
  36952. * @param camera Defines the camera the inputs belong to
  36953. */
  36954. constructor(camera: ArcRotateCamera);
  36955. /**
  36956. * Add mouse wheel input support to the input manager.
  36957. * @returns the current input manager
  36958. */
  36959. addMouseWheel(): ArcRotateCameraInputsManager;
  36960. /**
  36961. * Add pointers input support to the input manager.
  36962. * @returns the current input manager
  36963. */
  36964. addPointers(): ArcRotateCameraInputsManager;
  36965. /**
  36966. * Add keyboard input support to the input manager.
  36967. * @returns the current input manager
  36968. */
  36969. addKeyboard(): ArcRotateCameraInputsManager;
  36970. }
  36971. }
  36972. declare module "babylonjs/Cameras/arcRotateCamera" {
  36973. import { Observable } from "babylonjs/Misc/observable";
  36974. import { Nullable } from "babylonjs/types";
  36975. import { Scene } from "babylonjs/scene";
  36976. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36978. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36979. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36980. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36981. import { Camera } from "babylonjs/Cameras/camera";
  36982. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36983. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36984. import { Collider } from "babylonjs/Collisions/collider";
  36985. /**
  36986. * This represents an orbital type of camera.
  36987. *
  36988. * 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.
  36989. * 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.
  36990. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36991. */
  36992. export class ArcRotateCamera extends TargetCamera {
  36993. /**
  36994. * Defines the rotation angle of the camera along the longitudinal axis.
  36995. */
  36996. alpha: number;
  36997. /**
  36998. * Defines the rotation angle of the camera along the latitudinal axis.
  36999. */
  37000. beta: number;
  37001. /**
  37002. * Defines the radius of the camera from it s target point.
  37003. */
  37004. radius: number;
  37005. protected _target: Vector3;
  37006. protected _targetHost: Nullable<AbstractMesh>;
  37007. /**
  37008. * Defines the target point of the camera.
  37009. * The camera looks towards it form the radius distance.
  37010. */
  37011. target: Vector3;
  37012. /**
  37013. * Define the current local position of the camera in the scene
  37014. */
  37015. position: Vector3;
  37016. protected _upVector: Vector3;
  37017. protected _upToYMatrix: Matrix;
  37018. protected _YToUpMatrix: Matrix;
  37019. /**
  37020. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37021. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37022. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37023. */
  37024. upVector: Vector3;
  37025. /**
  37026. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37027. */
  37028. setMatUp(): void;
  37029. /**
  37030. * Current inertia value on the longitudinal axis.
  37031. * The bigger this number the longer it will take for the camera to stop.
  37032. */
  37033. inertialAlphaOffset: number;
  37034. /**
  37035. * Current inertia value on the latitudinal axis.
  37036. * The bigger this number the longer it will take for the camera to stop.
  37037. */
  37038. inertialBetaOffset: number;
  37039. /**
  37040. * Current inertia value on the radius axis.
  37041. * The bigger this number the longer it will take for the camera to stop.
  37042. */
  37043. inertialRadiusOffset: number;
  37044. /**
  37045. * Minimum allowed angle on the longitudinal axis.
  37046. * This can help limiting how the Camera is able to move in the scene.
  37047. */
  37048. lowerAlphaLimit: Nullable<number>;
  37049. /**
  37050. * Maximum allowed angle on the longitudinal axis.
  37051. * This can help limiting how the Camera is able to move in the scene.
  37052. */
  37053. upperAlphaLimit: Nullable<number>;
  37054. /**
  37055. * Minimum allowed angle on the latitudinal axis.
  37056. * This can help limiting how the Camera is able to move in the scene.
  37057. */
  37058. lowerBetaLimit: number;
  37059. /**
  37060. * Maximum allowed angle on the latitudinal axis.
  37061. * This can help limiting how the Camera is able to move in the scene.
  37062. */
  37063. upperBetaLimit: number;
  37064. /**
  37065. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37066. * This can help limiting how the Camera is able to move in the scene.
  37067. */
  37068. lowerRadiusLimit: Nullable<number>;
  37069. /**
  37070. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37071. * This can help limiting how the Camera is able to move in the scene.
  37072. */
  37073. upperRadiusLimit: Nullable<number>;
  37074. /**
  37075. * Defines the current inertia value used during panning of the camera along the X axis.
  37076. */
  37077. inertialPanningX: number;
  37078. /**
  37079. * Defines the current inertia value used during panning of the camera along the Y axis.
  37080. */
  37081. inertialPanningY: number;
  37082. /**
  37083. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37084. * Basically if your fingers moves away from more than this distance you will be considered
  37085. * in pinch mode.
  37086. */
  37087. pinchToPanMaxDistance: number;
  37088. /**
  37089. * Defines the maximum distance the camera can pan.
  37090. * This could help keeping the cammera always in your scene.
  37091. */
  37092. panningDistanceLimit: Nullable<number>;
  37093. /**
  37094. * Defines the target of the camera before paning.
  37095. */
  37096. panningOriginTarget: Vector3;
  37097. /**
  37098. * Defines the value of the inertia used during panning.
  37099. * 0 would mean stop inertia and one would mean no decelleration at all.
  37100. */
  37101. panningInertia: number;
  37102. /**
  37103. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37104. */
  37105. angularSensibilityX: number;
  37106. /**
  37107. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37108. */
  37109. angularSensibilityY: number;
  37110. /**
  37111. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37112. */
  37113. pinchPrecision: number;
  37114. /**
  37115. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37116. * It will be used instead of pinchDeltaPrecision if different from 0.
  37117. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37118. */
  37119. pinchDeltaPercentage: number;
  37120. /**
  37121. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37122. */
  37123. panningSensibility: number;
  37124. /**
  37125. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37126. */
  37127. keysUp: number[];
  37128. /**
  37129. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37130. */
  37131. keysDown: number[];
  37132. /**
  37133. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37134. */
  37135. keysLeft: number[];
  37136. /**
  37137. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37138. */
  37139. keysRight: number[];
  37140. /**
  37141. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37142. */
  37143. wheelPrecision: number;
  37144. /**
  37145. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37146. * It will be used instead of pinchDeltaPrecision if different from 0.
  37147. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37148. */
  37149. wheelDeltaPercentage: number;
  37150. /**
  37151. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37152. */
  37153. zoomOnFactor: number;
  37154. /**
  37155. * Defines a screen offset for the camera position.
  37156. */
  37157. targetScreenOffset: Vector2;
  37158. /**
  37159. * Allows the camera to be completely reversed.
  37160. * If false the camera can not arrive upside down.
  37161. */
  37162. allowUpsideDown: boolean;
  37163. /**
  37164. * Define if double tap/click is used to restore the previously saved state of the camera.
  37165. */
  37166. useInputToRestoreState: boolean;
  37167. /** @hidden */
  37168. _viewMatrix: Matrix;
  37169. /** @hidden */
  37170. _useCtrlForPanning: boolean;
  37171. /** @hidden */
  37172. _panningMouseButton: number;
  37173. /**
  37174. * Defines the input associated to the camera.
  37175. */
  37176. inputs: ArcRotateCameraInputsManager;
  37177. /** @hidden */
  37178. _reset: () => void;
  37179. /**
  37180. * Defines the allowed panning axis.
  37181. */
  37182. panningAxis: Vector3;
  37183. protected _localDirection: Vector3;
  37184. protected _transformedDirection: Vector3;
  37185. private _bouncingBehavior;
  37186. /**
  37187. * Gets the bouncing behavior of the camera if it has been enabled.
  37188. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37189. */
  37190. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37191. /**
  37192. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37193. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37194. */
  37195. useBouncingBehavior: boolean;
  37196. private _framingBehavior;
  37197. /**
  37198. * Gets the framing behavior of the camera if it has been enabled.
  37199. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37200. */
  37201. readonly framingBehavior: Nullable<FramingBehavior>;
  37202. /**
  37203. * Defines if the framing behavior of the camera is enabled on the camera.
  37204. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37205. */
  37206. useFramingBehavior: boolean;
  37207. private _autoRotationBehavior;
  37208. /**
  37209. * Gets the auto rotation behavior of the camera if it has been enabled.
  37210. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37211. */
  37212. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37213. /**
  37214. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37216. */
  37217. useAutoRotationBehavior: boolean;
  37218. /**
  37219. * Observable triggered when the mesh target has been changed on the camera.
  37220. */
  37221. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37222. /**
  37223. * Event raised when the camera is colliding with a mesh.
  37224. */
  37225. onCollide: (collidedMesh: AbstractMesh) => void;
  37226. /**
  37227. * Defines whether the camera should check collision with the objects oh the scene.
  37228. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37229. */
  37230. checkCollisions: boolean;
  37231. /**
  37232. * Defines the collision radius of the camera.
  37233. * This simulates a sphere around the camera.
  37234. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37235. */
  37236. collisionRadius: Vector3;
  37237. protected _collider: Collider;
  37238. protected _previousPosition: Vector3;
  37239. protected _collisionVelocity: Vector3;
  37240. protected _newPosition: Vector3;
  37241. protected _previousAlpha: number;
  37242. protected _previousBeta: number;
  37243. protected _previousRadius: number;
  37244. protected _collisionTriggered: boolean;
  37245. protected _targetBoundingCenter: Nullable<Vector3>;
  37246. private _computationVector;
  37247. /**
  37248. * Instantiates a new ArcRotateCamera in a given scene
  37249. * @param name Defines the name of the camera
  37250. * @param alpha Defines the camera rotation along the logitudinal axis
  37251. * @param beta Defines the camera rotation along the latitudinal axis
  37252. * @param radius Defines the camera distance from its target
  37253. * @param target Defines the camera target
  37254. * @param scene Defines the scene the camera belongs to
  37255. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37256. */
  37257. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37258. /** @hidden */
  37259. _initCache(): void;
  37260. /** @hidden */
  37261. _updateCache(ignoreParentClass?: boolean): void;
  37262. protected _getTargetPosition(): Vector3;
  37263. private _storedAlpha;
  37264. private _storedBeta;
  37265. private _storedRadius;
  37266. private _storedTarget;
  37267. /**
  37268. * Stores the current state of the camera (alpha, beta, radius and target)
  37269. * @returns the camera itself
  37270. */
  37271. storeState(): Camera;
  37272. /**
  37273. * @hidden
  37274. * Restored camera state. You must call storeState() first
  37275. */
  37276. _restoreStateValues(): boolean;
  37277. /** @hidden */
  37278. _isSynchronizedViewMatrix(): boolean;
  37279. /**
  37280. * Attached controls to the current camera.
  37281. * @param element Defines the element the controls should be listened from
  37282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37283. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37284. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37285. */
  37286. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37287. /**
  37288. * Detach the current controls from the camera.
  37289. * The camera will stop reacting to inputs.
  37290. * @param element Defines the element to stop listening the inputs from
  37291. */
  37292. detachControl(element: HTMLElement): void;
  37293. /** @hidden */
  37294. _checkInputs(): void;
  37295. protected _checkLimits(): void;
  37296. /**
  37297. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37298. */
  37299. rebuildAnglesAndRadius(): void;
  37300. /**
  37301. * Use a position to define the current camera related information like aplha, beta and radius
  37302. * @param position Defines the position to set the camera at
  37303. */
  37304. setPosition(position: Vector3): void;
  37305. /**
  37306. * Defines the target the camera should look at.
  37307. * This will automatically adapt alpha beta and radius to fit within the new target.
  37308. * @param target Defines the new target as a Vector or a mesh
  37309. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37310. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37311. */
  37312. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37313. /** @hidden */
  37314. _getViewMatrix(): Matrix;
  37315. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37316. /**
  37317. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37318. * @param meshes Defines the mesh to zoom on
  37319. * @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)
  37320. */
  37321. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37322. /**
  37323. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37324. * The target will be changed but the radius
  37325. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37326. * @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)
  37327. */
  37328. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37329. min: Vector3;
  37330. max: Vector3;
  37331. distance: number;
  37332. }, doNotUpdateMaxZ?: boolean): void;
  37333. /**
  37334. * @override
  37335. * Override Camera.createRigCamera
  37336. */
  37337. createRigCamera(name: string, cameraIndex: number): Camera;
  37338. /**
  37339. * @hidden
  37340. * @override
  37341. * Override Camera._updateRigCameras
  37342. */
  37343. _updateRigCameras(): void;
  37344. /**
  37345. * Destroy the camera and release the current resources hold by it.
  37346. */
  37347. dispose(): void;
  37348. /**
  37349. * Gets the current object class name.
  37350. * @return the class name
  37351. */
  37352. getClassName(): string;
  37353. }
  37354. }
  37355. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37356. import { Behavior } from "babylonjs/Behaviors/behavior";
  37357. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37358. /**
  37359. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37360. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37361. */
  37362. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37363. /**
  37364. * Gets the name of the behavior.
  37365. */
  37366. readonly name: string;
  37367. private _zoomStopsAnimation;
  37368. private _idleRotationSpeed;
  37369. private _idleRotationWaitTime;
  37370. private _idleRotationSpinupTime;
  37371. /**
  37372. * Sets the flag that indicates if user zooming should stop animation.
  37373. */
  37374. /**
  37375. * Gets the flag that indicates if user zooming should stop animation.
  37376. */
  37377. zoomStopsAnimation: boolean;
  37378. /**
  37379. * Sets the default speed at which the camera rotates around the model.
  37380. */
  37381. /**
  37382. * Gets the default speed at which the camera rotates around the model.
  37383. */
  37384. idleRotationSpeed: number;
  37385. /**
  37386. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37387. */
  37388. /**
  37389. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37390. */
  37391. idleRotationWaitTime: number;
  37392. /**
  37393. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37394. */
  37395. /**
  37396. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37397. */
  37398. idleRotationSpinupTime: number;
  37399. /**
  37400. * Gets a value indicating if the camera is currently rotating because of this behavior
  37401. */
  37402. readonly rotationInProgress: boolean;
  37403. private _onPrePointerObservableObserver;
  37404. private _onAfterCheckInputsObserver;
  37405. private _attachedCamera;
  37406. private _isPointerDown;
  37407. private _lastFrameTime;
  37408. private _lastInteractionTime;
  37409. private _cameraRotationSpeed;
  37410. /**
  37411. * Initializes the behavior.
  37412. */
  37413. init(): void;
  37414. /**
  37415. * Attaches the behavior to its arc rotate camera.
  37416. * @param camera Defines the camera to attach the behavior to
  37417. */
  37418. attach(camera: ArcRotateCamera): void;
  37419. /**
  37420. * Detaches the behavior from its current arc rotate camera.
  37421. */
  37422. detach(): void;
  37423. /**
  37424. * Returns true if user is scrolling.
  37425. * @return true if user is scrolling.
  37426. */
  37427. private _userIsZooming;
  37428. private _lastFrameRadius;
  37429. private _shouldAnimationStopForInteraction;
  37430. /**
  37431. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37432. */
  37433. private _applyUserInteraction;
  37434. private _userIsMoving;
  37435. }
  37436. }
  37437. declare module "babylonjs/Behaviors/Cameras/index" {
  37438. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37439. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37440. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37441. }
  37442. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37443. import { Mesh } from "babylonjs/Meshes/mesh";
  37444. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37445. import { Behavior } from "babylonjs/Behaviors/behavior";
  37446. /**
  37447. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37448. */
  37449. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37450. private ui;
  37451. /**
  37452. * The name of the behavior
  37453. */
  37454. name: string;
  37455. /**
  37456. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37457. */
  37458. distanceAwayFromFace: number;
  37459. /**
  37460. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37461. */
  37462. distanceAwayFromBottomOfFace: number;
  37463. private _faceVectors;
  37464. private _target;
  37465. private _scene;
  37466. private _onRenderObserver;
  37467. private _tmpMatrix;
  37468. private _tmpVector;
  37469. /**
  37470. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37471. * @param ui The transform node that should be attched to the mesh
  37472. */
  37473. constructor(ui: TransformNode);
  37474. /**
  37475. * Initializes the behavior
  37476. */
  37477. init(): void;
  37478. private _closestFace;
  37479. private _zeroVector;
  37480. private _lookAtTmpMatrix;
  37481. private _lookAtToRef;
  37482. /**
  37483. * Attaches the AttachToBoxBehavior to the passed in mesh
  37484. * @param target The mesh that the specified node will be attached to
  37485. */
  37486. attach(target: Mesh): void;
  37487. /**
  37488. * Detaches the behavior from the mesh
  37489. */
  37490. detach(): void;
  37491. }
  37492. }
  37493. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37494. import { Behavior } from "babylonjs/Behaviors/behavior";
  37495. import { Mesh } from "babylonjs/Meshes/mesh";
  37496. /**
  37497. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37498. */
  37499. export class FadeInOutBehavior implements Behavior<Mesh> {
  37500. /**
  37501. * Time in milliseconds to delay before fading in (Default: 0)
  37502. */
  37503. delay: number;
  37504. /**
  37505. * Time in milliseconds for the mesh to fade in (Default: 300)
  37506. */
  37507. fadeInTime: number;
  37508. private _millisecondsPerFrame;
  37509. private _hovered;
  37510. private _hoverValue;
  37511. private _ownerNode;
  37512. /**
  37513. * Instatiates the FadeInOutBehavior
  37514. */
  37515. constructor();
  37516. /**
  37517. * The name of the behavior
  37518. */
  37519. readonly name: string;
  37520. /**
  37521. * Initializes the behavior
  37522. */
  37523. init(): void;
  37524. /**
  37525. * Attaches the fade behavior on the passed in mesh
  37526. * @param ownerNode The mesh that will be faded in/out once attached
  37527. */
  37528. attach(ownerNode: Mesh): void;
  37529. /**
  37530. * Detaches the behavior from the mesh
  37531. */
  37532. detach(): void;
  37533. /**
  37534. * Triggers the mesh to begin fading in or out
  37535. * @param value if the object should fade in or out (true to fade in)
  37536. */
  37537. fadeIn(value: boolean): void;
  37538. private _update;
  37539. private _setAllVisibility;
  37540. }
  37541. }
  37542. declare module "babylonjs/Misc/pivotTools" {
  37543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37544. /**
  37545. * Class containing a set of static utilities functions for managing Pivots
  37546. * @hidden
  37547. */
  37548. export class PivotTools {
  37549. private static _PivotCached;
  37550. private static _OldPivotPoint;
  37551. private static _PivotTranslation;
  37552. private static _PivotTmpVector;
  37553. /** @hidden */
  37554. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37555. /** @hidden */
  37556. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37557. }
  37558. }
  37559. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37560. import { Scene } from "babylonjs/scene";
  37561. import { Vector4 } from "babylonjs/Maths/math.vector";
  37562. import { Mesh } from "babylonjs/Meshes/mesh";
  37563. import { Nullable } from "babylonjs/types";
  37564. import { Plane } from "babylonjs/Maths/math.plane";
  37565. /**
  37566. * Class containing static functions to help procedurally build meshes
  37567. */
  37568. export class PlaneBuilder {
  37569. /**
  37570. * Creates a plane mesh
  37571. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37572. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37573. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37577. * @param name defines the name of the mesh
  37578. * @param options defines the options used to create the mesh
  37579. * @param scene defines the hosting scene
  37580. * @returns the plane mesh
  37581. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37582. */
  37583. static CreatePlane(name: string, options: {
  37584. size?: number;
  37585. width?: number;
  37586. height?: number;
  37587. sideOrientation?: number;
  37588. frontUVs?: Vector4;
  37589. backUVs?: Vector4;
  37590. updatable?: boolean;
  37591. sourcePlane?: Plane;
  37592. }, scene?: Nullable<Scene>): Mesh;
  37593. }
  37594. }
  37595. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37596. import { Behavior } from "babylonjs/Behaviors/behavior";
  37597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37598. import { Observable } from "babylonjs/Misc/observable";
  37599. import { Vector3 } from "babylonjs/Maths/math.vector";
  37600. import { Ray } from "babylonjs/Culling/ray";
  37601. import "babylonjs/Meshes/Builders/planeBuilder";
  37602. /**
  37603. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37604. */
  37605. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37606. private static _AnyMouseID;
  37607. /**
  37608. * Abstract mesh the behavior is set on
  37609. */
  37610. attachedNode: AbstractMesh;
  37611. private _dragPlane;
  37612. private _scene;
  37613. private _pointerObserver;
  37614. private _beforeRenderObserver;
  37615. private static _planeScene;
  37616. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37617. /**
  37618. * 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)
  37619. */
  37620. maxDragAngle: number;
  37621. /**
  37622. * @hidden
  37623. */
  37624. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37625. /**
  37626. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37627. */
  37628. currentDraggingPointerID: number;
  37629. /**
  37630. * The last position where the pointer hit the drag plane in world space
  37631. */
  37632. lastDragPosition: Vector3;
  37633. /**
  37634. * If the behavior is currently in a dragging state
  37635. */
  37636. dragging: boolean;
  37637. /**
  37638. * 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)
  37639. */
  37640. dragDeltaRatio: number;
  37641. /**
  37642. * If the drag plane orientation should be updated during the dragging (Default: true)
  37643. */
  37644. updateDragPlane: boolean;
  37645. private _debugMode;
  37646. private _moving;
  37647. /**
  37648. * Fires each time the attached mesh is dragged with the pointer
  37649. * * delta between last drag position and current drag position in world space
  37650. * * dragDistance along the drag axis
  37651. * * dragPlaneNormal normal of the current drag plane used during the drag
  37652. * * dragPlanePoint in world space where the drag intersects the drag plane
  37653. */
  37654. onDragObservable: Observable<{
  37655. delta: Vector3;
  37656. dragPlanePoint: Vector3;
  37657. dragPlaneNormal: Vector3;
  37658. dragDistance: number;
  37659. pointerId: number;
  37660. }>;
  37661. /**
  37662. * Fires each time a drag begins (eg. mouse down on mesh)
  37663. */
  37664. onDragStartObservable: Observable<{
  37665. dragPlanePoint: Vector3;
  37666. pointerId: number;
  37667. }>;
  37668. /**
  37669. * Fires each time a drag ends (eg. mouse release after drag)
  37670. */
  37671. onDragEndObservable: Observable<{
  37672. dragPlanePoint: Vector3;
  37673. pointerId: number;
  37674. }>;
  37675. /**
  37676. * If the attached mesh should be moved when dragged
  37677. */
  37678. moveAttached: boolean;
  37679. /**
  37680. * If the drag behavior will react to drag events (Default: true)
  37681. */
  37682. enabled: boolean;
  37683. /**
  37684. * If pointer events should start and release the drag (Default: true)
  37685. */
  37686. startAndReleaseDragOnPointerEvents: boolean;
  37687. /**
  37688. * If camera controls should be detached during the drag
  37689. */
  37690. detachCameraControls: boolean;
  37691. /**
  37692. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37693. */
  37694. useObjectOrienationForDragging: boolean;
  37695. private _options;
  37696. /**
  37697. * Creates a pointer drag behavior that can be attached to a mesh
  37698. * @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)
  37699. */
  37700. constructor(options?: {
  37701. dragAxis?: Vector3;
  37702. dragPlaneNormal?: Vector3;
  37703. });
  37704. /**
  37705. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37706. */
  37707. validateDrag: (targetPosition: Vector3) => boolean;
  37708. /**
  37709. * The name of the behavior
  37710. */
  37711. readonly name: string;
  37712. /**
  37713. * Initializes the behavior
  37714. */
  37715. init(): void;
  37716. private _tmpVector;
  37717. private _alternatePickedPoint;
  37718. private _worldDragAxis;
  37719. private _targetPosition;
  37720. private _attachedElement;
  37721. /**
  37722. * Attaches the drag behavior the passed in mesh
  37723. * @param ownerNode The mesh that will be dragged around once attached
  37724. */
  37725. attach(ownerNode: AbstractMesh): void;
  37726. /**
  37727. * Force relase the drag action by code.
  37728. */
  37729. releaseDrag(): void;
  37730. private _startDragRay;
  37731. private _lastPointerRay;
  37732. /**
  37733. * Simulates the start of a pointer drag event on the behavior
  37734. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37735. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37736. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37737. */
  37738. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37739. private _startDrag;
  37740. private _dragDelta;
  37741. private _moveDrag;
  37742. private _pickWithRayOnDragPlane;
  37743. private _pointA;
  37744. private _pointB;
  37745. private _pointC;
  37746. private _lineA;
  37747. private _lineB;
  37748. private _localAxis;
  37749. private _lookAt;
  37750. private _updateDragPlanePosition;
  37751. /**
  37752. * Detaches the behavior from the mesh
  37753. */
  37754. detach(): void;
  37755. }
  37756. }
  37757. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37758. import { Mesh } from "babylonjs/Meshes/mesh";
  37759. import { Behavior } from "babylonjs/Behaviors/behavior";
  37760. /**
  37761. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37762. */
  37763. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37764. private _dragBehaviorA;
  37765. private _dragBehaviorB;
  37766. private _startDistance;
  37767. private _initialScale;
  37768. private _targetScale;
  37769. private _ownerNode;
  37770. private _sceneRenderObserver;
  37771. /**
  37772. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37773. */
  37774. constructor();
  37775. /**
  37776. * The name of the behavior
  37777. */
  37778. readonly name: string;
  37779. /**
  37780. * Initializes the behavior
  37781. */
  37782. init(): void;
  37783. private _getCurrentDistance;
  37784. /**
  37785. * Attaches the scale behavior the passed in mesh
  37786. * @param ownerNode The mesh that will be scaled around once attached
  37787. */
  37788. attach(ownerNode: Mesh): void;
  37789. /**
  37790. * Detaches the behavior from the mesh
  37791. */
  37792. detach(): void;
  37793. }
  37794. }
  37795. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37796. import { Behavior } from "babylonjs/Behaviors/behavior";
  37797. import { Mesh } from "babylonjs/Meshes/mesh";
  37798. import { Observable } from "babylonjs/Misc/observable";
  37799. /**
  37800. * 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
  37801. */
  37802. export class SixDofDragBehavior implements Behavior<Mesh> {
  37803. private static _virtualScene;
  37804. private _ownerNode;
  37805. private _sceneRenderObserver;
  37806. private _scene;
  37807. private _targetPosition;
  37808. private _virtualOriginMesh;
  37809. private _virtualDragMesh;
  37810. private _pointerObserver;
  37811. private _moving;
  37812. private _startingOrientation;
  37813. /**
  37814. * 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)
  37815. */
  37816. private zDragFactor;
  37817. /**
  37818. * If the object should rotate to face the drag origin
  37819. */
  37820. rotateDraggedObject: boolean;
  37821. /**
  37822. * If the behavior is currently in a dragging state
  37823. */
  37824. dragging: boolean;
  37825. /**
  37826. * 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)
  37827. */
  37828. dragDeltaRatio: number;
  37829. /**
  37830. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37831. */
  37832. currentDraggingPointerID: number;
  37833. /**
  37834. * If camera controls should be detached during the drag
  37835. */
  37836. detachCameraControls: boolean;
  37837. /**
  37838. * Fires each time a drag starts
  37839. */
  37840. onDragStartObservable: Observable<{}>;
  37841. /**
  37842. * Fires each time a drag ends (eg. mouse release after drag)
  37843. */
  37844. onDragEndObservable: Observable<{}>;
  37845. /**
  37846. * 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
  37847. */
  37848. constructor();
  37849. /**
  37850. * The name of the behavior
  37851. */
  37852. readonly name: string;
  37853. /**
  37854. * Initializes the behavior
  37855. */
  37856. init(): void;
  37857. /**
  37858. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37859. */
  37860. private readonly _pointerCamera;
  37861. /**
  37862. * Attaches the scale behavior the passed in mesh
  37863. * @param ownerNode The mesh that will be scaled around once attached
  37864. */
  37865. attach(ownerNode: Mesh): void;
  37866. /**
  37867. * Detaches the behavior from the mesh
  37868. */
  37869. detach(): void;
  37870. }
  37871. }
  37872. declare module "babylonjs/Behaviors/Meshes/index" {
  37873. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37874. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37875. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37876. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37877. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37878. }
  37879. declare module "babylonjs/Behaviors/index" {
  37880. export * from "babylonjs/Behaviors/behavior";
  37881. export * from "babylonjs/Behaviors/Cameras/index";
  37882. export * from "babylonjs/Behaviors/Meshes/index";
  37883. }
  37884. declare module "babylonjs/Bones/boneIKController" {
  37885. import { Bone } from "babylonjs/Bones/bone";
  37886. import { Vector3 } from "babylonjs/Maths/math.vector";
  37887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37888. import { Nullable } from "babylonjs/types";
  37889. /**
  37890. * Class used to apply inverse kinematics to bones
  37891. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37892. */
  37893. export class BoneIKController {
  37894. private static _tmpVecs;
  37895. private static _tmpQuat;
  37896. private static _tmpMats;
  37897. /**
  37898. * Gets or sets the target mesh
  37899. */
  37900. targetMesh: AbstractMesh;
  37901. /** Gets or sets the mesh used as pole */
  37902. poleTargetMesh: AbstractMesh;
  37903. /**
  37904. * Gets or sets the bone used as pole
  37905. */
  37906. poleTargetBone: Nullable<Bone>;
  37907. /**
  37908. * Gets or sets the target position
  37909. */
  37910. targetPosition: Vector3;
  37911. /**
  37912. * Gets or sets the pole target position
  37913. */
  37914. poleTargetPosition: Vector3;
  37915. /**
  37916. * Gets or sets the pole target local offset
  37917. */
  37918. poleTargetLocalOffset: Vector3;
  37919. /**
  37920. * Gets or sets the pole angle
  37921. */
  37922. poleAngle: number;
  37923. /**
  37924. * Gets or sets the mesh associated with the controller
  37925. */
  37926. mesh: AbstractMesh;
  37927. /**
  37928. * 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)
  37929. */
  37930. slerpAmount: number;
  37931. private _bone1Quat;
  37932. private _bone1Mat;
  37933. private _bone2Ang;
  37934. private _bone1;
  37935. private _bone2;
  37936. private _bone1Length;
  37937. private _bone2Length;
  37938. private _maxAngle;
  37939. private _maxReach;
  37940. private _rightHandedSystem;
  37941. private _bendAxis;
  37942. private _slerping;
  37943. private _adjustRoll;
  37944. /**
  37945. * Gets or sets maximum allowed angle
  37946. */
  37947. maxAngle: number;
  37948. /**
  37949. * Creates a new BoneIKController
  37950. * @param mesh defines the mesh to control
  37951. * @param bone defines the bone to control
  37952. * @param options defines options to set up the controller
  37953. */
  37954. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37955. targetMesh?: AbstractMesh;
  37956. poleTargetMesh?: AbstractMesh;
  37957. poleTargetBone?: Bone;
  37958. poleTargetLocalOffset?: Vector3;
  37959. poleAngle?: number;
  37960. bendAxis?: Vector3;
  37961. maxAngle?: number;
  37962. slerpAmount?: number;
  37963. });
  37964. private _setMaxAngle;
  37965. /**
  37966. * Force the controller to update the bones
  37967. */
  37968. update(): void;
  37969. }
  37970. }
  37971. declare module "babylonjs/Bones/boneLookController" {
  37972. import { Vector3 } from "babylonjs/Maths/math.vector";
  37973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37974. import { Bone } from "babylonjs/Bones/bone";
  37975. import { Space } from "babylonjs/Maths/math.axis";
  37976. /**
  37977. * Class used to make a bone look toward a point in space
  37978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37979. */
  37980. export class BoneLookController {
  37981. private static _tmpVecs;
  37982. private static _tmpQuat;
  37983. private static _tmpMats;
  37984. /**
  37985. * The target Vector3 that the bone will look at
  37986. */
  37987. target: Vector3;
  37988. /**
  37989. * The mesh that the bone is attached to
  37990. */
  37991. mesh: AbstractMesh;
  37992. /**
  37993. * The bone that will be looking to the target
  37994. */
  37995. bone: Bone;
  37996. /**
  37997. * The up axis of the coordinate system that is used when the bone is rotated
  37998. */
  37999. upAxis: Vector3;
  38000. /**
  38001. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38002. */
  38003. upAxisSpace: Space;
  38004. /**
  38005. * Used to make an adjustment to the yaw of the bone
  38006. */
  38007. adjustYaw: number;
  38008. /**
  38009. * Used to make an adjustment to the pitch of the bone
  38010. */
  38011. adjustPitch: number;
  38012. /**
  38013. * Used to make an adjustment to the roll of the bone
  38014. */
  38015. adjustRoll: number;
  38016. /**
  38017. * 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)
  38018. */
  38019. slerpAmount: number;
  38020. private _minYaw;
  38021. private _maxYaw;
  38022. private _minPitch;
  38023. private _maxPitch;
  38024. private _minYawSin;
  38025. private _minYawCos;
  38026. private _maxYawSin;
  38027. private _maxYawCos;
  38028. private _midYawConstraint;
  38029. private _minPitchTan;
  38030. private _maxPitchTan;
  38031. private _boneQuat;
  38032. private _slerping;
  38033. private _transformYawPitch;
  38034. private _transformYawPitchInv;
  38035. private _firstFrameSkipped;
  38036. private _yawRange;
  38037. private _fowardAxis;
  38038. /**
  38039. * Gets or sets the minimum yaw angle that the bone can look to
  38040. */
  38041. minYaw: number;
  38042. /**
  38043. * Gets or sets the maximum yaw angle that the bone can look to
  38044. */
  38045. maxYaw: number;
  38046. /**
  38047. * Gets or sets the minimum pitch angle that the bone can look to
  38048. */
  38049. minPitch: number;
  38050. /**
  38051. * Gets or sets the maximum pitch angle that the bone can look to
  38052. */
  38053. maxPitch: number;
  38054. /**
  38055. * Create a BoneLookController
  38056. * @param mesh the mesh that the bone belongs to
  38057. * @param bone the bone that will be looking to the target
  38058. * @param target the target Vector3 to look at
  38059. * @param options optional settings:
  38060. * * maxYaw: the maximum angle the bone will yaw to
  38061. * * minYaw: the minimum angle the bone will yaw to
  38062. * * maxPitch: the maximum angle the bone will pitch to
  38063. * * minPitch: the minimum angle the bone will yaw to
  38064. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38065. * * upAxis: the up axis of the coordinate system
  38066. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38067. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38068. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38069. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38070. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38071. * * adjustRoll: used to make an adjustment to the roll of the bone
  38072. **/
  38073. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38074. maxYaw?: number;
  38075. minYaw?: number;
  38076. maxPitch?: number;
  38077. minPitch?: number;
  38078. slerpAmount?: number;
  38079. upAxis?: Vector3;
  38080. upAxisSpace?: Space;
  38081. yawAxis?: Vector3;
  38082. pitchAxis?: Vector3;
  38083. adjustYaw?: number;
  38084. adjustPitch?: number;
  38085. adjustRoll?: number;
  38086. });
  38087. /**
  38088. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38089. */
  38090. update(): void;
  38091. private _getAngleDiff;
  38092. private _getAngleBetween;
  38093. private _isAngleBetween;
  38094. }
  38095. }
  38096. declare module "babylonjs/Bones/index" {
  38097. export * from "babylonjs/Bones/bone";
  38098. export * from "babylonjs/Bones/boneIKController";
  38099. export * from "babylonjs/Bones/boneLookController";
  38100. export * from "babylonjs/Bones/skeleton";
  38101. }
  38102. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38103. import { Nullable } from "babylonjs/types";
  38104. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38105. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38106. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38107. /**
  38108. * Manage the gamepad inputs to control an arc rotate camera.
  38109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38110. */
  38111. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38112. /**
  38113. * Defines the camera the input is attached to.
  38114. */
  38115. camera: ArcRotateCamera;
  38116. /**
  38117. * Defines the gamepad the input is gathering event from.
  38118. */
  38119. gamepad: Nullable<Gamepad>;
  38120. /**
  38121. * Defines the gamepad rotation sensiblity.
  38122. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38123. */
  38124. gamepadRotationSensibility: number;
  38125. /**
  38126. * Defines the gamepad move sensiblity.
  38127. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38128. */
  38129. gamepadMoveSensibility: number;
  38130. private _onGamepadConnectedObserver;
  38131. private _onGamepadDisconnectedObserver;
  38132. /**
  38133. * Attach the input controls to a specific dom element to get the input from.
  38134. * @param element Defines the element the controls should be listened from
  38135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38136. */
  38137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38138. /**
  38139. * Detach the current controls from the specified dom element.
  38140. * @param element Defines the element to stop listening the inputs from
  38141. */
  38142. detachControl(element: Nullable<HTMLElement>): void;
  38143. /**
  38144. * Update the current camera state depending on the inputs that have been used this frame.
  38145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38146. */
  38147. checkInputs(): void;
  38148. /**
  38149. * Gets the class name of the current intput.
  38150. * @returns the class name
  38151. */
  38152. getClassName(): string;
  38153. /**
  38154. * Get the friendly name associated with the input class.
  38155. * @returns the input friendly name
  38156. */
  38157. getSimpleName(): string;
  38158. }
  38159. }
  38160. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38161. import { Nullable } from "babylonjs/types";
  38162. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38163. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38164. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38165. interface ArcRotateCameraInputsManager {
  38166. /**
  38167. * Add orientation input support to the input manager.
  38168. * @returns the current input manager
  38169. */
  38170. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38171. }
  38172. }
  38173. /**
  38174. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38176. */
  38177. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38178. /**
  38179. * Defines the camera the input is attached to.
  38180. */
  38181. camera: ArcRotateCamera;
  38182. /**
  38183. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38184. */
  38185. alphaCorrection: number;
  38186. /**
  38187. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38188. */
  38189. gammaCorrection: number;
  38190. private _alpha;
  38191. private _gamma;
  38192. private _dirty;
  38193. private _deviceOrientationHandler;
  38194. /**
  38195. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38196. */
  38197. constructor();
  38198. /**
  38199. * Attach the input controls to a specific dom element to get the input from.
  38200. * @param element Defines the element the controls should be listened from
  38201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38202. */
  38203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38204. /** @hidden */
  38205. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38206. /**
  38207. * Update the current camera state depending on the inputs that have been used this frame.
  38208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38209. */
  38210. checkInputs(): void;
  38211. /**
  38212. * Detach the current controls from the specified dom element.
  38213. * @param element Defines the element to stop listening the inputs from
  38214. */
  38215. detachControl(element: Nullable<HTMLElement>): void;
  38216. /**
  38217. * Gets the class name of the current intput.
  38218. * @returns the class name
  38219. */
  38220. getClassName(): string;
  38221. /**
  38222. * Get the friendly name associated with the input class.
  38223. * @returns the input friendly name
  38224. */
  38225. getSimpleName(): string;
  38226. }
  38227. }
  38228. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38229. import { Nullable } from "babylonjs/types";
  38230. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38231. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38232. /**
  38233. * Listen to mouse events to control the camera.
  38234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38235. */
  38236. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38237. /**
  38238. * Defines the camera the input is attached to.
  38239. */
  38240. camera: FlyCamera;
  38241. /**
  38242. * Defines if touch is enabled. (Default is true.)
  38243. */
  38244. touchEnabled: boolean;
  38245. /**
  38246. * Defines the buttons associated with the input to handle camera rotation.
  38247. */
  38248. buttons: number[];
  38249. /**
  38250. * Assign buttons for Yaw control.
  38251. */
  38252. buttonsYaw: number[];
  38253. /**
  38254. * Assign buttons for Pitch control.
  38255. */
  38256. buttonsPitch: number[];
  38257. /**
  38258. * Assign buttons for Roll control.
  38259. */
  38260. buttonsRoll: number[];
  38261. /**
  38262. * Detect if any button is being pressed while mouse is moved.
  38263. * -1 = Mouse locked.
  38264. * 0 = Left button.
  38265. * 1 = Middle Button.
  38266. * 2 = Right Button.
  38267. */
  38268. activeButton: number;
  38269. /**
  38270. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38271. * Higher values reduce its sensitivity.
  38272. */
  38273. angularSensibility: number;
  38274. private _mousemoveCallback;
  38275. private _observer;
  38276. private _rollObserver;
  38277. private previousPosition;
  38278. private noPreventDefault;
  38279. private element;
  38280. /**
  38281. * Listen to mouse events to control the camera.
  38282. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38284. */
  38285. constructor(touchEnabled?: boolean);
  38286. /**
  38287. * Attach the mouse control to the HTML DOM element.
  38288. * @param element Defines the element that listens to the input events.
  38289. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38290. */
  38291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38292. /**
  38293. * Detach the current controls from the specified dom element.
  38294. * @param element Defines the element to stop listening the inputs from
  38295. */
  38296. detachControl(element: Nullable<HTMLElement>): void;
  38297. /**
  38298. * Gets the class name of the current input.
  38299. * @returns the class name.
  38300. */
  38301. getClassName(): string;
  38302. /**
  38303. * Get the friendly name associated with the input class.
  38304. * @returns the input's friendly name.
  38305. */
  38306. getSimpleName(): string;
  38307. private _pointerInput;
  38308. private _onMouseMove;
  38309. /**
  38310. * Rotate camera by mouse offset.
  38311. */
  38312. private rotateCamera;
  38313. }
  38314. }
  38315. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38316. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38317. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38318. /**
  38319. * Default Inputs manager for the FlyCamera.
  38320. * It groups all the default supported inputs for ease of use.
  38321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38322. */
  38323. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38324. /**
  38325. * Instantiates a new FlyCameraInputsManager.
  38326. * @param camera Defines the camera the inputs belong to.
  38327. */
  38328. constructor(camera: FlyCamera);
  38329. /**
  38330. * Add keyboard input support to the input manager.
  38331. * @returns the new FlyCameraKeyboardMoveInput().
  38332. */
  38333. addKeyboard(): FlyCameraInputsManager;
  38334. /**
  38335. * Add mouse input support to the input manager.
  38336. * @param touchEnabled Enable touch screen support.
  38337. * @returns the new FlyCameraMouseInput().
  38338. */
  38339. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38340. }
  38341. }
  38342. declare module "babylonjs/Cameras/flyCamera" {
  38343. import { Scene } from "babylonjs/scene";
  38344. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38346. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38347. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38348. /**
  38349. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38350. * such as in a 3D Space Shooter or a Flight Simulator.
  38351. */
  38352. export class FlyCamera extends TargetCamera {
  38353. /**
  38354. * Define the collision ellipsoid of the camera.
  38355. * This is helpful for simulating a camera body, like a player's body.
  38356. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38357. */
  38358. ellipsoid: Vector3;
  38359. /**
  38360. * Define an offset for the position of the ellipsoid around the camera.
  38361. * This can be helpful if the camera is attached away from the player's body center,
  38362. * such as at its head.
  38363. */
  38364. ellipsoidOffset: Vector3;
  38365. /**
  38366. * Enable or disable collisions of the camera with the rest of the scene objects.
  38367. */
  38368. checkCollisions: boolean;
  38369. /**
  38370. * Enable or disable gravity on the camera.
  38371. */
  38372. applyGravity: boolean;
  38373. /**
  38374. * Define the current direction the camera is moving to.
  38375. */
  38376. cameraDirection: Vector3;
  38377. /**
  38378. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38379. * This overrides and empties cameraRotation.
  38380. */
  38381. rotationQuaternion: Quaternion;
  38382. /**
  38383. * Track Roll to maintain the wanted Rolling when looking around.
  38384. */
  38385. _trackRoll: number;
  38386. /**
  38387. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38388. */
  38389. rollCorrect: number;
  38390. /**
  38391. * Mimic a banked turn, Rolling the camera when Yawing.
  38392. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38393. */
  38394. bankedTurn: boolean;
  38395. /**
  38396. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38397. */
  38398. bankedTurnLimit: number;
  38399. /**
  38400. * Value of 0 disables the banked Roll.
  38401. * Value of 1 is equal to the Yaw angle in radians.
  38402. */
  38403. bankedTurnMultiplier: number;
  38404. /**
  38405. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38406. */
  38407. inputs: FlyCameraInputsManager;
  38408. /**
  38409. * Gets the input sensibility for mouse input.
  38410. * Higher values reduce sensitivity.
  38411. */
  38412. /**
  38413. * Sets the input sensibility for a mouse input.
  38414. * Higher values reduce sensitivity.
  38415. */
  38416. angularSensibility: number;
  38417. /**
  38418. * Get the keys for camera movement forward.
  38419. */
  38420. /**
  38421. * Set the keys for camera movement forward.
  38422. */
  38423. keysForward: number[];
  38424. /**
  38425. * Get the keys for camera movement backward.
  38426. */
  38427. keysBackward: number[];
  38428. /**
  38429. * Get the keys for camera movement up.
  38430. */
  38431. /**
  38432. * Set the keys for camera movement up.
  38433. */
  38434. keysUp: number[];
  38435. /**
  38436. * Get the keys for camera movement down.
  38437. */
  38438. /**
  38439. * Set the keys for camera movement down.
  38440. */
  38441. keysDown: number[];
  38442. /**
  38443. * Get the keys for camera movement left.
  38444. */
  38445. /**
  38446. * Set the keys for camera movement left.
  38447. */
  38448. keysLeft: number[];
  38449. /**
  38450. * Set the keys for camera movement right.
  38451. */
  38452. /**
  38453. * Set the keys for camera movement right.
  38454. */
  38455. keysRight: number[];
  38456. /**
  38457. * Event raised when the camera collides with a mesh in the scene.
  38458. */
  38459. onCollide: (collidedMesh: AbstractMesh) => void;
  38460. private _collider;
  38461. private _needMoveForGravity;
  38462. private _oldPosition;
  38463. private _diffPosition;
  38464. private _newPosition;
  38465. /** @hidden */
  38466. _localDirection: Vector3;
  38467. /** @hidden */
  38468. _transformedDirection: Vector3;
  38469. /**
  38470. * Instantiates a FlyCamera.
  38471. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38472. * such as in a 3D Space Shooter or a Flight Simulator.
  38473. * @param name Define the name of the camera in the scene.
  38474. * @param position Define the starting position of the camera in the scene.
  38475. * @param scene Define the scene the camera belongs to.
  38476. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38477. */
  38478. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38479. /**
  38480. * Attach a control to the HTML DOM element.
  38481. * @param element Defines the element that listens to the input events.
  38482. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38483. */
  38484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38485. /**
  38486. * Detach a control from the HTML DOM element.
  38487. * The camera will stop reacting to that input.
  38488. * @param element Defines the element that listens to the input events.
  38489. */
  38490. detachControl(element: HTMLElement): void;
  38491. private _collisionMask;
  38492. /**
  38493. * Get the mask that the camera ignores in collision events.
  38494. */
  38495. /**
  38496. * Set the mask that the camera ignores in collision events.
  38497. */
  38498. collisionMask: number;
  38499. /** @hidden */
  38500. _collideWithWorld(displacement: Vector3): void;
  38501. /** @hidden */
  38502. private _onCollisionPositionChange;
  38503. /** @hidden */
  38504. _checkInputs(): void;
  38505. /** @hidden */
  38506. _decideIfNeedsToMove(): boolean;
  38507. /** @hidden */
  38508. _updatePosition(): void;
  38509. /**
  38510. * Restore the Roll to its target value at the rate specified.
  38511. * @param rate - Higher means slower restoring.
  38512. * @hidden
  38513. */
  38514. restoreRoll(rate: number): void;
  38515. /**
  38516. * Destroy the camera and release the current resources held by it.
  38517. */
  38518. dispose(): void;
  38519. /**
  38520. * Get the current object class name.
  38521. * @returns the class name.
  38522. */
  38523. getClassName(): string;
  38524. }
  38525. }
  38526. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38527. import { Nullable } from "babylonjs/types";
  38528. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38529. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38530. /**
  38531. * Listen to keyboard events to control the camera.
  38532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38533. */
  38534. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38535. /**
  38536. * Defines the camera the input is attached to.
  38537. */
  38538. camera: FlyCamera;
  38539. /**
  38540. * The list of keyboard keys used to control the forward move of the camera.
  38541. */
  38542. keysForward: number[];
  38543. /**
  38544. * The list of keyboard keys used to control the backward move of the camera.
  38545. */
  38546. keysBackward: number[];
  38547. /**
  38548. * The list of keyboard keys used to control the forward move of the camera.
  38549. */
  38550. keysUp: number[];
  38551. /**
  38552. * The list of keyboard keys used to control the backward move of the camera.
  38553. */
  38554. keysDown: number[];
  38555. /**
  38556. * The list of keyboard keys used to control the right strafe move of the camera.
  38557. */
  38558. keysRight: number[];
  38559. /**
  38560. * The list of keyboard keys used to control the left strafe move of the camera.
  38561. */
  38562. keysLeft: number[];
  38563. private _keys;
  38564. private _onCanvasBlurObserver;
  38565. private _onKeyboardObserver;
  38566. private _engine;
  38567. private _scene;
  38568. /**
  38569. * Attach the input controls to a specific dom element to get the input from.
  38570. * @param element Defines the element the controls should be listened from
  38571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38572. */
  38573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38574. /**
  38575. * Detach the current controls from the specified dom element.
  38576. * @param element Defines the element to stop listening the inputs from
  38577. */
  38578. detachControl(element: Nullable<HTMLElement>): void;
  38579. /**
  38580. * Gets the class name of the current intput.
  38581. * @returns the class name
  38582. */
  38583. getClassName(): string;
  38584. /** @hidden */
  38585. _onLostFocus(e: FocusEvent): void;
  38586. /**
  38587. * Get the friendly name associated with the input class.
  38588. * @returns the input friendly name
  38589. */
  38590. getSimpleName(): string;
  38591. /**
  38592. * Update the current camera state depending on the inputs that have been used this frame.
  38593. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38594. */
  38595. checkInputs(): void;
  38596. }
  38597. }
  38598. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38599. import { Nullable } from "babylonjs/types";
  38600. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38601. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38602. /**
  38603. * Manage the mouse wheel inputs to control a follow camera.
  38604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38605. */
  38606. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38607. /**
  38608. * Defines the camera the input is attached to.
  38609. */
  38610. camera: FollowCamera;
  38611. /**
  38612. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38613. */
  38614. axisControlRadius: boolean;
  38615. /**
  38616. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38617. */
  38618. axisControlHeight: boolean;
  38619. /**
  38620. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38621. */
  38622. axisControlRotation: boolean;
  38623. /**
  38624. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38625. * relation to mouseWheel events.
  38626. */
  38627. wheelPrecision: number;
  38628. /**
  38629. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38630. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38631. */
  38632. wheelDeltaPercentage: number;
  38633. private _wheel;
  38634. private _observer;
  38635. /**
  38636. * Attach the input controls to a specific dom element to get the input from.
  38637. * @param element Defines the element the controls should be listened from
  38638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38639. */
  38640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38641. /**
  38642. * Detach the current controls from the specified dom element.
  38643. * @param element Defines the element to stop listening the inputs from
  38644. */
  38645. detachControl(element: Nullable<HTMLElement>): void;
  38646. /**
  38647. * Gets the class name of the current intput.
  38648. * @returns the class name
  38649. */
  38650. getClassName(): string;
  38651. /**
  38652. * Get the friendly name associated with the input class.
  38653. * @returns the input friendly name
  38654. */
  38655. getSimpleName(): string;
  38656. }
  38657. }
  38658. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38659. import { Nullable } from "babylonjs/types";
  38660. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38661. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38662. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38663. /**
  38664. * Manage the pointers inputs to control an follow camera.
  38665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38666. */
  38667. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38668. /**
  38669. * Defines the camera the input is attached to.
  38670. */
  38671. camera: FollowCamera;
  38672. /**
  38673. * Gets the class name of the current input.
  38674. * @returns the class name
  38675. */
  38676. getClassName(): string;
  38677. /**
  38678. * Defines the pointer angular sensibility along the X axis or how fast is
  38679. * the camera rotating.
  38680. * A negative number will reverse the axis direction.
  38681. */
  38682. angularSensibilityX: number;
  38683. /**
  38684. * Defines the pointer angular sensibility along the Y axis or how fast is
  38685. * the camera rotating.
  38686. * A negative number will reverse the axis direction.
  38687. */
  38688. angularSensibilityY: number;
  38689. /**
  38690. * Defines the pointer pinch precision or how fast is the camera zooming.
  38691. * A negative number will reverse the axis direction.
  38692. */
  38693. pinchPrecision: number;
  38694. /**
  38695. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38696. * from 0.
  38697. * It defines the percentage of current camera.radius to use as delta when
  38698. * pinch zoom is used.
  38699. */
  38700. pinchDeltaPercentage: number;
  38701. /**
  38702. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38703. */
  38704. axisXControlRadius: boolean;
  38705. /**
  38706. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38707. */
  38708. axisXControlHeight: boolean;
  38709. /**
  38710. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38711. */
  38712. axisXControlRotation: boolean;
  38713. /**
  38714. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38715. */
  38716. axisYControlRadius: boolean;
  38717. /**
  38718. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38719. */
  38720. axisYControlHeight: boolean;
  38721. /**
  38722. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38723. */
  38724. axisYControlRotation: boolean;
  38725. /**
  38726. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38727. */
  38728. axisPinchControlRadius: boolean;
  38729. /**
  38730. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38731. */
  38732. axisPinchControlHeight: boolean;
  38733. /**
  38734. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38735. */
  38736. axisPinchControlRotation: boolean;
  38737. /**
  38738. * Log error messages if basic misconfiguration has occurred.
  38739. */
  38740. warningEnable: boolean;
  38741. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38742. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38743. private _warningCounter;
  38744. private _warning;
  38745. }
  38746. }
  38747. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38748. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38749. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38750. /**
  38751. * Default Inputs manager for the FollowCamera.
  38752. * It groups all the default supported inputs for ease of use.
  38753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38754. */
  38755. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38756. /**
  38757. * Instantiates a new FollowCameraInputsManager.
  38758. * @param camera Defines the camera the inputs belong to
  38759. */
  38760. constructor(camera: FollowCamera);
  38761. /**
  38762. * Add keyboard input support to the input manager.
  38763. * @returns the current input manager
  38764. */
  38765. addKeyboard(): FollowCameraInputsManager;
  38766. /**
  38767. * Add mouse wheel input support to the input manager.
  38768. * @returns the current input manager
  38769. */
  38770. addMouseWheel(): FollowCameraInputsManager;
  38771. /**
  38772. * Add pointers input support to the input manager.
  38773. * @returns the current input manager
  38774. */
  38775. addPointers(): FollowCameraInputsManager;
  38776. /**
  38777. * Add orientation input support to the input manager.
  38778. * @returns the current input manager
  38779. */
  38780. addVRDeviceOrientation(): FollowCameraInputsManager;
  38781. }
  38782. }
  38783. declare module "babylonjs/Cameras/followCamera" {
  38784. import { Nullable } from "babylonjs/types";
  38785. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38786. import { Scene } from "babylonjs/scene";
  38787. import { Vector3 } from "babylonjs/Maths/math.vector";
  38788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38789. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38790. /**
  38791. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38792. * an arc rotate version arcFollowCamera are available.
  38793. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38794. */
  38795. export class FollowCamera extends TargetCamera {
  38796. /**
  38797. * Distance the follow camera should follow an object at
  38798. */
  38799. radius: number;
  38800. /**
  38801. * Minimum allowed distance of the camera to the axis of rotation
  38802. * (The camera can not get closer).
  38803. * This can help limiting how the Camera is able to move in the scene.
  38804. */
  38805. lowerRadiusLimit: Nullable<number>;
  38806. /**
  38807. * Maximum allowed distance of the camera to the axis of rotation
  38808. * (The camera can not get further).
  38809. * This can help limiting how the Camera is able to move in the scene.
  38810. */
  38811. upperRadiusLimit: Nullable<number>;
  38812. /**
  38813. * Define a rotation offset between the camera and the object it follows
  38814. */
  38815. rotationOffset: number;
  38816. /**
  38817. * Minimum allowed angle to camera position relative to target object.
  38818. * This can help limiting how the Camera is able to move in the scene.
  38819. */
  38820. lowerRotationOffsetLimit: Nullable<number>;
  38821. /**
  38822. * Maximum allowed angle to camera position relative to target object.
  38823. * This can help limiting how the Camera is able to move in the scene.
  38824. */
  38825. upperRotationOffsetLimit: Nullable<number>;
  38826. /**
  38827. * Define a height offset between the camera and the object it follows.
  38828. * It can help following an object from the top (like a car chaing a plane)
  38829. */
  38830. heightOffset: number;
  38831. /**
  38832. * Minimum allowed height of camera position relative to target object.
  38833. * This can help limiting how the Camera is able to move in the scene.
  38834. */
  38835. lowerHeightOffsetLimit: Nullable<number>;
  38836. /**
  38837. * Maximum allowed height of camera position relative to target object.
  38838. * This can help limiting how the Camera is able to move in the scene.
  38839. */
  38840. upperHeightOffsetLimit: Nullable<number>;
  38841. /**
  38842. * Define how fast the camera can accelerate to follow it s target.
  38843. */
  38844. cameraAcceleration: number;
  38845. /**
  38846. * Define the speed limit of the camera following an object.
  38847. */
  38848. maxCameraSpeed: number;
  38849. /**
  38850. * Define the target of the camera.
  38851. */
  38852. lockedTarget: Nullable<AbstractMesh>;
  38853. /**
  38854. * Defines the input associated with the camera.
  38855. */
  38856. inputs: FollowCameraInputsManager;
  38857. /**
  38858. * Instantiates the follow camera.
  38859. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38860. * @param name Define the name of the camera in the scene
  38861. * @param position Define the position of the camera
  38862. * @param scene Define the scene the camera belong to
  38863. * @param lockedTarget Define the target of the camera
  38864. */
  38865. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38866. private _follow;
  38867. /**
  38868. * Attached controls to the current camera.
  38869. * @param element Defines the element the controls should be listened from
  38870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38871. */
  38872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38873. /**
  38874. * Detach the current controls from the camera.
  38875. * The camera will stop reacting to inputs.
  38876. * @param element Defines the element to stop listening the inputs from
  38877. */
  38878. detachControl(element: HTMLElement): void;
  38879. /** @hidden */
  38880. _checkInputs(): void;
  38881. private _checkLimits;
  38882. /**
  38883. * Gets the camera class name.
  38884. * @returns the class name
  38885. */
  38886. getClassName(): string;
  38887. }
  38888. /**
  38889. * Arc Rotate version of the follow camera.
  38890. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38891. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38892. */
  38893. export class ArcFollowCamera extends TargetCamera {
  38894. /** The longitudinal angle of the camera */
  38895. alpha: number;
  38896. /** The latitudinal angle of the camera */
  38897. beta: number;
  38898. /** The radius of the camera from its target */
  38899. radius: number;
  38900. /** Define the camera target (the messh it should follow) */
  38901. target: Nullable<AbstractMesh>;
  38902. private _cartesianCoordinates;
  38903. /**
  38904. * Instantiates a new ArcFollowCamera
  38905. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38906. * @param name Define the name of the camera
  38907. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38908. * @param beta Define the rotation angle of the camera around the elevation axis
  38909. * @param radius Define the radius of the camera from its target point
  38910. * @param target Define the target of the camera
  38911. * @param scene Define the scene the camera belongs to
  38912. */
  38913. constructor(name: string,
  38914. /** The longitudinal angle of the camera */
  38915. alpha: number,
  38916. /** The latitudinal angle of the camera */
  38917. beta: number,
  38918. /** The radius of the camera from its target */
  38919. radius: number,
  38920. /** Define the camera target (the messh it should follow) */
  38921. target: Nullable<AbstractMesh>, scene: Scene);
  38922. private _follow;
  38923. /** @hidden */
  38924. _checkInputs(): void;
  38925. /**
  38926. * Returns the class name of the object.
  38927. * It is mostly used internally for serialization purposes.
  38928. */
  38929. getClassName(): string;
  38930. }
  38931. }
  38932. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38933. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38934. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38935. import { Nullable } from "babylonjs/types";
  38936. /**
  38937. * Manage the keyboard inputs to control the movement of a follow camera.
  38938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38939. */
  38940. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38941. /**
  38942. * Defines the camera the input is attached to.
  38943. */
  38944. camera: FollowCamera;
  38945. /**
  38946. * Defines the list of key codes associated with the up action (increase heightOffset)
  38947. */
  38948. keysHeightOffsetIncr: number[];
  38949. /**
  38950. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38951. */
  38952. keysHeightOffsetDecr: number[];
  38953. /**
  38954. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38955. */
  38956. keysHeightOffsetModifierAlt: boolean;
  38957. /**
  38958. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38959. */
  38960. keysHeightOffsetModifierCtrl: boolean;
  38961. /**
  38962. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38963. */
  38964. keysHeightOffsetModifierShift: boolean;
  38965. /**
  38966. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38967. */
  38968. keysRotationOffsetIncr: number[];
  38969. /**
  38970. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38971. */
  38972. keysRotationOffsetDecr: number[];
  38973. /**
  38974. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38975. */
  38976. keysRotationOffsetModifierAlt: boolean;
  38977. /**
  38978. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38979. */
  38980. keysRotationOffsetModifierCtrl: boolean;
  38981. /**
  38982. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38983. */
  38984. keysRotationOffsetModifierShift: boolean;
  38985. /**
  38986. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38987. */
  38988. keysRadiusIncr: number[];
  38989. /**
  38990. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38991. */
  38992. keysRadiusDecr: number[];
  38993. /**
  38994. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38995. */
  38996. keysRadiusModifierAlt: boolean;
  38997. /**
  38998. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38999. */
  39000. keysRadiusModifierCtrl: boolean;
  39001. /**
  39002. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39003. */
  39004. keysRadiusModifierShift: boolean;
  39005. /**
  39006. * Defines the rate of change of heightOffset.
  39007. */
  39008. heightSensibility: number;
  39009. /**
  39010. * Defines the rate of change of rotationOffset.
  39011. */
  39012. rotationSensibility: number;
  39013. /**
  39014. * Defines the rate of change of radius.
  39015. */
  39016. radiusSensibility: number;
  39017. private _keys;
  39018. private _ctrlPressed;
  39019. private _altPressed;
  39020. private _shiftPressed;
  39021. private _onCanvasBlurObserver;
  39022. private _onKeyboardObserver;
  39023. private _engine;
  39024. private _scene;
  39025. /**
  39026. * Attach the input controls to a specific dom element to get the input from.
  39027. * @param element Defines the element the controls should be listened from
  39028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39029. */
  39030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39031. /**
  39032. * Detach the current controls from the specified dom element.
  39033. * @param element Defines the element to stop listening the inputs from
  39034. */
  39035. detachControl(element: Nullable<HTMLElement>): void;
  39036. /**
  39037. * Update the current camera state depending on the inputs that have been used this frame.
  39038. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39039. */
  39040. checkInputs(): void;
  39041. /**
  39042. * Gets the class name of the current input.
  39043. * @returns the class name
  39044. */
  39045. getClassName(): string;
  39046. /**
  39047. * Get the friendly name associated with the input class.
  39048. * @returns the input friendly name
  39049. */
  39050. getSimpleName(): string;
  39051. /**
  39052. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39053. * allow modification of the heightOffset value.
  39054. */
  39055. private _modifierHeightOffset;
  39056. /**
  39057. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39058. * allow modification of the rotationOffset value.
  39059. */
  39060. private _modifierRotationOffset;
  39061. /**
  39062. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39063. * allow modification of the radius value.
  39064. */
  39065. private _modifierRadius;
  39066. }
  39067. }
  39068. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39069. import { Nullable } from "babylonjs/types";
  39070. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39071. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39072. import { Observable } from "babylonjs/Misc/observable";
  39073. module "babylonjs/Cameras/freeCameraInputsManager" {
  39074. interface FreeCameraInputsManager {
  39075. /**
  39076. * @hidden
  39077. */
  39078. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39079. /**
  39080. * Add orientation input support to the input manager.
  39081. * @returns the current input manager
  39082. */
  39083. addDeviceOrientation(): FreeCameraInputsManager;
  39084. }
  39085. }
  39086. /**
  39087. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39088. * Screen rotation is taken into account.
  39089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39090. */
  39091. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39092. private _camera;
  39093. private _screenOrientationAngle;
  39094. private _constantTranform;
  39095. private _screenQuaternion;
  39096. private _alpha;
  39097. private _beta;
  39098. private _gamma;
  39099. /**
  39100. * Can be used to detect if a device orientation sensor is availible on a device
  39101. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39102. * @returns a promise that will resolve on orientation change
  39103. */
  39104. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39105. /**
  39106. * @hidden
  39107. */
  39108. _onDeviceOrientationChangedObservable: Observable<void>;
  39109. /**
  39110. * Instantiates a new input
  39111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39112. */
  39113. constructor();
  39114. /**
  39115. * Define the camera controlled by the input.
  39116. */
  39117. camera: FreeCamera;
  39118. /**
  39119. * Attach the input controls to a specific dom element to get the input from.
  39120. * @param element Defines the element the controls should be listened from
  39121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39122. */
  39123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39124. private _orientationChanged;
  39125. private _deviceOrientation;
  39126. /**
  39127. * Detach the current controls from the specified dom element.
  39128. * @param element Defines the element to stop listening the inputs from
  39129. */
  39130. detachControl(element: Nullable<HTMLElement>): void;
  39131. /**
  39132. * Update the current camera state depending on the inputs that have been used this frame.
  39133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39134. */
  39135. checkInputs(): void;
  39136. /**
  39137. * Gets the class name of the current intput.
  39138. * @returns the class name
  39139. */
  39140. getClassName(): string;
  39141. /**
  39142. * Get the friendly name associated with the input class.
  39143. * @returns the input friendly name
  39144. */
  39145. getSimpleName(): string;
  39146. }
  39147. }
  39148. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39149. import { Nullable } from "babylonjs/types";
  39150. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39151. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39152. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39153. /**
  39154. * Manage the gamepad inputs to control a free camera.
  39155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39156. */
  39157. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39158. /**
  39159. * Define the camera the input is attached to.
  39160. */
  39161. camera: FreeCamera;
  39162. /**
  39163. * Define the Gamepad controlling the input
  39164. */
  39165. gamepad: Nullable<Gamepad>;
  39166. /**
  39167. * Defines the gamepad rotation sensiblity.
  39168. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39169. */
  39170. gamepadAngularSensibility: number;
  39171. /**
  39172. * Defines the gamepad move sensiblity.
  39173. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39174. */
  39175. gamepadMoveSensibility: number;
  39176. private _onGamepadConnectedObserver;
  39177. private _onGamepadDisconnectedObserver;
  39178. private _cameraTransform;
  39179. private _deltaTransform;
  39180. private _vector3;
  39181. private _vector2;
  39182. /**
  39183. * Attach the input controls to a specific dom element to get the input from.
  39184. * @param element Defines the element the controls should be listened from
  39185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39186. */
  39187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39188. /**
  39189. * Detach the current controls from the specified dom element.
  39190. * @param element Defines the element to stop listening the inputs from
  39191. */
  39192. detachControl(element: Nullable<HTMLElement>): void;
  39193. /**
  39194. * Update the current camera state depending on the inputs that have been used this frame.
  39195. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39196. */
  39197. checkInputs(): void;
  39198. /**
  39199. * Gets the class name of the current intput.
  39200. * @returns the class name
  39201. */
  39202. getClassName(): string;
  39203. /**
  39204. * Get the friendly name associated with the input class.
  39205. * @returns the input friendly name
  39206. */
  39207. getSimpleName(): string;
  39208. }
  39209. }
  39210. declare module "babylonjs/Misc/virtualJoystick" {
  39211. import { Nullable } from "babylonjs/types";
  39212. import { Vector3 } from "babylonjs/Maths/math.vector";
  39213. /**
  39214. * Defines the potential axis of a Joystick
  39215. */
  39216. export enum JoystickAxis {
  39217. /** X axis */
  39218. X = 0,
  39219. /** Y axis */
  39220. Y = 1,
  39221. /** Z axis */
  39222. Z = 2
  39223. }
  39224. /**
  39225. * Class used to define virtual joystick (used in touch mode)
  39226. */
  39227. export class VirtualJoystick {
  39228. /**
  39229. * Gets or sets a boolean indicating that left and right values must be inverted
  39230. */
  39231. reverseLeftRight: boolean;
  39232. /**
  39233. * Gets or sets a boolean indicating that up and down values must be inverted
  39234. */
  39235. reverseUpDown: boolean;
  39236. /**
  39237. * Gets the offset value for the position (ie. the change of the position value)
  39238. */
  39239. deltaPosition: Vector3;
  39240. /**
  39241. * Gets a boolean indicating if the virtual joystick was pressed
  39242. */
  39243. pressed: boolean;
  39244. /**
  39245. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39246. */
  39247. static Canvas: Nullable<HTMLCanvasElement>;
  39248. private static _globalJoystickIndex;
  39249. private static vjCanvasContext;
  39250. private static vjCanvasWidth;
  39251. private static vjCanvasHeight;
  39252. private static halfWidth;
  39253. private _action;
  39254. private _axisTargetedByLeftAndRight;
  39255. private _axisTargetedByUpAndDown;
  39256. private _joystickSensibility;
  39257. private _inversedSensibility;
  39258. private _joystickPointerID;
  39259. private _joystickColor;
  39260. private _joystickPointerPos;
  39261. private _joystickPreviousPointerPos;
  39262. private _joystickPointerStartPos;
  39263. private _deltaJoystickVector;
  39264. private _leftJoystick;
  39265. private _touches;
  39266. private _onPointerDownHandlerRef;
  39267. private _onPointerMoveHandlerRef;
  39268. private _onPointerUpHandlerRef;
  39269. private _onResize;
  39270. /**
  39271. * Creates a new virtual joystick
  39272. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39273. */
  39274. constructor(leftJoystick?: boolean);
  39275. /**
  39276. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39277. * @param newJoystickSensibility defines the new sensibility
  39278. */
  39279. setJoystickSensibility(newJoystickSensibility: number): void;
  39280. private _onPointerDown;
  39281. private _onPointerMove;
  39282. private _onPointerUp;
  39283. /**
  39284. * Change the color of the virtual joystick
  39285. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39286. */
  39287. setJoystickColor(newColor: string): void;
  39288. /**
  39289. * Defines a callback to call when the joystick is touched
  39290. * @param action defines the callback
  39291. */
  39292. setActionOnTouch(action: () => any): void;
  39293. /**
  39294. * Defines which axis you'd like to control for left & right
  39295. * @param axis defines the axis to use
  39296. */
  39297. setAxisForLeftRight(axis: JoystickAxis): void;
  39298. /**
  39299. * Defines which axis you'd like to control for up & down
  39300. * @param axis defines the axis to use
  39301. */
  39302. setAxisForUpDown(axis: JoystickAxis): void;
  39303. private _drawVirtualJoystick;
  39304. /**
  39305. * Release internal HTML canvas
  39306. */
  39307. releaseCanvas(): void;
  39308. }
  39309. }
  39310. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39311. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39312. import { Nullable } from "babylonjs/types";
  39313. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39314. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39315. module "babylonjs/Cameras/freeCameraInputsManager" {
  39316. interface FreeCameraInputsManager {
  39317. /**
  39318. * Add virtual joystick input support to the input manager.
  39319. * @returns the current input manager
  39320. */
  39321. addVirtualJoystick(): FreeCameraInputsManager;
  39322. }
  39323. }
  39324. /**
  39325. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39327. */
  39328. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39329. /**
  39330. * Defines the camera the input is attached to.
  39331. */
  39332. camera: FreeCamera;
  39333. private _leftjoystick;
  39334. private _rightjoystick;
  39335. /**
  39336. * Gets the left stick of the virtual joystick.
  39337. * @returns The virtual Joystick
  39338. */
  39339. getLeftJoystick(): VirtualJoystick;
  39340. /**
  39341. * Gets the right stick of the virtual joystick.
  39342. * @returns The virtual Joystick
  39343. */
  39344. getRightJoystick(): VirtualJoystick;
  39345. /**
  39346. * Update the current camera state depending on the inputs that have been used this frame.
  39347. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39348. */
  39349. checkInputs(): void;
  39350. /**
  39351. * Attach the input controls to a specific dom element to get the input from.
  39352. * @param element Defines the element the controls should be listened from
  39353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39354. */
  39355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39356. /**
  39357. * Detach the current controls from the specified dom element.
  39358. * @param element Defines the element to stop listening the inputs from
  39359. */
  39360. detachControl(element: Nullable<HTMLElement>): void;
  39361. /**
  39362. * Gets the class name of the current intput.
  39363. * @returns the class name
  39364. */
  39365. getClassName(): string;
  39366. /**
  39367. * Get the friendly name associated with the input class.
  39368. * @returns the input friendly name
  39369. */
  39370. getSimpleName(): string;
  39371. }
  39372. }
  39373. declare module "babylonjs/Cameras/Inputs/index" {
  39374. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39375. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39376. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39377. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39378. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39379. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39380. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39381. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39382. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39383. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39384. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39385. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39386. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39387. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39388. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39389. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39390. }
  39391. declare module "babylonjs/Cameras/touchCamera" {
  39392. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39393. import { Scene } from "babylonjs/scene";
  39394. import { Vector3 } from "babylonjs/Maths/math.vector";
  39395. /**
  39396. * This represents a FPS type of camera controlled by touch.
  39397. * This is like a universal camera minus the Gamepad controls.
  39398. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39399. */
  39400. export class TouchCamera extends FreeCamera {
  39401. /**
  39402. * Defines the touch sensibility for rotation.
  39403. * The higher the faster.
  39404. */
  39405. touchAngularSensibility: number;
  39406. /**
  39407. * Defines the touch sensibility for move.
  39408. * The higher the faster.
  39409. */
  39410. touchMoveSensibility: number;
  39411. /**
  39412. * Instantiates a new touch camera.
  39413. * This represents a FPS type of camera controlled by touch.
  39414. * This is like a universal camera minus the Gamepad controls.
  39415. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39416. * @param name Define the name of the camera in the scene
  39417. * @param position Define the start position of the camera in the scene
  39418. * @param scene Define the scene the camera belongs to
  39419. */
  39420. constructor(name: string, position: Vector3, scene: Scene);
  39421. /**
  39422. * Gets the current object class name.
  39423. * @return the class name
  39424. */
  39425. getClassName(): string;
  39426. /** @hidden */
  39427. _setupInputs(): void;
  39428. }
  39429. }
  39430. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39431. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39432. import { Scene } from "babylonjs/scene";
  39433. import { Vector3 } from "babylonjs/Maths/math.vector";
  39434. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39435. import { Axis } from "babylonjs/Maths/math.axis";
  39436. /**
  39437. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39438. * being tilted forward or back and left or right.
  39439. */
  39440. export class DeviceOrientationCamera extends FreeCamera {
  39441. private _initialQuaternion;
  39442. private _quaternionCache;
  39443. private _tmpDragQuaternion;
  39444. private _disablePointerInputWhenUsingDeviceOrientation;
  39445. /**
  39446. * Creates a new device orientation camera
  39447. * @param name The name of the camera
  39448. * @param position The start position camera
  39449. * @param scene The scene the camera belongs to
  39450. */
  39451. constructor(name: string, position: Vector3, scene: Scene);
  39452. /**
  39453. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39454. */
  39455. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39456. private _dragFactor;
  39457. /**
  39458. * Enabled turning on the y axis when the orientation sensor is active
  39459. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39460. */
  39461. enableHorizontalDragging(dragFactor?: number): void;
  39462. /**
  39463. * Gets the current instance class name ("DeviceOrientationCamera").
  39464. * This helps avoiding instanceof at run time.
  39465. * @returns the class name
  39466. */
  39467. getClassName(): string;
  39468. /**
  39469. * @hidden
  39470. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39471. */
  39472. _checkInputs(): void;
  39473. /**
  39474. * Reset the camera to its default orientation on the specified axis only.
  39475. * @param axis The axis to reset
  39476. */
  39477. resetToCurrentRotation(axis?: Axis): void;
  39478. }
  39479. }
  39480. declare module "babylonjs/Gamepads/xboxGamepad" {
  39481. import { Observable } from "babylonjs/Misc/observable";
  39482. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39483. /**
  39484. * Defines supported buttons for XBox360 compatible gamepads
  39485. */
  39486. export enum Xbox360Button {
  39487. /** A */
  39488. A = 0,
  39489. /** B */
  39490. B = 1,
  39491. /** X */
  39492. X = 2,
  39493. /** Y */
  39494. Y = 3,
  39495. /** Start */
  39496. Start = 4,
  39497. /** Back */
  39498. Back = 5,
  39499. /** Left button */
  39500. LB = 6,
  39501. /** Right button */
  39502. RB = 7,
  39503. /** Left stick */
  39504. LeftStick = 8,
  39505. /** Right stick */
  39506. RightStick = 9
  39507. }
  39508. /** Defines values for XBox360 DPad */
  39509. export enum Xbox360Dpad {
  39510. /** Up */
  39511. Up = 0,
  39512. /** Down */
  39513. Down = 1,
  39514. /** Left */
  39515. Left = 2,
  39516. /** Right */
  39517. Right = 3
  39518. }
  39519. /**
  39520. * Defines a XBox360 gamepad
  39521. */
  39522. export class Xbox360Pad extends Gamepad {
  39523. private _leftTrigger;
  39524. private _rightTrigger;
  39525. private _onlefttriggerchanged;
  39526. private _onrighttriggerchanged;
  39527. private _onbuttondown;
  39528. private _onbuttonup;
  39529. private _ondpaddown;
  39530. private _ondpadup;
  39531. /** Observable raised when a button is pressed */
  39532. onButtonDownObservable: Observable<Xbox360Button>;
  39533. /** Observable raised when a button is released */
  39534. onButtonUpObservable: Observable<Xbox360Button>;
  39535. /** Observable raised when a pad is pressed */
  39536. onPadDownObservable: Observable<Xbox360Dpad>;
  39537. /** Observable raised when a pad is released */
  39538. onPadUpObservable: Observable<Xbox360Dpad>;
  39539. private _buttonA;
  39540. private _buttonB;
  39541. private _buttonX;
  39542. private _buttonY;
  39543. private _buttonBack;
  39544. private _buttonStart;
  39545. private _buttonLB;
  39546. private _buttonRB;
  39547. private _buttonLeftStick;
  39548. private _buttonRightStick;
  39549. private _dPadUp;
  39550. private _dPadDown;
  39551. private _dPadLeft;
  39552. private _dPadRight;
  39553. private _isXboxOnePad;
  39554. /**
  39555. * Creates a new XBox360 gamepad object
  39556. * @param id defines the id of this gamepad
  39557. * @param index defines its index
  39558. * @param gamepad defines the internal HTML gamepad object
  39559. * @param xboxOne defines if it is a XBox One gamepad
  39560. */
  39561. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39562. /**
  39563. * Defines the callback to call when left trigger is pressed
  39564. * @param callback defines the callback to use
  39565. */
  39566. onlefttriggerchanged(callback: (value: number) => void): void;
  39567. /**
  39568. * Defines the callback to call when right trigger is pressed
  39569. * @param callback defines the callback to use
  39570. */
  39571. onrighttriggerchanged(callback: (value: number) => void): void;
  39572. /**
  39573. * Gets the left trigger value
  39574. */
  39575. /**
  39576. * Sets the left trigger value
  39577. */
  39578. leftTrigger: number;
  39579. /**
  39580. * Gets the right trigger value
  39581. */
  39582. /**
  39583. * Sets the right trigger value
  39584. */
  39585. rightTrigger: number;
  39586. /**
  39587. * Defines the callback to call when a button is pressed
  39588. * @param callback defines the callback to use
  39589. */
  39590. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39591. /**
  39592. * Defines the callback to call when a button is released
  39593. * @param callback defines the callback to use
  39594. */
  39595. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39596. /**
  39597. * Defines the callback to call when a pad is pressed
  39598. * @param callback defines the callback to use
  39599. */
  39600. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39601. /**
  39602. * Defines the callback to call when a pad is released
  39603. * @param callback defines the callback to use
  39604. */
  39605. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39606. private _setButtonValue;
  39607. private _setDPadValue;
  39608. /**
  39609. * Gets the value of the `A` button
  39610. */
  39611. /**
  39612. * Sets the value of the `A` button
  39613. */
  39614. buttonA: number;
  39615. /**
  39616. * Gets the value of the `B` button
  39617. */
  39618. /**
  39619. * Sets the value of the `B` button
  39620. */
  39621. buttonB: number;
  39622. /**
  39623. * Gets the value of the `X` button
  39624. */
  39625. /**
  39626. * Sets the value of the `X` button
  39627. */
  39628. buttonX: number;
  39629. /**
  39630. * Gets the value of the `Y` button
  39631. */
  39632. /**
  39633. * Sets the value of the `Y` button
  39634. */
  39635. buttonY: number;
  39636. /**
  39637. * Gets the value of the `Start` button
  39638. */
  39639. /**
  39640. * Sets the value of the `Start` button
  39641. */
  39642. buttonStart: number;
  39643. /**
  39644. * Gets the value of the `Back` button
  39645. */
  39646. /**
  39647. * Sets the value of the `Back` button
  39648. */
  39649. buttonBack: number;
  39650. /**
  39651. * Gets the value of the `Left` button
  39652. */
  39653. /**
  39654. * Sets the value of the `Left` button
  39655. */
  39656. buttonLB: number;
  39657. /**
  39658. * Gets the value of the `Right` button
  39659. */
  39660. /**
  39661. * Sets the value of the `Right` button
  39662. */
  39663. buttonRB: number;
  39664. /**
  39665. * Gets the value of the Left joystick
  39666. */
  39667. /**
  39668. * Sets the value of the Left joystick
  39669. */
  39670. buttonLeftStick: number;
  39671. /**
  39672. * Gets the value of the Right joystick
  39673. */
  39674. /**
  39675. * Sets the value of the Right joystick
  39676. */
  39677. buttonRightStick: number;
  39678. /**
  39679. * Gets the value of D-pad up
  39680. */
  39681. /**
  39682. * Sets the value of D-pad up
  39683. */
  39684. dPadUp: number;
  39685. /**
  39686. * Gets the value of D-pad down
  39687. */
  39688. /**
  39689. * Sets the value of D-pad down
  39690. */
  39691. dPadDown: number;
  39692. /**
  39693. * Gets the value of D-pad left
  39694. */
  39695. /**
  39696. * Sets the value of D-pad left
  39697. */
  39698. dPadLeft: number;
  39699. /**
  39700. * Gets the value of D-pad right
  39701. */
  39702. /**
  39703. * Sets the value of D-pad right
  39704. */
  39705. dPadRight: number;
  39706. /**
  39707. * Force the gamepad to synchronize with device values
  39708. */
  39709. update(): void;
  39710. /**
  39711. * Disposes the gamepad
  39712. */
  39713. dispose(): void;
  39714. }
  39715. }
  39716. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39717. import { Observable } from "babylonjs/Misc/observable";
  39718. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39719. /**
  39720. * Defines supported buttons for DualShock compatible gamepads
  39721. */
  39722. export enum DualShockButton {
  39723. /** Cross */
  39724. Cross = 0,
  39725. /** Circle */
  39726. Circle = 1,
  39727. /** Square */
  39728. Square = 2,
  39729. /** Triangle */
  39730. Triangle = 3,
  39731. /** Options */
  39732. Options = 4,
  39733. /** Share */
  39734. Share = 5,
  39735. /** L1 */
  39736. L1 = 6,
  39737. /** R1 */
  39738. R1 = 7,
  39739. /** Left stick */
  39740. LeftStick = 8,
  39741. /** Right stick */
  39742. RightStick = 9
  39743. }
  39744. /** Defines values for DualShock DPad */
  39745. export enum DualShockDpad {
  39746. /** Up */
  39747. Up = 0,
  39748. /** Down */
  39749. Down = 1,
  39750. /** Left */
  39751. Left = 2,
  39752. /** Right */
  39753. Right = 3
  39754. }
  39755. /**
  39756. * Defines a DualShock gamepad
  39757. */
  39758. export class DualShockPad extends Gamepad {
  39759. private _leftTrigger;
  39760. private _rightTrigger;
  39761. private _onlefttriggerchanged;
  39762. private _onrighttriggerchanged;
  39763. private _onbuttondown;
  39764. private _onbuttonup;
  39765. private _ondpaddown;
  39766. private _ondpadup;
  39767. /** Observable raised when a button is pressed */
  39768. onButtonDownObservable: Observable<DualShockButton>;
  39769. /** Observable raised when a button is released */
  39770. onButtonUpObservable: Observable<DualShockButton>;
  39771. /** Observable raised when a pad is pressed */
  39772. onPadDownObservable: Observable<DualShockDpad>;
  39773. /** Observable raised when a pad is released */
  39774. onPadUpObservable: Observable<DualShockDpad>;
  39775. private _buttonCross;
  39776. private _buttonCircle;
  39777. private _buttonSquare;
  39778. private _buttonTriangle;
  39779. private _buttonShare;
  39780. private _buttonOptions;
  39781. private _buttonL1;
  39782. private _buttonR1;
  39783. private _buttonLeftStick;
  39784. private _buttonRightStick;
  39785. private _dPadUp;
  39786. private _dPadDown;
  39787. private _dPadLeft;
  39788. private _dPadRight;
  39789. /**
  39790. * Creates a new DualShock gamepad object
  39791. * @param id defines the id of this gamepad
  39792. * @param index defines its index
  39793. * @param gamepad defines the internal HTML gamepad object
  39794. */
  39795. constructor(id: string, index: number, gamepad: any);
  39796. /**
  39797. * Defines the callback to call when left trigger is pressed
  39798. * @param callback defines the callback to use
  39799. */
  39800. onlefttriggerchanged(callback: (value: number) => void): void;
  39801. /**
  39802. * Defines the callback to call when right trigger is pressed
  39803. * @param callback defines the callback to use
  39804. */
  39805. onrighttriggerchanged(callback: (value: number) => void): void;
  39806. /**
  39807. * Gets the left trigger value
  39808. */
  39809. /**
  39810. * Sets the left trigger value
  39811. */
  39812. leftTrigger: number;
  39813. /**
  39814. * Gets the right trigger value
  39815. */
  39816. /**
  39817. * Sets the right trigger value
  39818. */
  39819. rightTrigger: number;
  39820. /**
  39821. * Defines the callback to call when a button is pressed
  39822. * @param callback defines the callback to use
  39823. */
  39824. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39825. /**
  39826. * Defines the callback to call when a button is released
  39827. * @param callback defines the callback to use
  39828. */
  39829. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39830. /**
  39831. * Defines the callback to call when a pad is pressed
  39832. * @param callback defines the callback to use
  39833. */
  39834. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39835. /**
  39836. * Defines the callback to call when a pad is released
  39837. * @param callback defines the callback to use
  39838. */
  39839. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39840. private _setButtonValue;
  39841. private _setDPadValue;
  39842. /**
  39843. * Gets the value of the `Cross` button
  39844. */
  39845. /**
  39846. * Sets the value of the `Cross` button
  39847. */
  39848. buttonCross: number;
  39849. /**
  39850. * Gets the value of the `Circle` button
  39851. */
  39852. /**
  39853. * Sets the value of the `Circle` button
  39854. */
  39855. buttonCircle: number;
  39856. /**
  39857. * Gets the value of the `Square` button
  39858. */
  39859. /**
  39860. * Sets the value of the `Square` button
  39861. */
  39862. buttonSquare: number;
  39863. /**
  39864. * Gets the value of the `Triangle` button
  39865. */
  39866. /**
  39867. * Sets the value of the `Triangle` button
  39868. */
  39869. buttonTriangle: number;
  39870. /**
  39871. * Gets the value of the `Options` button
  39872. */
  39873. /**
  39874. * Sets the value of the `Options` button
  39875. */
  39876. buttonOptions: number;
  39877. /**
  39878. * Gets the value of the `Share` button
  39879. */
  39880. /**
  39881. * Sets the value of the `Share` button
  39882. */
  39883. buttonShare: number;
  39884. /**
  39885. * Gets the value of the `L1` button
  39886. */
  39887. /**
  39888. * Sets the value of the `L1` button
  39889. */
  39890. buttonL1: number;
  39891. /**
  39892. * Gets the value of the `R1` button
  39893. */
  39894. /**
  39895. * Sets the value of the `R1` button
  39896. */
  39897. buttonR1: number;
  39898. /**
  39899. * Gets the value of the Left joystick
  39900. */
  39901. /**
  39902. * Sets the value of the Left joystick
  39903. */
  39904. buttonLeftStick: number;
  39905. /**
  39906. * Gets the value of the Right joystick
  39907. */
  39908. /**
  39909. * Sets the value of the Right joystick
  39910. */
  39911. buttonRightStick: number;
  39912. /**
  39913. * Gets the value of D-pad up
  39914. */
  39915. /**
  39916. * Sets the value of D-pad up
  39917. */
  39918. dPadUp: number;
  39919. /**
  39920. * Gets the value of D-pad down
  39921. */
  39922. /**
  39923. * Sets the value of D-pad down
  39924. */
  39925. dPadDown: number;
  39926. /**
  39927. * Gets the value of D-pad left
  39928. */
  39929. /**
  39930. * Sets the value of D-pad left
  39931. */
  39932. dPadLeft: number;
  39933. /**
  39934. * Gets the value of D-pad right
  39935. */
  39936. /**
  39937. * Sets the value of D-pad right
  39938. */
  39939. dPadRight: number;
  39940. /**
  39941. * Force the gamepad to synchronize with device values
  39942. */
  39943. update(): void;
  39944. /**
  39945. * Disposes the gamepad
  39946. */
  39947. dispose(): void;
  39948. }
  39949. }
  39950. declare module "babylonjs/Gamepads/gamepadManager" {
  39951. import { Observable } from "babylonjs/Misc/observable";
  39952. import { Nullable } from "babylonjs/types";
  39953. import { Scene } from "babylonjs/scene";
  39954. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39955. /**
  39956. * Manager for handling gamepads
  39957. */
  39958. export class GamepadManager {
  39959. private _scene?;
  39960. private _babylonGamepads;
  39961. private _oneGamepadConnected;
  39962. /** @hidden */
  39963. _isMonitoring: boolean;
  39964. private _gamepadEventSupported;
  39965. private _gamepadSupport;
  39966. /**
  39967. * observable to be triggered when the gamepad controller has been connected
  39968. */
  39969. onGamepadConnectedObservable: Observable<Gamepad>;
  39970. /**
  39971. * observable to be triggered when the gamepad controller has been disconnected
  39972. */
  39973. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39974. private _onGamepadConnectedEvent;
  39975. private _onGamepadDisconnectedEvent;
  39976. /**
  39977. * Initializes the gamepad manager
  39978. * @param _scene BabylonJS scene
  39979. */
  39980. constructor(_scene?: Scene | undefined);
  39981. /**
  39982. * The gamepads in the game pad manager
  39983. */
  39984. readonly gamepads: Gamepad[];
  39985. /**
  39986. * Get the gamepad controllers based on type
  39987. * @param type The type of gamepad controller
  39988. * @returns Nullable gamepad
  39989. */
  39990. getGamepadByType(type?: number): Nullable<Gamepad>;
  39991. /**
  39992. * Disposes the gamepad manager
  39993. */
  39994. dispose(): void;
  39995. private _addNewGamepad;
  39996. private _startMonitoringGamepads;
  39997. private _stopMonitoringGamepads;
  39998. /** @hidden */
  39999. _checkGamepadsStatus(): void;
  40000. private _updateGamepadObjects;
  40001. }
  40002. }
  40003. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40004. import { Nullable } from "babylonjs/types";
  40005. import { Scene } from "babylonjs/scene";
  40006. import { ISceneComponent } from "babylonjs/sceneComponent";
  40007. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40008. module "babylonjs/scene" {
  40009. interface Scene {
  40010. /** @hidden */
  40011. _gamepadManager: Nullable<GamepadManager>;
  40012. /**
  40013. * Gets the gamepad manager associated with the scene
  40014. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40015. */
  40016. gamepadManager: GamepadManager;
  40017. }
  40018. }
  40019. module "babylonjs/Cameras/freeCameraInputsManager" {
  40020. /**
  40021. * Interface representing a free camera inputs manager
  40022. */
  40023. interface FreeCameraInputsManager {
  40024. /**
  40025. * Adds gamepad input support to the FreeCameraInputsManager.
  40026. * @returns the FreeCameraInputsManager
  40027. */
  40028. addGamepad(): FreeCameraInputsManager;
  40029. }
  40030. }
  40031. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40032. /**
  40033. * Interface representing an arc rotate camera inputs manager
  40034. */
  40035. interface ArcRotateCameraInputsManager {
  40036. /**
  40037. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40038. * @returns the camera inputs manager
  40039. */
  40040. addGamepad(): ArcRotateCameraInputsManager;
  40041. }
  40042. }
  40043. /**
  40044. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40045. */
  40046. export class GamepadSystemSceneComponent implements ISceneComponent {
  40047. /**
  40048. * The component name helpfull to identify the component in the list of scene components.
  40049. */
  40050. readonly name: string;
  40051. /**
  40052. * The scene the component belongs to.
  40053. */
  40054. scene: Scene;
  40055. /**
  40056. * Creates a new instance of the component for the given scene
  40057. * @param scene Defines the scene to register the component in
  40058. */
  40059. constructor(scene: Scene);
  40060. /**
  40061. * Registers the component in a given scene
  40062. */
  40063. register(): void;
  40064. /**
  40065. * Rebuilds the elements related to this component in case of
  40066. * context lost for instance.
  40067. */
  40068. rebuild(): void;
  40069. /**
  40070. * Disposes the component and the associated ressources
  40071. */
  40072. dispose(): void;
  40073. private _beforeCameraUpdate;
  40074. }
  40075. }
  40076. declare module "babylonjs/Cameras/universalCamera" {
  40077. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40078. import { Scene } from "babylonjs/scene";
  40079. import { Vector3 } from "babylonjs/Maths/math.vector";
  40080. import "babylonjs/Gamepads/gamepadSceneComponent";
  40081. /**
  40082. * 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,
  40083. * which still works and will still be found in many Playgrounds.
  40084. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40085. */
  40086. export class UniversalCamera extends TouchCamera {
  40087. /**
  40088. * Defines the gamepad rotation sensiblity.
  40089. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40090. */
  40091. gamepadAngularSensibility: number;
  40092. /**
  40093. * Defines the gamepad move sensiblity.
  40094. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40095. */
  40096. gamepadMoveSensibility: number;
  40097. /**
  40098. * 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,
  40099. * which still works and will still be found in many Playgrounds.
  40100. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40101. * @param name Define the name of the camera in the scene
  40102. * @param position Define the start position of the camera in the scene
  40103. * @param scene Define the scene the camera belongs to
  40104. */
  40105. constructor(name: string, position: Vector3, scene: Scene);
  40106. /**
  40107. * Gets the current object class name.
  40108. * @return the class name
  40109. */
  40110. getClassName(): string;
  40111. }
  40112. }
  40113. declare module "babylonjs/Cameras/gamepadCamera" {
  40114. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40115. import { Scene } from "babylonjs/scene";
  40116. import { Vector3 } from "babylonjs/Maths/math.vector";
  40117. /**
  40118. * This represents a FPS type of camera. This is only here for back compat purpose.
  40119. * Please use the UniversalCamera instead as both are identical.
  40120. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40121. */
  40122. export class GamepadCamera extends UniversalCamera {
  40123. /**
  40124. * Instantiates a new Gamepad Camera
  40125. * This represents a FPS type of camera. This is only here for back compat purpose.
  40126. * Please use the UniversalCamera instead as both are identical.
  40127. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40128. * @param name Define the name of the camera in the scene
  40129. * @param position Define the start position of the camera in the scene
  40130. * @param scene Define the scene the camera belongs to
  40131. */
  40132. constructor(name: string, position: Vector3, scene: Scene);
  40133. /**
  40134. * Gets the current object class name.
  40135. * @return the class name
  40136. */
  40137. getClassName(): string;
  40138. }
  40139. }
  40140. declare module "babylonjs/Shaders/pass.fragment" {
  40141. /** @hidden */
  40142. export var passPixelShader: {
  40143. name: string;
  40144. shader: string;
  40145. };
  40146. }
  40147. declare module "babylonjs/Shaders/passCube.fragment" {
  40148. /** @hidden */
  40149. export var passCubePixelShader: {
  40150. name: string;
  40151. shader: string;
  40152. };
  40153. }
  40154. declare module "babylonjs/PostProcesses/passPostProcess" {
  40155. import { Nullable } from "babylonjs/types";
  40156. import { Camera } from "babylonjs/Cameras/camera";
  40157. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40158. import { Engine } from "babylonjs/Engines/engine";
  40159. import "babylonjs/Shaders/pass.fragment";
  40160. import "babylonjs/Shaders/passCube.fragment";
  40161. /**
  40162. * PassPostProcess which produces an output the same as it's input
  40163. */
  40164. export class PassPostProcess extends PostProcess {
  40165. /**
  40166. * Creates the PassPostProcess
  40167. * @param name The name of the effect.
  40168. * @param options The required width/height ratio to downsize to before computing the render pass.
  40169. * @param camera The camera to apply the render pass to.
  40170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40171. * @param engine The engine which the post process will be applied. (default: current engine)
  40172. * @param reusable If the post process can be reused on the same frame. (default: false)
  40173. * @param textureType The type of texture to be used when performing the post processing.
  40174. * @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)
  40175. */
  40176. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40177. }
  40178. /**
  40179. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40180. */
  40181. export class PassCubePostProcess extends PostProcess {
  40182. private _face;
  40183. /**
  40184. * Gets or sets the cube face to display.
  40185. * * 0 is +X
  40186. * * 1 is -X
  40187. * * 2 is +Y
  40188. * * 3 is -Y
  40189. * * 4 is +Z
  40190. * * 5 is -Z
  40191. */
  40192. face: number;
  40193. /**
  40194. * Creates the PassCubePostProcess
  40195. * @param name The name of the effect.
  40196. * @param options The required width/height ratio to downsize to before computing the render pass.
  40197. * @param camera The camera to apply the render pass to.
  40198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40199. * @param engine The engine which the post process will be applied. (default: current engine)
  40200. * @param reusable If the post process can be reused on the same frame. (default: false)
  40201. * @param textureType The type of texture to be used when performing the post processing.
  40202. * @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)
  40203. */
  40204. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40205. }
  40206. }
  40207. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40208. /** @hidden */
  40209. export var anaglyphPixelShader: {
  40210. name: string;
  40211. shader: string;
  40212. };
  40213. }
  40214. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40215. import { Engine } from "babylonjs/Engines/engine";
  40216. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40217. import { Camera } from "babylonjs/Cameras/camera";
  40218. import "babylonjs/Shaders/anaglyph.fragment";
  40219. /**
  40220. * Postprocess used to generate anaglyphic rendering
  40221. */
  40222. export class AnaglyphPostProcess extends PostProcess {
  40223. private _passedProcess;
  40224. /**
  40225. * Creates a new AnaglyphPostProcess
  40226. * @param name defines postprocess name
  40227. * @param options defines creation options or target ratio scale
  40228. * @param rigCameras defines cameras using this postprocess
  40229. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40230. * @param engine defines hosting engine
  40231. * @param reusable defines if the postprocess will be reused multiple times per frame
  40232. */
  40233. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40234. }
  40235. }
  40236. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40237. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40238. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40239. import { Scene } from "babylonjs/scene";
  40240. import { Vector3 } from "babylonjs/Maths/math.vector";
  40241. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40242. /**
  40243. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40244. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40245. */
  40246. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40247. /**
  40248. * Creates a new AnaglyphArcRotateCamera
  40249. * @param name defines camera name
  40250. * @param alpha defines alpha angle (in radians)
  40251. * @param beta defines beta angle (in radians)
  40252. * @param radius defines radius
  40253. * @param target defines camera target
  40254. * @param interaxialDistance defines distance between each color axis
  40255. * @param scene defines the hosting scene
  40256. */
  40257. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40258. /**
  40259. * Gets camera class name
  40260. * @returns AnaglyphArcRotateCamera
  40261. */
  40262. getClassName(): string;
  40263. }
  40264. }
  40265. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40266. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40267. import { Scene } from "babylonjs/scene";
  40268. import { Vector3 } from "babylonjs/Maths/math.vector";
  40269. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40270. /**
  40271. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40272. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40273. */
  40274. export class AnaglyphFreeCamera extends FreeCamera {
  40275. /**
  40276. * Creates a new AnaglyphFreeCamera
  40277. * @param name defines camera name
  40278. * @param position defines initial position
  40279. * @param interaxialDistance defines distance between each color axis
  40280. * @param scene defines the hosting scene
  40281. */
  40282. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40283. /**
  40284. * Gets camera class name
  40285. * @returns AnaglyphFreeCamera
  40286. */
  40287. getClassName(): string;
  40288. }
  40289. }
  40290. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40291. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40292. import { Scene } from "babylonjs/scene";
  40293. import { Vector3 } from "babylonjs/Maths/math.vector";
  40294. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40295. /**
  40296. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40297. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40298. */
  40299. export class AnaglyphGamepadCamera extends GamepadCamera {
  40300. /**
  40301. * Creates a new AnaglyphGamepadCamera
  40302. * @param name defines camera name
  40303. * @param position defines initial position
  40304. * @param interaxialDistance defines distance between each color axis
  40305. * @param scene defines the hosting scene
  40306. */
  40307. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40308. /**
  40309. * Gets camera class name
  40310. * @returns AnaglyphGamepadCamera
  40311. */
  40312. getClassName(): string;
  40313. }
  40314. }
  40315. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40316. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40317. import { Scene } from "babylonjs/scene";
  40318. import { Vector3 } from "babylonjs/Maths/math.vector";
  40319. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40320. /**
  40321. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40322. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40323. */
  40324. export class AnaglyphUniversalCamera extends UniversalCamera {
  40325. /**
  40326. * Creates a new AnaglyphUniversalCamera
  40327. * @param name defines camera name
  40328. * @param position defines initial position
  40329. * @param interaxialDistance defines distance between each color axis
  40330. * @param scene defines the hosting scene
  40331. */
  40332. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40333. /**
  40334. * Gets camera class name
  40335. * @returns AnaglyphUniversalCamera
  40336. */
  40337. getClassName(): string;
  40338. }
  40339. }
  40340. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40341. /** @hidden */
  40342. export var stereoscopicInterlacePixelShader: {
  40343. name: string;
  40344. shader: string;
  40345. };
  40346. }
  40347. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40348. import { Camera } from "babylonjs/Cameras/camera";
  40349. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40350. import { Engine } from "babylonjs/Engines/engine";
  40351. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40352. /**
  40353. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40354. */
  40355. export class StereoscopicInterlacePostProcess extends PostProcess {
  40356. private _stepSize;
  40357. private _passedProcess;
  40358. /**
  40359. * Initializes a StereoscopicInterlacePostProcess
  40360. * @param name The name of the effect.
  40361. * @param rigCameras The rig cameras to be appled to the post process
  40362. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40364. * @param engine The engine which the post process will be applied. (default: current engine)
  40365. * @param reusable If the post process can be reused on the same frame. (default: false)
  40366. */
  40367. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40368. }
  40369. }
  40370. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40371. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40372. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40373. import { Scene } from "babylonjs/scene";
  40374. import { Vector3 } from "babylonjs/Maths/math.vector";
  40375. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40376. /**
  40377. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40378. * @see http://doc.babylonjs.com/features/cameras
  40379. */
  40380. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40381. /**
  40382. * Creates a new StereoscopicArcRotateCamera
  40383. * @param name defines camera name
  40384. * @param alpha defines alpha angle (in radians)
  40385. * @param beta defines beta angle (in radians)
  40386. * @param radius defines radius
  40387. * @param target defines camera target
  40388. * @param interaxialDistance defines distance between each color axis
  40389. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40390. * @param scene defines the hosting scene
  40391. */
  40392. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40393. /**
  40394. * Gets camera class name
  40395. * @returns StereoscopicArcRotateCamera
  40396. */
  40397. getClassName(): string;
  40398. }
  40399. }
  40400. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40401. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40402. import { Scene } from "babylonjs/scene";
  40403. import { Vector3 } from "babylonjs/Maths/math.vector";
  40404. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40405. /**
  40406. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40407. * @see http://doc.babylonjs.com/features/cameras
  40408. */
  40409. export class StereoscopicFreeCamera extends FreeCamera {
  40410. /**
  40411. * Creates a new StereoscopicFreeCamera
  40412. * @param name defines camera name
  40413. * @param position defines initial position
  40414. * @param interaxialDistance defines distance between each color axis
  40415. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40416. * @param scene defines the hosting scene
  40417. */
  40418. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40419. /**
  40420. * Gets camera class name
  40421. * @returns StereoscopicFreeCamera
  40422. */
  40423. getClassName(): string;
  40424. }
  40425. }
  40426. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40427. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40428. import { Scene } from "babylonjs/scene";
  40429. import { Vector3 } from "babylonjs/Maths/math.vector";
  40430. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40431. /**
  40432. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40433. * @see http://doc.babylonjs.com/features/cameras
  40434. */
  40435. export class StereoscopicGamepadCamera extends GamepadCamera {
  40436. /**
  40437. * Creates a new StereoscopicGamepadCamera
  40438. * @param name defines camera name
  40439. * @param position defines initial position
  40440. * @param interaxialDistance defines distance between each color axis
  40441. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40442. * @param scene defines the hosting scene
  40443. */
  40444. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40445. /**
  40446. * Gets camera class name
  40447. * @returns StereoscopicGamepadCamera
  40448. */
  40449. getClassName(): string;
  40450. }
  40451. }
  40452. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40453. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40454. import { Scene } from "babylonjs/scene";
  40455. import { Vector3 } from "babylonjs/Maths/math.vector";
  40456. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40457. /**
  40458. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40459. * @see http://doc.babylonjs.com/features/cameras
  40460. */
  40461. export class StereoscopicUniversalCamera extends UniversalCamera {
  40462. /**
  40463. * Creates a new StereoscopicUniversalCamera
  40464. * @param name defines camera name
  40465. * @param position defines initial position
  40466. * @param interaxialDistance defines distance between each color axis
  40467. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40468. * @param scene defines the hosting scene
  40469. */
  40470. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40471. /**
  40472. * Gets camera class name
  40473. * @returns StereoscopicUniversalCamera
  40474. */
  40475. getClassName(): string;
  40476. }
  40477. }
  40478. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40479. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40480. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40481. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40482. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40483. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40484. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40485. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40486. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40487. }
  40488. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40489. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40490. import { Scene } from "babylonjs/scene";
  40491. import { Vector3 } from "babylonjs/Maths/math.vector";
  40492. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40493. /**
  40494. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40495. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40496. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40497. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40498. */
  40499. export class VirtualJoysticksCamera extends FreeCamera {
  40500. /**
  40501. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40502. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40503. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40504. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40505. * @param name Define the name of the camera in the scene
  40506. * @param position Define the start position of the camera in the scene
  40507. * @param scene Define the scene the camera belongs to
  40508. */
  40509. constructor(name: string, position: Vector3, scene: Scene);
  40510. /**
  40511. * Gets the current object class name.
  40512. * @return the class name
  40513. */
  40514. getClassName(): string;
  40515. }
  40516. }
  40517. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40518. import { Matrix } from "babylonjs/Maths/math.vector";
  40519. /**
  40520. * This represents all the required metrics to create a VR camera.
  40521. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40522. */
  40523. export class VRCameraMetrics {
  40524. /**
  40525. * Define the horizontal resolution off the screen.
  40526. */
  40527. hResolution: number;
  40528. /**
  40529. * Define the vertical resolution off the screen.
  40530. */
  40531. vResolution: number;
  40532. /**
  40533. * Define the horizontal screen size.
  40534. */
  40535. hScreenSize: number;
  40536. /**
  40537. * Define the vertical screen size.
  40538. */
  40539. vScreenSize: number;
  40540. /**
  40541. * Define the vertical screen center position.
  40542. */
  40543. vScreenCenter: number;
  40544. /**
  40545. * Define the distance of the eyes to the screen.
  40546. */
  40547. eyeToScreenDistance: number;
  40548. /**
  40549. * Define the distance between both lenses
  40550. */
  40551. lensSeparationDistance: number;
  40552. /**
  40553. * Define the distance between both viewer's eyes.
  40554. */
  40555. interpupillaryDistance: number;
  40556. /**
  40557. * Define the distortion factor of the VR postprocess.
  40558. * Please, touch with care.
  40559. */
  40560. distortionK: number[];
  40561. /**
  40562. * Define the chromatic aberration correction factors for the VR post process.
  40563. */
  40564. chromaAbCorrection: number[];
  40565. /**
  40566. * Define the scale factor of the post process.
  40567. * The smaller the better but the slower.
  40568. */
  40569. postProcessScaleFactor: number;
  40570. /**
  40571. * Define an offset for the lens center.
  40572. */
  40573. lensCenterOffset: number;
  40574. /**
  40575. * Define if the current vr camera should compensate the distortion of the lense or not.
  40576. */
  40577. compensateDistortion: boolean;
  40578. /**
  40579. * Defines if multiview should be enabled when rendering (Default: false)
  40580. */
  40581. multiviewEnabled: boolean;
  40582. /**
  40583. * Gets the rendering aspect ratio based on the provided resolutions.
  40584. */
  40585. readonly aspectRatio: number;
  40586. /**
  40587. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40588. */
  40589. readonly aspectRatioFov: number;
  40590. /**
  40591. * @hidden
  40592. */
  40593. readonly leftHMatrix: Matrix;
  40594. /**
  40595. * @hidden
  40596. */
  40597. readonly rightHMatrix: Matrix;
  40598. /**
  40599. * @hidden
  40600. */
  40601. readonly leftPreViewMatrix: Matrix;
  40602. /**
  40603. * @hidden
  40604. */
  40605. readonly rightPreViewMatrix: Matrix;
  40606. /**
  40607. * Get the default VRMetrics based on the most generic setup.
  40608. * @returns the default vr metrics
  40609. */
  40610. static GetDefault(): VRCameraMetrics;
  40611. }
  40612. }
  40613. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40614. /** @hidden */
  40615. export var vrDistortionCorrectionPixelShader: {
  40616. name: string;
  40617. shader: string;
  40618. };
  40619. }
  40620. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40621. import { Camera } from "babylonjs/Cameras/camera";
  40622. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40623. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40624. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40625. /**
  40626. * VRDistortionCorrectionPostProcess used for mobile VR
  40627. */
  40628. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40629. private _isRightEye;
  40630. private _distortionFactors;
  40631. private _postProcessScaleFactor;
  40632. private _lensCenterOffset;
  40633. private _scaleIn;
  40634. private _scaleFactor;
  40635. private _lensCenter;
  40636. /**
  40637. * Initializes the VRDistortionCorrectionPostProcess
  40638. * @param name The name of the effect.
  40639. * @param camera The camera to apply the render pass to.
  40640. * @param isRightEye If this is for the right eye distortion
  40641. * @param vrMetrics All the required metrics for the VR camera
  40642. */
  40643. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40644. }
  40645. }
  40646. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40647. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40648. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40649. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40650. import { Scene } from "babylonjs/scene";
  40651. import { Vector3 } from "babylonjs/Maths/math.vector";
  40652. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40653. import "babylonjs/Cameras/RigModes/vrRigMode";
  40654. /**
  40655. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40656. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40657. */
  40658. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40659. /**
  40660. * Creates a new VRDeviceOrientationArcRotateCamera
  40661. * @param name defines camera name
  40662. * @param alpha defines the camera rotation along the logitudinal axis
  40663. * @param beta defines the camera rotation along the latitudinal axis
  40664. * @param radius defines the camera distance from its target
  40665. * @param target defines the camera target
  40666. * @param scene defines the scene the camera belongs to
  40667. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40668. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40669. */
  40670. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40671. /**
  40672. * Gets camera class name
  40673. * @returns VRDeviceOrientationArcRotateCamera
  40674. */
  40675. getClassName(): string;
  40676. }
  40677. }
  40678. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40679. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40680. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40681. import { Scene } from "babylonjs/scene";
  40682. import { Vector3 } from "babylonjs/Maths/math.vector";
  40683. import "babylonjs/Cameras/RigModes/vrRigMode";
  40684. /**
  40685. * Camera used to simulate VR rendering (based on FreeCamera)
  40686. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40687. */
  40688. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40689. /**
  40690. * Creates a new VRDeviceOrientationFreeCamera
  40691. * @param name defines camera name
  40692. * @param position defines the start position of the camera
  40693. * @param scene defines the scene the camera belongs to
  40694. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40695. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40696. */
  40697. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40698. /**
  40699. * Gets camera class name
  40700. * @returns VRDeviceOrientationFreeCamera
  40701. */
  40702. getClassName(): string;
  40703. }
  40704. }
  40705. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40706. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40707. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40708. import { Scene } from "babylonjs/scene";
  40709. import { Vector3 } from "babylonjs/Maths/math.vector";
  40710. import "babylonjs/Gamepads/gamepadSceneComponent";
  40711. /**
  40712. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40713. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40714. */
  40715. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40716. /**
  40717. * Creates a new VRDeviceOrientationGamepadCamera
  40718. * @param name defines camera name
  40719. * @param position defines the start position of the camera
  40720. * @param scene defines the scene the camera belongs to
  40721. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40722. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40723. */
  40724. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40725. /**
  40726. * Gets camera class name
  40727. * @returns VRDeviceOrientationGamepadCamera
  40728. */
  40729. getClassName(): string;
  40730. }
  40731. }
  40732. declare module "babylonjs/Materials/pushMaterial" {
  40733. import { Nullable } from "babylonjs/types";
  40734. import { Scene } from "babylonjs/scene";
  40735. import { Matrix } from "babylonjs/Maths/math.vector";
  40736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40737. import { Mesh } from "babylonjs/Meshes/mesh";
  40738. import { Material } from "babylonjs/Materials/material";
  40739. import { Effect } from "babylonjs/Materials/effect";
  40740. /**
  40741. * Base class of materials working in push mode in babylon JS
  40742. * @hidden
  40743. */
  40744. export class PushMaterial extends Material {
  40745. protected _activeEffect: Effect;
  40746. protected _normalMatrix: Matrix;
  40747. /**
  40748. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40749. * This means that the material can keep using a previous shader while a new one is being compiled.
  40750. * This is mostly used when shader parallel compilation is supported (true by default)
  40751. */
  40752. allowShaderHotSwapping: boolean;
  40753. constructor(name: string, scene: Scene);
  40754. getEffect(): Effect;
  40755. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40756. /**
  40757. * Binds the given world matrix to the active effect
  40758. *
  40759. * @param world the matrix to bind
  40760. */
  40761. bindOnlyWorldMatrix(world: Matrix): void;
  40762. /**
  40763. * Binds the given normal matrix to the active effect
  40764. *
  40765. * @param normalMatrix the matrix to bind
  40766. */
  40767. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40768. bind(world: Matrix, mesh?: Mesh): void;
  40769. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40770. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40771. }
  40772. }
  40773. declare module "babylonjs/Materials/materialFlags" {
  40774. /**
  40775. * This groups all the flags used to control the materials channel.
  40776. */
  40777. export class MaterialFlags {
  40778. private static _DiffuseTextureEnabled;
  40779. /**
  40780. * Are diffuse textures enabled in the application.
  40781. */
  40782. static DiffuseTextureEnabled: boolean;
  40783. private static _AmbientTextureEnabled;
  40784. /**
  40785. * Are ambient textures enabled in the application.
  40786. */
  40787. static AmbientTextureEnabled: boolean;
  40788. private static _OpacityTextureEnabled;
  40789. /**
  40790. * Are opacity textures enabled in the application.
  40791. */
  40792. static OpacityTextureEnabled: boolean;
  40793. private static _ReflectionTextureEnabled;
  40794. /**
  40795. * Are reflection textures enabled in the application.
  40796. */
  40797. static ReflectionTextureEnabled: boolean;
  40798. private static _EmissiveTextureEnabled;
  40799. /**
  40800. * Are emissive textures enabled in the application.
  40801. */
  40802. static EmissiveTextureEnabled: boolean;
  40803. private static _SpecularTextureEnabled;
  40804. /**
  40805. * Are specular textures enabled in the application.
  40806. */
  40807. static SpecularTextureEnabled: boolean;
  40808. private static _BumpTextureEnabled;
  40809. /**
  40810. * Are bump textures enabled in the application.
  40811. */
  40812. static BumpTextureEnabled: boolean;
  40813. private static _LightmapTextureEnabled;
  40814. /**
  40815. * Are lightmap textures enabled in the application.
  40816. */
  40817. static LightmapTextureEnabled: boolean;
  40818. private static _RefractionTextureEnabled;
  40819. /**
  40820. * Are refraction textures enabled in the application.
  40821. */
  40822. static RefractionTextureEnabled: boolean;
  40823. private static _ColorGradingTextureEnabled;
  40824. /**
  40825. * Are color grading textures enabled in the application.
  40826. */
  40827. static ColorGradingTextureEnabled: boolean;
  40828. private static _FresnelEnabled;
  40829. /**
  40830. * Are fresnels enabled in the application.
  40831. */
  40832. static FresnelEnabled: boolean;
  40833. private static _ClearCoatTextureEnabled;
  40834. /**
  40835. * Are clear coat textures enabled in the application.
  40836. */
  40837. static ClearCoatTextureEnabled: boolean;
  40838. private static _ClearCoatBumpTextureEnabled;
  40839. /**
  40840. * Are clear coat bump textures enabled in the application.
  40841. */
  40842. static ClearCoatBumpTextureEnabled: boolean;
  40843. private static _ClearCoatTintTextureEnabled;
  40844. /**
  40845. * Are clear coat tint textures enabled in the application.
  40846. */
  40847. static ClearCoatTintTextureEnabled: boolean;
  40848. private static _SheenTextureEnabled;
  40849. /**
  40850. * Are sheen textures enabled in the application.
  40851. */
  40852. static SheenTextureEnabled: boolean;
  40853. private static _AnisotropicTextureEnabled;
  40854. /**
  40855. * Are anisotropic textures enabled in the application.
  40856. */
  40857. static AnisotropicTextureEnabled: boolean;
  40858. private static _ThicknessTextureEnabled;
  40859. /**
  40860. * Are thickness textures enabled in the application.
  40861. */
  40862. static ThicknessTextureEnabled: boolean;
  40863. }
  40864. }
  40865. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40866. /** @hidden */
  40867. export var defaultFragmentDeclaration: {
  40868. name: string;
  40869. shader: string;
  40870. };
  40871. }
  40872. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40873. /** @hidden */
  40874. export var defaultUboDeclaration: {
  40875. name: string;
  40876. shader: string;
  40877. };
  40878. }
  40879. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40880. /** @hidden */
  40881. export var lightFragmentDeclaration: {
  40882. name: string;
  40883. shader: string;
  40884. };
  40885. }
  40886. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40887. /** @hidden */
  40888. export var lightUboDeclaration: {
  40889. name: string;
  40890. shader: string;
  40891. };
  40892. }
  40893. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40894. /** @hidden */
  40895. export var lightsFragmentFunctions: {
  40896. name: string;
  40897. shader: string;
  40898. };
  40899. }
  40900. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40901. /** @hidden */
  40902. export var shadowsFragmentFunctions: {
  40903. name: string;
  40904. shader: string;
  40905. };
  40906. }
  40907. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40908. /** @hidden */
  40909. export var fresnelFunction: {
  40910. name: string;
  40911. shader: string;
  40912. };
  40913. }
  40914. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40915. /** @hidden */
  40916. export var reflectionFunction: {
  40917. name: string;
  40918. shader: string;
  40919. };
  40920. }
  40921. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40922. /** @hidden */
  40923. export var bumpFragmentFunctions: {
  40924. name: string;
  40925. shader: string;
  40926. };
  40927. }
  40928. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40929. /** @hidden */
  40930. export var logDepthDeclaration: {
  40931. name: string;
  40932. shader: string;
  40933. };
  40934. }
  40935. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40936. /** @hidden */
  40937. export var bumpFragment: {
  40938. name: string;
  40939. shader: string;
  40940. };
  40941. }
  40942. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40943. /** @hidden */
  40944. export var depthPrePass: {
  40945. name: string;
  40946. shader: string;
  40947. };
  40948. }
  40949. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40950. /** @hidden */
  40951. export var lightFragment: {
  40952. name: string;
  40953. shader: string;
  40954. };
  40955. }
  40956. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40957. /** @hidden */
  40958. export var logDepthFragment: {
  40959. name: string;
  40960. shader: string;
  40961. };
  40962. }
  40963. declare module "babylonjs/Shaders/default.fragment" {
  40964. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40965. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40966. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40967. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40968. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40969. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40970. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40971. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40972. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40973. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40974. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40975. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40976. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40977. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40978. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40979. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40980. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40981. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40982. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40983. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40984. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40985. /** @hidden */
  40986. export var defaultPixelShader: {
  40987. name: string;
  40988. shader: string;
  40989. };
  40990. }
  40991. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40992. /** @hidden */
  40993. export var defaultVertexDeclaration: {
  40994. name: string;
  40995. shader: string;
  40996. };
  40997. }
  40998. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40999. /** @hidden */
  41000. export var bumpVertexDeclaration: {
  41001. name: string;
  41002. shader: string;
  41003. };
  41004. }
  41005. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41006. /** @hidden */
  41007. export var bumpVertex: {
  41008. name: string;
  41009. shader: string;
  41010. };
  41011. }
  41012. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41013. /** @hidden */
  41014. export var fogVertex: {
  41015. name: string;
  41016. shader: string;
  41017. };
  41018. }
  41019. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41020. /** @hidden */
  41021. export var shadowsVertex: {
  41022. name: string;
  41023. shader: string;
  41024. };
  41025. }
  41026. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41027. /** @hidden */
  41028. export var pointCloudVertex: {
  41029. name: string;
  41030. shader: string;
  41031. };
  41032. }
  41033. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41034. /** @hidden */
  41035. export var logDepthVertex: {
  41036. name: string;
  41037. shader: string;
  41038. };
  41039. }
  41040. declare module "babylonjs/Shaders/default.vertex" {
  41041. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41042. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41043. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41044. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41045. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41046. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41047. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41048. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41049. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41050. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41051. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41052. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41053. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41054. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41055. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41056. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41057. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41058. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41059. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41060. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41061. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41062. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41063. /** @hidden */
  41064. export var defaultVertexShader: {
  41065. name: string;
  41066. shader: string;
  41067. };
  41068. }
  41069. declare module "babylonjs/Materials/standardMaterial" {
  41070. import { SmartArray } from "babylonjs/Misc/smartArray";
  41071. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41072. import { Nullable } from "babylonjs/types";
  41073. import { Scene } from "babylonjs/scene";
  41074. import { Matrix } from "babylonjs/Maths/math.vector";
  41075. import { Color3 } from "babylonjs/Maths/math.color";
  41076. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41078. import { Mesh } from "babylonjs/Meshes/mesh";
  41079. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41080. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41081. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41083. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41085. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41086. import "babylonjs/Shaders/default.fragment";
  41087. import "babylonjs/Shaders/default.vertex";
  41088. /** @hidden */
  41089. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41090. MAINUV1: boolean;
  41091. MAINUV2: boolean;
  41092. DIFFUSE: boolean;
  41093. DIFFUSEDIRECTUV: number;
  41094. AMBIENT: boolean;
  41095. AMBIENTDIRECTUV: number;
  41096. OPACITY: boolean;
  41097. OPACITYDIRECTUV: number;
  41098. OPACITYRGB: boolean;
  41099. REFLECTION: boolean;
  41100. EMISSIVE: boolean;
  41101. EMISSIVEDIRECTUV: number;
  41102. SPECULAR: boolean;
  41103. SPECULARDIRECTUV: number;
  41104. BUMP: boolean;
  41105. BUMPDIRECTUV: number;
  41106. PARALLAX: boolean;
  41107. PARALLAXOCCLUSION: boolean;
  41108. SPECULAROVERALPHA: boolean;
  41109. CLIPPLANE: boolean;
  41110. CLIPPLANE2: boolean;
  41111. CLIPPLANE3: boolean;
  41112. CLIPPLANE4: boolean;
  41113. ALPHATEST: boolean;
  41114. DEPTHPREPASS: boolean;
  41115. ALPHAFROMDIFFUSE: boolean;
  41116. POINTSIZE: boolean;
  41117. FOG: boolean;
  41118. SPECULARTERM: boolean;
  41119. DIFFUSEFRESNEL: boolean;
  41120. OPACITYFRESNEL: boolean;
  41121. REFLECTIONFRESNEL: boolean;
  41122. REFRACTIONFRESNEL: boolean;
  41123. EMISSIVEFRESNEL: boolean;
  41124. FRESNEL: boolean;
  41125. NORMAL: boolean;
  41126. UV1: boolean;
  41127. UV2: boolean;
  41128. VERTEXCOLOR: boolean;
  41129. VERTEXALPHA: boolean;
  41130. NUM_BONE_INFLUENCERS: number;
  41131. BonesPerMesh: number;
  41132. BONETEXTURE: boolean;
  41133. INSTANCES: boolean;
  41134. GLOSSINESS: boolean;
  41135. ROUGHNESS: boolean;
  41136. EMISSIVEASILLUMINATION: boolean;
  41137. LINKEMISSIVEWITHDIFFUSE: boolean;
  41138. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41139. LIGHTMAP: boolean;
  41140. LIGHTMAPDIRECTUV: number;
  41141. OBJECTSPACE_NORMALMAP: boolean;
  41142. USELIGHTMAPASSHADOWMAP: boolean;
  41143. REFLECTIONMAP_3D: boolean;
  41144. REFLECTIONMAP_SPHERICAL: boolean;
  41145. REFLECTIONMAP_PLANAR: boolean;
  41146. REFLECTIONMAP_CUBIC: boolean;
  41147. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41148. REFLECTIONMAP_PROJECTION: boolean;
  41149. REFLECTIONMAP_SKYBOX: boolean;
  41150. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41151. REFLECTIONMAP_EXPLICIT: boolean;
  41152. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41153. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41154. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41155. INVERTCUBICMAP: boolean;
  41156. LOGARITHMICDEPTH: boolean;
  41157. REFRACTION: boolean;
  41158. REFRACTIONMAP_3D: boolean;
  41159. REFLECTIONOVERALPHA: boolean;
  41160. TWOSIDEDLIGHTING: boolean;
  41161. SHADOWFLOAT: boolean;
  41162. MORPHTARGETS: boolean;
  41163. MORPHTARGETS_NORMAL: boolean;
  41164. MORPHTARGETS_TANGENT: boolean;
  41165. MORPHTARGETS_UV: boolean;
  41166. NUM_MORPH_INFLUENCERS: number;
  41167. NONUNIFORMSCALING: boolean;
  41168. PREMULTIPLYALPHA: boolean;
  41169. IMAGEPROCESSING: boolean;
  41170. VIGNETTE: boolean;
  41171. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41172. VIGNETTEBLENDMODEOPAQUE: boolean;
  41173. TONEMAPPING: boolean;
  41174. TONEMAPPING_ACES: boolean;
  41175. CONTRAST: boolean;
  41176. COLORCURVES: boolean;
  41177. COLORGRADING: boolean;
  41178. COLORGRADING3D: boolean;
  41179. SAMPLER3DGREENDEPTH: boolean;
  41180. SAMPLER3DBGRMAP: boolean;
  41181. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41182. MULTIVIEW: boolean;
  41183. /**
  41184. * If the reflection texture on this material is in linear color space
  41185. * @hidden
  41186. */
  41187. IS_REFLECTION_LINEAR: boolean;
  41188. /**
  41189. * If the refraction texture on this material is in linear color space
  41190. * @hidden
  41191. */
  41192. IS_REFRACTION_LINEAR: boolean;
  41193. EXPOSURE: boolean;
  41194. constructor();
  41195. setReflectionMode(modeToEnable: string): void;
  41196. }
  41197. /**
  41198. * This is the default material used in Babylon. It is the best trade off between quality
  41199. * and performances.
  41200. * @see http://doc.babylonjs.com/babylon101/materials
  41201. */
  41202. export class StandardMaterial extends PushMaterial {
  41203. private _diffuseTexture;
  41204. /**
  41205. * The basic texture of the material as viewed under a light.
  41206. */
  41207. diffuseTexture: Nullable<BaseTexture>;
  41208. private _ambientTexture;
  41209. /**
  41210. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41211. */
  41212. ambientTexture: Nullable<BaseTexture>;
  41213. private _opacityTexture;
  41214. /**
  41215. * Define the transparency of the material from a texture.
  41216. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41217. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41218. */
  41219. opacityTexture: Nullable<BaseTexture>;
  41220. private _reflectionTexture;
  41221. /**
  41222. * Define the texture used to display the reflection.
  41223. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41224. */
  41225. reflectionTexture: Nullable<BaseTexture>;
  41226. private _emissiveTexture;
  41227. /**
  41228. * Define texture of the material as if self lit.
  41229. * This will be mixed in the final result even in the absence of light.
  41230. */
  41231. emissiveTexture: Nullable<BaseTexture>;
  41232. private _specularTexture;
  41233. /**
  41234. * Define how the color and intensity of the highlight given by the light in the material.
  41235. */
  41236. specularTexture: Nullable<BaseTexture>;
  41237. private _bumpTexture;
  41238. /**
  41239. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41240. * 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.
  41241. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41242. */
  41243. bumpTexture: Nullable<BaseTexture>;
  41244. private _lightmapTexture;
  41245. /**
  41246. * Complex lighting can be computationally expensive to compute at runtime.
  41247. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41248. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41249. */
  41250. lightmapTexture: Nullable<BaseTexture>;
  41251. private _refractionTexture;
  41252. /**
  41253. * Define the texture used to display the refraction.
  41254. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41255. */
  41256. refractionTexture: Nullable<BaseTexture>;
  41257. /**
  41258. * The color of the material lit by the environmental background lighting.
  41259. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41260. */
  41261. ambientColor: Color3;
  41262. /**
  41263. * The basic color of the material as viewed under a light.
  41264. */
  41265. diffuseColor: Color3;
  41266. /**
  41267. * Define how the color and intensity of the highlight given by the light in the material.
  41268. */
  41269. specularColor: Color3;
  41270. /**
  41271. * Define the color of the material as if self lit.
  41272. * This will be mixed in the final result even in the absence of light.
  41273. */
  41274. emissiveColor: Color3;
  41275. /**
  41276. * Defines how sharp are the highlights in the material.
  41277. * The bigger the value the sharper giving a more glossy feeling to the result.
  41278. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41279. */
  41280. specularPower: number;
  41281. private _useAlphaFromDiffuseTexture;
  41282. /**
  41283. * Does the transparency come from the diffuse texture alpha channel.
  41284. */
  41285. useAlphaFromDiffuseTexture: boolean;
  41286. private _useEmissiveAsIllumination;
  41287. /**
  41288. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41289. */
  41290. useEmissiveAsIllumination: boolean;
  41291. private _linkEmissiveWithDiffuse;
  41292. /**
  41293. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41294. * the emissive level when the final color is close to one.
  41295. */
  41296. linkEmissiveWithDiffuse: boolean;
  41297. private _useSpecularOverAlpha;
  41298. /**
  41299. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41300. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41301. */
  41302. useSpecularOverAlpha: boolean;
  41303. private _useReflectionOverAlpha;
  41304. /**
  41305. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41306. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41307. */
  41308. useReflectionOverAlpha: boolean;
  41309. private _disableLighting;
  41310. /**
  41311. * Does lights from the scene impacts this material.
  41312. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41313. */
  41314. disableLighting: boolean;
  41315. private _useObjectSpaceNormalMap;
  41316. /**
  41317. * Allows using an object space normal map (instead of tangent space).
  41318. */
  41319. useObjectSpaceNormalMap: boolean;
  41320. private _useParallax;
  41321. /**
  41322. * Is parallax enabled or not.
  41323. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41324. */
  41325. useParallax: boolean;
  41326. private _useParallaxOcclusion;
  41327. /**
  41328. * Is parallax occlusion enabled or not.
  41329. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41330. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41331. */
  41332. useParallaxOcclusion: boolean;
  41333. /**
  41334. * 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.
  41335. */
  41336. parallaxScaleBias: number;
  41337. private _roughness;
  41338. /**
  41339. * Helps to define how blurry the reflections should appears in the material.
  41340. */
  41341. roughness: number;
  41342. /**
  41343. * In case of refraction, define the value of the index of refraction.
  41344. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41345. */
  41346. indexOfRefraction: number;
  41347. /**
  41348. * Invert the refraction texture alongside the y axis.
  41349. * It can be useful with procedural textures or probe for instance.
  41350. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41351. */
  41352. invertRefractionY: boolean;
  41353. /**
  41354. * Defines the alpha limits in alpha test mode.
  41355. */
  41356. alphaCutOff: number;
  41357. private _useLightmapAsShadowmap;
  41358. /**
  41359. * In case of light mapping, define whether the map contains light or shadow informations.
  41360. */
  41361. useLightmapAsShadowmap: boolean;
  41362. private _diffuseFresnelParameters;
  41363. /**
  41364. * Define the diffuse fresnel parameters of the material.
  41365. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41366. */
  41367. diffuseFresnelParameters: FresnelParameters;
  41368. private _opacityFresnelParameters;
  41369. /**
  41370. * Define the opacity fresnel parameters of the material.
  41371. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41372. */
  41373. opacityFresnelParameters: FresnelParameters;
  41374. private _reflectionFresnelParameters;
  41375. /**
  41376. * Define the reflection fresnel parameters of the material.
  41377. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41378. */
  41379. reflectionFresnelParameters: FresnelParameters;
  41380. private _refractionFresnelParameters;
  41381. /**
  41382. * Define the refraction fresnel parameters of the material.
  41383. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41384. */
  41385. refractionFresnelParameters: FresnelParameters;
  41386. private _emissiveFresnelParameters;
  41387. /**
  41388. * Define the emissive fresnel parameters of the material.
  41389. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41390. */
  41391. emissiveFresnelParameters: FresnelParameters;
  41392. private _useReflectionFresnelFromSpecular;
  41393. /**
  41394. * If true automatically deducts the fresnels values from the material specularity.
  41395. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41396. */
  41397. useReflectionFresnelFromSpecular: boolean;
  41398. private _useGlossinessFromSpecularMapAlpha;
  41399. /**
  41400. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41401. */
  41402. useGlossinessFromSpecularMapAlpha: boolean;
  41403. private _maxSimultaneousLights;
  41404. /**
  41405. * Defines the maximum number of lights that can be used in the material
  41406. */
  41407. maxSimultaneousLights: number;
  41408. private _invertNormalMapX;
  41409. /**
  41410. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41411. */
  41412. invertNormalMapX: boolean;
  41413. private _invertNormalMapY;
  41414. /**
  41415. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41416. */
  41417. invertNormalMapY: boolean;
  41418. private _twoSidedLighting;
  41419. /**
  41420. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41421. */
  41422. twoSidedLighting: boolean;
  41423. /**
  41424. * Default configuration related to image processing available in the standard Material.
  41425. */
  41426. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41427. /**
  41428. * Gets the image processing configuration used either in this material.
  41429. */
  41430. /**
  41431. * Sets the Default image processing configuration used either in the this material.
  41432. *
  41433. * If sets to null, the scene one is in use.
  41434. */
  41435. imageProcessingConfiguration: ImageProcessingConfiguration;
  41436. /**
  41437. * Keep track of the image processing observer to allow dispose and replace.
  41438. */
  41439. private _imageProcessingObserver;
  41440. /**
  41441. * Attaches a new image processing configuration to the Standard Material.
  41442. * @param configuration
  41443. */
  41444. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41445. /**
  41446. * Gets wether the color curves effect is enabled.
  41447. */
  41448. /**
  41449. * Sets wether the color curves effect is enabled.
  41450. */
  41451. cameraColorCurvesEnabled: boolean;
  41452. /**
  41453. * Gets wether the color grading effect is enabled.
  41454. */
  41455. /**
  41456. * Gets wether the color grading effect is enabled.
  41457. */
  41458. cameraColorGradingEnabled: boolean;
  41459. /**
  41460. * Gets wether tonemapping is enabled or not.
  41461. */
  41462. /**
  41463. * Sets wether tonemapping is enabled or not
  41464. */
  41465. cameraToneMappingEnabled: boolean;
  41466. /**
  41467. * The camera exposure used on this material.
  41468. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41469. * This corresponds to a photographic exposure.
  41470. */
  41471. /**
  41472. * The camera exposure used on this material.
  41473. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41474. * This corresponds to a photographic exposure.
  41475. */
  41476. cameraExposure: number;
  41477. /**
  41478. * Gets The camera contrast used on this material.
  41479. */
  41480. /**
  41481. * Sets The camera contrast used on this material.
  41482. */
  41483. cameraContrast: number;
  41484. /**
  41485. * Gets the Color Grading 2D Lookup Texture.
  41486. */
  41487. /**
  41488. * Sets the Color Grading 2D Lookup Texture.
  41489. */
  41490. cameraColorGradingTexture: Nullable<BaseTexture>;
  41491. /**
  41492. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41493. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41494. * 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;
  41495. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41496. */
  41497. /**
  41498. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41499. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41500. * 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;
  41501. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41502. */
  41503. cameraColorCurves: Nullable<ColorCurves>;
  41504. /**
  41505. * Custom callback helping to override the default shader used in the material.
  41506. */
  41507. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41508. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41509. protected _worldViewProjectionMatrix: Matrix;
  41510. protected _globalAmbientColor: Color3;
  41511. protected _useLogarithmicDepth: boolean;
  41512. /**
  41513. * Instantiates a new standard material.
  41514. * This is the default material used in Babylon. It is the best trade off between quality
  41515. * and performances.
  41516. * @see http://doc.babylonjs.com/babylon101/materials
  41517. * @param name Define the name of the material in the scene
  41518. * @param scene Define the scene the material belong to
  41519. */
  41520. constructor(name: string, scene: Scene);
  41521. /**
  41522. * Gets a boolean indicating that current material needs to register RTT
  41523. */
  41524. readonly hasRenderTargetTextures: boolean;
  41525. /**
  41526. * Gets the current class name of the material e.g. "StandardMaterial"
  41527. * Mainly use in serialization.
  41528. * @returns the class name
  41529. */
  41530. getClassName(): string;
  41531. /**
  41532. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41533. * You can try switching to logarithmic depth.
  41534. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41535. */
  41536. useLogarithmicDepth: boolean;
  41537. /**
  41538. * Specifies if the material will require alpha blending
  41539. * @returns a boolean specifying if alpha blending is needed
  41540. */
  41541. needAlphaBlending(): boolean;
  41542. /**
  41543. * Specifies if this material should be rendered in alpha test mode
  41544. * @returns a boolean specifying if an alpha test is needed.
  41545. */
  41546. needAlphaTesting(): boolean;
  41547. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41548. /**
  41549. * Get the texture used for alpha test purpose.
  41550. * @returns the diffuse texture in case of the standard material.
  41551. */
  41552. getAlphaTestTexture(): Nullable<BaseTexture>;
  41553. /**
  41554. * Get if the submesh is ready to be used and all its information available.
  41555. * Child classes can use it to update shaders
  41556. * @param mesh defines the mesh to check
  41557. * @param subMesh defines which submesh to check
  41558. * @param useInstances specifies that instances should be used
  41559. * @returns a boolean indicating that the submesh is ready or not
  41560. */
  41561. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41562. /**
  41563. * Builds the material UBO layouts.
  41564. * Used internally during the effect preparation.
  41565. */
  41566. buildUniformLayout(): void;
  41567. /**
  41568. * Unbinds the material from the mesh
  41569. */
  41570. unbind(): void;
  41571. /**
  41572. * Binds the submesh to this material by preparing the effect and shader to draw
  41573. * @param world defines the world transformation matrix
  41574. * @param mesh defines the mesh containing the submesh
  41575. * @param subMesh defines the submesh to bind the material to
  41576. */
  41577. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41578. /**
  41579. * Get the list of animatables in the material.
  41580. * @returns the list of animatables object used in the material
  41581. */
  41582. getAnimatables(): IAnimatable[];
  41583. /**
  41584. * Gets the active textures from the material
  41585. * @returns an array of textures
  41586. */
  41587. getActiveTextures(): BaseTexture[];
  41588. /**
  41589. * Specifies if the material uses a texture
  41590. * @param texture defines the texture to check against the material
  41591. * @returns a boolean specifying if the material uses the texture
  41592. */
  41593. hasTexture(texture: BaseTexture): boolean;
  41594. /**
  41595. * Disposes the material
  41596. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41597. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41598. */
  41599. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41600. /**
  41601. * Makes a duplicate of the material, and gives it a new name
  41602. * @param name defines the new name for the duplicated material
  41603. * @returns the cloned material
  41604. */
  41605. clone(name: string): StandardMaterial;
  41606. /**
  41607. * Serializes this material in a JSON representation
  41608. * @returns the serialized material object
  41609. */
  41610. serialize(): any;
  41611. /**
  41612. * Creates a standard material from parsed material data
  41613. * @param source defines the JSON representation of the material
  41614. * @param scene defines the hosting scene
  41615. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41616. * @returns a new standard material
  41617. */
  41618. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41619. /**
  41620. * Are diffuse textures enabled in the application.
  41621. */
  41622. static DiffuseTextureEnabled: boolean;
  41623. /**
  41624. * Are ambient textures enabled in the application.
  41625. */
  41626. static AmbientTextureEnabled: boolean;
  41627. /**
  41628. * Are opacity textures enabled in the application.
  41629. */
  41630. static OpacityTextureEnabled: boolean;
  41631. /**
  41632. * Are reflection textures enabled in the application.
  41633. */
  41634. static ReflectionTextureEnabled: boolean;
  41635. /**
  41636. * Are emissive textures enabled in the application.
  41637. */
  41638. static EmissiveTextureEnabled: boolean;
  41639. /**
  41640. * Are specular textures enabled in the application.
  41641. */
  41642. static SpecularTextureEnabled: boolean;
  41643. /**
  41644. * Are bump textures enabled in the application.
  41645. */
  41646. static BumpTextureEnabled: boolean;
  41647. /**
  41648. * Are lightmap textures enabled in the application.
  41649. */
  41650. static LightmapTextureEnabled: boolean;
  41651. /**
  41652. * Are refraction textures enabled in the application.
  41653. */
  41654. static RefractionTextureEnabled: boolean;
  41655. /**
  41656. * Are color grading textures enabled in the application.
  41657. */
  41658. static ColorGradingTextureEnabled: boolean;
  41659. /**
  41660. * Are fresnels enabled in the application.
  41661. */
  41662. static FresnelEnabled: boolean;
  41663. }
  41664. }
  41665. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41666. import { Scene } from "babylonjs/scene";
  41667. import { Texture } from "babylonjs/Materials/Textures/texture";
  41668. /**
  41669. * A class extending Texture allowing drawing on a texture
  41670. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41671. */
  41672. export class DynamicTexture extends Texture {
  41673. private _generateMipMaps;
  41674. private _canvas;
  41675. private _context;
  41676. private _engine;
  41677. /**
  41678. * Creates a DynamicTexture
  41679. * @param name defines the name of the texture
  41680. * @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
  41681. * @param scene defines the scene where you want the texture
  41682. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41683. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41684. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41685. */
  41686. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41687. /**
  41688. * Get the current class name of the texture useful for serialization or dynamic coding.
  41689. * @returns "DynamicTexture"
  41690. */
  41691. getClassName(): string;
  41692. /**
  41693. * Gets the current state of canRescale
  41694. */
  41695. readonly canRescale: boolean;
  41696. private _recreate;
  41697. /**
  41698. * Scales the texture
  41699. * @param ratio the scale factor to apply to both width and height
  41700. */
  41701. scale(ratio: number): void;
  41702. /**
  41703. * Resizes the texture
  41704. * @param width the new width
  41705. * @param height the new height
  41706. */
  41707. scaleTo(width: number, height: number): void;
  41708. /**
  41709. * Gets the context of the canvas used by the texture
  41710. * @returns the canvas context of the dynamic texture
  41711. */
  41712. getContext(): CanvasRenderingContext2D;
  41713. /**
  41714. * Clears the texture
  41715. */
  41716. clear(): void;
  41717. /**
  41718. * Updates the texture
  41719. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41720. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41721. */
  41722. update(invertY?: boolean, premulAlpha?: boolean): void;
  41723. /**
  41724. * Draws text onto the texture
  41725. * @param text defines the text to be drawn
  41726. * @param x defines the placement of the text from the left
  41727. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41728. * @param font defines the font to be used with font-style, font-size, font-name
  41729. * @param color defines the color used for the text
  41730. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41731. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41732. * @param update defines whether texture is immediately update (default is true)
  41733. */
  41734. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41735. /**
  41736. * Clones the texture
  41737. * @returns the clone of the texture.
  41738. */
  41739. clone(): DynamicTexture;
  41740. /**
  41741. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41742. * @returns a serialized dynamic texture object
  41743. */
  41744. serialize(): any;
  41745. /** @hidden */
  41746. _rebuild(): void;
  41747. }
  41748. }
  41749. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41750. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41751. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41752. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41753. /** @hidden */
  41754. export var imageProcessingPixelShader: {
  41755. name: string;
  41756. shader: string;
  41757. };
  41758. }
  41759. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41760. import { Nullable } from "babylonjs/types";
  41761. import { Color4 } from "babylonjs/Maths/math.color";
  41762. import { Camera } from "babylonjs/Cameras/camera";
  41763. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41764. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41765. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41766. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41767. import { Engine } from "babylonjs/Engines/engine";
  41768. import "babylonjs/Shaders/imageProcessing.fragment";
  41769. import "babylonjs/Shaders/postprocess.vertex";
  41770. /**
  41771. * ImageProcessingPostProcess
  41772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41773. */
  41774. export class ImageProcessingPostProcess extends PostProcess {
  41775. /**
  41776. * Default configuration related to image processing available in the PBR Material.
  41777. */
  41778. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41779. /**
  41780. * Gets the image processing configuration used either in this material.
  41781. */
  41782. /**
  41783. * Sets the Default image processing configuration used either in the this material.
  41784. *
  41785. * If sets to null, the scene one is in use.
  41786. */
  41787. imageProcessingConfiguration: ImageProcessingConfiguration;
  41788. /**
  41789. * Keep track of the image processing observer to allow dispose and replace.
  41790. */
  41791. private _imageProcessingObserver;
  41792. /**
  41793. * Attaches a new image processing configuration to the PBR Material.
  41794. * @param configuration
  41795. */
  41796. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41797. /**
  41798. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41799. */
  41800. /**
  41801. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41802. */
  41803. colorCurves: Nullable<ColorCurves>;
  41804. /**
  41805. * Gets wether the color curves effect is enabled.
  41806. */
  41807. /**
  41808. * Sets wether the color curves effect is enabled.
  41809. */
  41810. colorCurvesEnabled: boolean;
  41811. /**
  41812. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41813. */
  41814. /**
  41815. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41816. */
  41817. colorGradingTexture: Nullable<BaseTexture>;
  41818. /**
  41819. * Gets wether the color grading effect is enabled.
  41820. */
  41821. /**
  41822. * Gets wether the color grading effect is enabled.
  41823. */
  41824. colorGradingEnabled: boolean;
  41825. /**
  41826. * Gets exposure used in the effect.
  41827. */
  41828. /**
  41829. * Sets exposure used in the effect.
  41830. */
  41831. exposure: number;
  41832. /**
  41833. * Gets wether tonemapping is enabled or not.
  41834. */
  41835. /**
  41836. * Sets wether tonemapping is enabled or not
  41837. */
  41838. toneMappingEnabled: boolean;
  41839. /**
  41840. * Gets the type of tone mapping effect.
  41841. */
  41842. /**
  41843. * Sets the type of tone mapping effect.
  41844. */
  41845. toneMappingType: number;
  41846. /**
  41847. * Gets contrast used in the effect.
  41848. */
  41849. /**
  41850. * Sets contrast used in the effect.
  41851. */
  41852. contrast: number;
  41853. /**
  41854. * Gets Vignette stretch size.
  41855. */
  41856. /**
  41857. * Sets Vignette stretch size.
  41858. */
  41859. vignetteStretch: number;
  41860. /**
  41861. * Gets Vignette centre X Offset.
  41862. */
  41863. /**
  41864. * Sets Vignette centre X Offset.
  41865. */
  41866. vignetteCentreX: number;
  41867. /**
  41868. * Gets Vignette centre Y Offset.
  41869. */
  41870. /**
  41871. * Sets Vignette centre Y Offset.
  41872. */
  41873. vignetteCentreY: number;
  41874. /**
  41875. * Gets Vignette weight or intensity of the vignette effect.
  41876. */
  41877. /**
  41878. * Sets Vignette weight or intensity of the vignette effect.
  41879. */
  41880. vignetteWeight: number;
  41881. /**
  41882. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41883. * if vignetteEnabled is set to true.
  41884. */
  41885. /**
  41886. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41887. * if vignetteEnabled is set to true.
  41888. */
  41889. vignetteColor: Color4;
  41890. /**
  41891. * Gets Camera field of view used by the Vignette effect.
  41892. */
  41893. /**
  41894. * Sets Camera field of view used by the Vignette effect.
  41895. */
  41896. vignetteCameraFov: number;
  41897. /**
  41898. * Gets the vignette blend mode allowing different kind of effect.
  41899. */
  41900. /**
  41901. * Sets the vignette blend mode allowing different kind of effect.
  41902. */
  41903. vignetteBlendMode: number;
  41904. /**
  41905. * Gets wether the vignette effect is enabled.
  41906. */
  41907. /**
  41908. * Sets wether the vignette effect is enabled.
  41909. */
  41910. vignetteEnabled: boolean;
  41911. private _fromLinearSpace;
  41912. /**
  41913. * Gets wether the input of the processing is in Gamma or Linear Space.
  41914. */
  41915. /**
  41916. * Sets wether the input of the processing is in Gamma or Linear Space.
  41917. */
  41918. fromLinearSpace: boolean;
  41919. /**
  41920. * Defines cache preventing GC.
  41921. */
  41922. private _defines;
  41923. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41924. /**
  41925. * "ImageProcessingPostProcess"
  41926. * @returns "ImageProcessingPostProcess"
  41927. */
  41928. getClassName(): string;
  41929. protected _updateParameters(): void;
  41930. dispose(camera?: Camera): void;
  41931. }
  41932. }
  41933. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41934. import { Scene } from "babylonjs/scene";
  41935. import { Color3 } from "babylonjs/Maths/math.color";
  41936. import { Mesh } from "babylonjs/Meshes/mesh";
  41937. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41938. import { Nullable } from "babylonjs/types";
  41939. /**
  41940. * Class containing static functions to help procedurally build meshes
  41941. */
  41942. export class GroundBuilder {
  41943. /**
  41944. * Creates a ground mesh
  41945. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41946. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41948. * @param name defines the name of the mesh
  41949. * @param options defines the options used to create the mesh
  41950. * @param scene defines the hosting scene
  41951. * @returns the ground mesh
  41952. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41953. */
  41954. static CreateGround(name: string, options: {
  41955. width?: number;
  41956. height?: number;
  41957. subdivisions?: number;
  41958. subdivisionsX?: number;
  41959. subdivisionsY?: number;
  41960. updatable?: boolean;
  41961. }, scene: any): Mesh;
  41962. /**
  41963. * Creates a tiled ground mesh
  41964. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41965. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41966. * * 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
  41967. * * 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
  41968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41969. * @param name defines the name of the mesh
  41970. * @param options defines the options used to create the mesh
  41971. * @param scene defines the hosting scene
  41972. * @returns the tiled ground mesh
  41973. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41974. */
  41975. static CreateTiledGround(name: string, options: {
  41976. xmin: number;
  41977. zmin: number;
  41978. xmax: number;
  41979. zmax: number;
  41980. subdivisions?: {
  41981. w: number;
  41982. h: number;
  41983. };
  41984. precision?: {
  41985. w: number;
  41986. h: number;
  41987. };
  41988. updatable?: boolean;
  41989. }, scene?: Nullable<Scene>): Mesh;
  41990. /**
  41991. * Creates a ground mesh from a height map
  41992. * * The parameter `url` sets the URL of the height map image resource.
  41993. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41994. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41995. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41996. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41997. * * 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.
  41998. * * 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).
  41999. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42001. * @param name defines the name of the mesh
  42002. * @param url defines the url to the height map
  42003. * @param options defines the options used to create the mesh
  42004. * @param scene defines the hosting scene
  42005. * @returns the ground mesh
  42006. * @see https://doc.babylonjs.com/babylon101/height_map
  42007. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42008. */
  42009. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42010. width?: number;
  42011. height?: number;
  42012. subdivisions?: number;
  42013. minHeight?: number;
  42014. maxHeight?: number;
  42015. colorFilter?: Color3;
  42016. alphaFilter?: number;
  42017. updatable?: boolean;
  42018. onReady?: (mesh: GroundMesh) => void;
  42019. }, scene?: Nullable<Scene>): GroundMesh;
  42020. }
  42021. }
  42022. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42023. import { Vector4 } from "babylonjs/Maths/math.vector";
  42024. import { Mesh } from "babylonjs/Meshes/mesh";
  42025. /**
  42026. * Class containing static functions to help procedurally build meshes
  42027. */
  42028. export class TorusBuilder {
  42029. /**
  42030. * Creates a torus mesh
  42031. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42032. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42033. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42037. * @param name defines the name of the mesh
  42038. * @param options defines the options used to create the mesh
  42039. * @param scene defines the hosting scene
  42040. * @returns the torus mesh
  42041. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42042. */
  42043. static CreateTorus(name: string, options: {
  42044. diameter?: number;
  42045. thickness?: number;
  42046. tessellation?: number;
  42047. updatable?: boolean;
  42048. sideOrientation?: number;
  42049. frontUVs?: Vector4;
  42050. backUVs?: Vector4;
  42051. }, scene: any): Mesh;
  42052. }
  42053. }
  42054. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42055. import { Vector4 } from "babylonjs/Maths/math.vector";
  42056. import { Color4 } from "babylonjs/Maths/math.color";
  42057. import { Mesh } from "babylonjs/Meshes/mesh";
  42058. /**
  42059. * Class containing static functions to help procedurally build meshes
  42060. */
  42061. export class CylinderBuilder {
  42062. /**
  42063. * Creates a cylinder or a cone mesh
  42064. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42065. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42066. * * 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.
  42067. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42068. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42069. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42070. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42071. * * 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).
  42072. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42073. * * 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).
  42074. * * 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
  42075. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42076. * * 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
  42077. * * 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.
  42078. * * If `enclose` is false, a ring surface is one element.
  42079. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42080. * * 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
  42081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42084. * @param name defines the name of the mesh
  42085. * @param options defines the options used to create the mesh
  42086. * @param scene defines the hosting scene
  42087. * @returns the cylinder mesh
  42088. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42089. */
  42090. static CreateCylinder(name: string, options: {
  42091. height?: number;
  42092. diameterTop?: number;
  42093. diameterBottom?: number;
  42094. diameter?: number;
  42095. tessellation?: number;
  42096. subdivisions?: number;
  42097. arc?: number;
  42098. faceColors?: Color4[];
  42099. faceUV?: Vector4[];
  42100. updatable?: boolean;
  42101. hasRings?: boolean;
  42102. enclose?: boolean;
  42103. cap?: number;
  42104. sideOrientation?: number;
  42105. frontUVs?: Vector4;
  42106. backUVs?: Vector4;
  42107. }, scene: any): Mesh;
  42108. }
  42109. }
  42110. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42111. import { Observable } from "babylonjs/Misc/observable";
  42112. import { Nullable } from "babylonjs/types";
  42113. import { Camera } from "babylonjs/Cameras/camera";
  42114. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42115. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42116. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42117. import { Scene } from "babylonjs/scene";
  42118. import { Vector3 } from "babylonjs/Maths/math.vector";
  42119. import { Color3 } from "babylonjs/Maths/math.color";
  42120. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42122. import { Mesh } from "babylonjs/Meshes/mesh";
  42123. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42124. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42125. import "babylonjs/Meshes/Builders/groundBuilder";
  42126. import "babylonjs/Meshes/Builders/torusBuilder";
  42127. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42128. import "babylonjs/Gamepads/gamepadSceneComponent";
  42129. import "babylonjs/Animations/animatable";
  42130. /**
  42131. * Options to modify the vr teleportation behavior.
  42132. */
  42133. export interface VRTeleportationOptions {
  42134. /**
  42135. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42136. */
  42137. floorMeshName?: string;
  42138. /**
  42139. * A list of meshes to be used as the teleportation floor. (default: empty)
  42140. */
  42141. floorMeshes?: Mesh[];
  42142. }
  42143. /**
  42144. * Options to modify the vr experience helper's behavior.
  42145. */
  42146. export interface VRExperienceHelperOptions extends WebVROptions {
  42147. /**
  42148. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42149. */
  42150. createDeviceOrientationCamera?: boolean;
  42151. /**
  42152. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42153. */
  42154. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42155. /**
  42156. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42157. */
  42158. laserToggle?: boolean;
  42159. /**
  42160. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42161. */
  42162. floorMeshes?: Mesh[];
  42163. /**
  42164. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42165. */
  42166. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42167. }
  42168. /**
  42169. * Event containing information after VR has been entered
  42170. */
  42171. export class OnAfterEnteringVRObservableEvent {
  42172. /**
  42173. * If entering vr was successful
  42174. */
  42175. success: boolean;
  42176. }
  42177. /**
  42178. * Helps to quickly add VR support to an existing scene.
  42179. * See http://doc.babylonjs.com/how_to/webvr_helper
  42180. */
  42181. export class VRExperienceHelper {
  42182. /** Options to modify the vr experience helper's behavior. */
  42183. webVROptions: VRExperienceHelperOptions;
  42184. private _scene;
  42185. private _position;
  42186. private _btnVR;
  42187. private _btnVRDisplayed;
  42188. private _webVRsupported;
  42189. private _webVRready;
  42190. private _webVRrequesting;
  42191. private _webVRpresenting;
  42192. private _hasEnteredVR;
  42193. private _fullscreenVRpresenting;
  42194. private _canvas;
  42195. private _webVRCamera;
  42196. private _vrDeviceOrientationCamera;
  42197. private _deviceOrientationCamera;
  42198. private _existingCamera;
  42199. private _onKeyDown;
  42200. private _onVrDisplayPresentChange;
  42201. private _onVRDisplayChanged;
  42202. private _onVRRequestPresentStart;
  42203. private _onVRRequestPresentComplete;
  42204. /**
  42205. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  42206. */
  42207. enableGazeEvenWhenNoPointerLock: boolean;
  42208. /**
  42209. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42210. */
  42211. exitVROnDoubleTap: boolean;
  42212. /**
  42213. * Observable raised right before entering VR.
  42214. */
  42215. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42216. /**
  42217. * Observable raised when entering VR has completed.
  42218. */
  42219. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42220. /**
  42221. * Observable raised when exiting VR.
  42222. */
  42223. onExitingVRObservable: Observable<VRExperienceHelper>;
  42224. /**
  42225. * Observable raised when controller mesh is loaded.
  42226. */
  42227. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42228. /** Return this.onEnteringVRObservable
  42229. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42230. */
  42231. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42232. /** Return this.onExitingVRObservable
  42233. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42234. */
  42235. readonly onExitingVR: Observable<VRExperienceHelper>;
  42236. /** Return this.onControllerMeshLoadedObservable
  42237. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42238. */
  42239. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42240. private _rayLength;
  42241. private _useCustomVRButton;
  42242. private _teleportationRequested;
  42243. private _teleportActive;
  42244. private _floorMeshName;
  42245. private _floorMeshesCollection;
  42246. private _rotationAllowed;
  42247. private _teleportBackwardsVector;
  42248. private _teleportationTarget;
  42249. private _isDefaultTeleportationTarget;
  42250. private _postProcessMove;
  42251. private _teleportationFillColor;
  42252. private _teleportationBorderColor;
  42253. private _rotationAngle;
  42254. private _haloCenter;
  42255. private _cameraGazer;
  42256. private _padSensibilityUp;
  42257. private _padSensibilityDown;
  42258. private _leftController;
  42259. private _rightController;
  42260. /**
  42261. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42262. */
  42263. onNewMeshSelected: Observable<AbstractMesh>;
  42264. /**
  42265. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42266. */
  42267. onNewMeshPicked: Observable<PickingInfo>;
  42268. private _circleEase;
  42269. /**
  42270. * Observable raised before camera teleportation
  42271. */
  42272. onBeforeCameraTeleport: Observable<Vector3>;
  42273. /**
  42274. * Observable raised after camera teleportation
  42275. */
  42276. onAfterCameraTeleport: Observable<Vector3>;
  42277. /**
  42278. * Observable raised when current selected mesh gets unselected
  42279. */
  42280. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42281. private _raySelectionPredicate;
  42282. /**
  42283. * To be optionaly changed by user to define custom ray selection
  42284. */
  42285. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42286. /**
  42287. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42288. */
  42289. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42290. /**
  42291. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42292. */
  42293. teleportationEnabled: boolean;
  42294. private _defaultHeight;
  42295. private _teleportationInitialized;
  42296. private _interactionsEnabled;
  42297. private _interactionsRequested;
  42298. private _displayGaze;
  42299. private _displayLaserPointer;
  42300. /**
  42301. * The mesh used to display where the user is going to teleport.
  42302. */
  42303. /**
  42304. * Sets the mesh to be used to display where the user is going to teleport.
  42305. */
  42306. teleportationTarget: Mesh;
  42307. /**
  42308. * 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
  42309. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42310. * See http://doc.babylonjs.com/resources/baking_transformations
  42311. */
  42312. gazeTrackerMesh: Mesh;
  42313. /**
  42314. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42315. */
  42316. updateGazeTrackerScale: boolean;
  42317. /**
  42318. * If the gaze trackers color should be updated when selecting meshes
  42319. */
  42320. updateGazeTrackerColor: boolean;
  42321. /**
  42322. * The gaze tracking mesh corresponding to the left controller
  42323. */
  42324. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42325. /**
  42326. * The gaze tracking mesh corresponding to the right controller
  42327. */
  42328. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42329. /**
  42330. * If the ray of the gaze should be displayed.
  42331. */
  42332. /**
  42333. * Sets if the ray of the gaze should be displayed.
  42334. */
  42335. displayGaze: boolean;
  42336. /**
  42337. * If the ray of the LaserPointer should be displayed.
  42338. */
  42339. /**
  42340. * Sets if the ray of the LaserPointer should be displayed.
  42341. */
  42342. displayLaserPointer: boolean;
  42343. /**
  42344. * The deviceOrientationCamera used as the camera when not in VR.
  42345. */
  42346. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42347. /**
  42348. * Based on the current WebVR support, returns the current VR camera used.
  42349. */
  42350. readonly currentVRCamera: Nullable<Camera>;
  42351. /**
  42352. * The webVRCamera which is used when in VR.
  42353. */
  42354. readonly webVRCamera: WebVRFreeCamera;
  42355. /**
  42356. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42357. */
  42358. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42359. /**
  42360. * The html button that is used to trigger entering into VR.
  42361. */
  42362. readonly vrButton: Nullable<HTMLButtonElement>;
  42363. private readonly _teleportationRequestInitiated;
  42364. /**
  42365. * Defines wether or not Pointer lock should be requested when switching to
  42366. * full screen.
  42367. */
  42368. requestPointerLockOnFullScreen: boolean;
  42369. /**
  42370. * Instantiates a VRExperienceHelper.
  42371. * Helps to quickly add VR support to an existing scene.
  42372. * @param scene The scene the VRExperienceHelper belongs to.
  42373. * @param webVROptions Options to modify the vr experience helper's behavior.
  42374. */
  42375. constructor(scene: Scene,
  42376. /** Options to modify the vr experience helper's behavior. */
  42377. webVROptions?: VRExperienceHelperOptions);
  42378. private _onDefaultMeshLoaded;
  42379. private _onResize;
  42380. private _onFullscreenChange;
  42381. /**
  42382. * Gets a value indicating if we are currently in VR mode.
  42383. */
  42384. readonly isInVRMode: boolean;
  42385. private onVrDisplayPresentChange;
  42386. private onVRDisplayChanged;
  42387. private moveButtonToBottomRight;
  42388. private displayVRButton;
  42389. private updateButtonVisibility;
  42390. private _cachedAngularSensibility;
  42391. /**
  42392. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42393. * Otherwise, will use the fullscreen API.
  42394. */
  42395. enterVR(): void;
  42396. /**
  42397. * Attempt to exit VR, or fullscreen.
  42398. */
  42399. exitVR(): void;
  42400. /**
  42401. * The position of the vr experience helper.
  42402. */
  42403. /**
  42404. * Sets the position of the vr experience helper.
  42405. */
  42406. position: Vector3;
  42407. /**
  42408. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42409. */
  42410. enableInteractions(): void;
  42411. private readonly _noControllerIsActive;
  42412. private beforeRender;
  42413. private _isTeleportationFloor;
  42414. /**
  42415. * Adds a floor mesh to be used for teleportation.
  42416. * @param floorMesh the mesh to be used for teleportation.
  42417. */
  42418. addFloorMesh(floorMesh: Mesh): void;
  42419. /**
  42420. * Removes a floor mesh from being used for teleportation.
  42421. * @param floorMesh the mesh to be removed.
  42422. */
  42423. removeFloorMesh(floorMesh: Mesh): void;
  42424. /**
  42425. * Enables interactions and teleportation using the VR controllers and gaze.
  42426. * @param vrTeleportationOptions options to modify teleportation behavior.
  42427. */
  42428. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42429. private _onNewGamepadConnected;
  42430. private _tryEnableInteractionOnController;
  42431. private _onNewGamepadDisconnected;
  42432. private _enableInteractionOnController;
  42433. private _checkTeleportWithRay;
  42434. private _checkRotate;
  42435. private _checkTeleportBackwards;
  42436. private _enableTeleportationOnController;
  42437. private _createTeleportationCircles;
  42438. private _displayTeleportationTarget;
  42439. private _hideTeleportationTarget;
  42440. private _rotateCamera;
  42441. private _moveTeleportationSelectorTo;
  42442. private _workingVector;
  42443. private _workingQuaternion;
  42444. private _workingMatrix;
  42445. /**
  42446. * Teleports the users feet to the desired location
  42447. * @param location The location where the user's feet should be placed
  42448. */
  42449. teleportCamera(location: Vector3): void;
  42450. private _convertNormalToDirectionOfRay;
  42451. private _castRayAndSelectObject;
  42452. private _notifySelectedMeshUnselected;
  42453. /**
  42454. * Sets the color of the laser ray from the vr controllers.
  42455. * @param color new color for the ray.
  42456. */
  42457. changeLaserColor(color: Color3): void;
  42458. /**
  42459. * Sets the color of the ray from the vr headsets gaze.
  42460. * @param color new color for the ray.
  42461. */
  42462. changeGazeColor(color: Color3): void;
  42463. /**
  42464. * Exits VR and disposes of the vr experience helper
  42465. */
  42466. dispose(): void;
  42467. /**
  42468. * Gets the name of the VRExperienceHelper class
  42469. * @returns "VRExperienceHelper"
  42470. */
  42471. getClassName(): string;
  42472. }
  42473. }
  42474. declare module "babylonjs/Cameras/VR/index" {
  42475. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42476. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42477. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42478. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42479. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42480. export * from "babylonjs/Cameras/VR/webVRCamera";
  42481. }
  42482. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42483. import { Observable } from "babylonjs/Misc/observable";
  42484. import { Nullable } from "babylonjs/types";
  42485. import { IDisposable, Scene } from "babylonjs/scene";
  42486. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42487. /**
  42488. * Manages an XRSession to work with Babylon's engine
  42489. * @see https://doc.babylonjs.com/how_to/webxr
  42490. */
  42491. export class WebXRSessionManager implements IDisposable {
  42492. private scene;
  42493. /**
  42494. * Fires every time a new xrFrame arrives which can be used to update the camera
  42495. */
  42496. onXRFrameObservable: Observable<any>;
  42497. /**
  42498. * Fires when the xr session is ended either by the device or manually done
  42499. */
  42500. onXRSessionEnded: Observable<any>;
  42501. /**
  42502. * Underlying xr session
  42503. */
  42504. session: XRSession;
  42505. /**
  42506. * Type of reference space used when creating the session
  42507. */
  42508. referenceSpace: XRReferenceSpace;
  42509. /** @hidden */
  42510. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42511. /**
  42512. * Current XR frame
  42513. */
  42514. currentFrame: Nullable<XRFrame>;
  42515. private _xrNavigator;
  42516. private baseLayer;
  42517. /**
  42518. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42519. * @param scene The scene which the session should be created for
  42520. */
  42521. constructor(scene: Scene);
  42522. /**
  42523. * Initializes the manager
  42524. * After initialization enterXR can be called to start an XR session
  42525. * @returns Promise which resolves after it is initialized
  42526. */
  42527. initializeAsync(): Promise<void>;
  42528. /**
  42529. * Initializes an xr session
  42530. * @param xrSessionMode mode to initialize
  42531. * @returns a promise which will resolve once the session has been initialized
  42532. */
  42533. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42534. /**
  42535. * Sets the reference space on the xr session
  42536. * @param referenceSpace space to set
  42537. * @returns a promise that will resolve once the reference space has been set
  42538. */
  42539. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42540. /**
  42541. * Updates the render state of the session
  42542. * @param state state to set
  42543. * @returns a promise that resolves once the render state has been updated
  42544. */
  42545. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42546. /**
  42547. * Starts rendering to the xr layer
  42548. * @returns a promise that will resolve once rendering has started
  42549. */
  42550. startRenderingToXRAsync(): Promise<void>;
  42551. /**
  42552. * Stops the xrSession and restores the renderloop
  42553. * @returns Promise which resolves after it exits XR
  42554. */
  42555. exitXRAsync(): Promise<unknown>;
  42556. /**
  42557. * Checks if a session would be supported for the creation options specified
  42558. * @param sessionMode session mode to check if supported eg. immersive-vr
  42559. * @returns true if supported
  42560. */
  42561. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42562. /**
  42563. * @hidden
  42564. * Converts the render layer of xrSession to a render target
  42565. * @param session session to create render target for
  42566. * @param scene scene the new render target should be created for
  42567. */
  42568. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42569. /**
  42570. * Disposes of the session manager
  42571. */
  42572. dispose(): void;
  42573. }
  42574. }
  42575. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42576. import { Scene } from "babylonjs/scene";
  42577. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42578. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42579. /**
  42580. * WebXR Camera which holds the views for the xrSession
  42581. * @see https://doc.babylonjs.com/how_to/webxr
  42582. */
  42583. export class WebXRCamera extends FreeCamera {
  42584. private static _TmpMatrix;
  42585. /**
  42586. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42587. * @param name the name of the camera
  42588. * @param scene the scene to add the camera to
  42589. */
  42590. constructor(name: string, scene: Scene);
  42591. private _updateNumberOfRigCameras;
  42592. /** @hidden */
  42593. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42594. /**
  42595. * Updates the cameras position from the current pose information of the XR session
  42596. * @param xrSessionManager the session containing pose information
  42597. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42598. */
  42599. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42600. }
  42601. }
  42602. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42603. import { Nullable } from "babylonjs/types";
  42604. import { IDisposable } from "babylonjs/scene";
  42605. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42606. /**
  42607. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42608. */
  42609. export class WebXRManagedOutputCanvas implements IDisposable {
  42610. private helper;
  42611. private _canvas;
  42612. /**
  42613. * xrpresent context of the canvas which can be used to display/mirror xr content
  42614. */
  42615. canvasContext: WebGLRenderingContext;
  42616. /**
  42617. * xr layer for the canvas
  42618. */
  42619. xrLayer: Nullable<XRWebGLLayer>;
  42620. /**
  42621. * Initializes the xr layer for the session
  42622. * @param xrSession xr session
  42623. * @returns a promise that will resolve once the XR Layer has been created
  42624. */
  42625. initializeXRLayerAsync(xrSession: any): any;
  42626. /**
  42627. * Initializes the canvas to be added/removed upon entering/exiting xr
  42628. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42629. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42630. */
  42631. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42632. /**
  42633. * Disposes of the object
  42634. */
  42635. dispose(): void;
  42636. private _setManagedOutputCanvas;
  42637. private _addCanvas;
  42638. private _removeCanvas;
  42639. }
  42640. }
  42641. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42642. import { Observable } from "babylonjs/Misc/observable";
  42643. import { IDisposable, Scene } from "babylonjs/scene";
  42644. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42646. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42647. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42648. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42649. /**
  42650. * States of the webXR experience
  42651. */
  42652. export enum WebXRState {
  42653. /**
  42654. * Transitioning to being in XR mode
  42655. */
  42656. ENTERING_XR = 0,
  42657. /**
  42658. * Transitioning to non XR mode
  42659. */
  42660. EXITING_XR = 1,
  42661. /**
  42662. * In XR mode and presenting
  42663. */
  42664. IN_XR = 2,
  42665. /**
  42666. * Not entered XR mode
  42667. */
  42668. NOT_IN_XR = 3
  42669. }
  42670. /**
  42671. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42672. * @see https://doc.babylonjs.com/how_to/webxr
  42673. */
  42674. export class WebXRExperienceHelper implements IDisposable {
  42675. private scene;
  42676. /**
  42677. * 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
  42678. */
  42679. container: AbstractMesh;
  42680. /**
  42681. * Camera used to render xr content
  42682. */
  42683. camera: WebXRCamera;
  42684. /**
  42685. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42686. */
  42687. state: WebXRState;
  42688. private _setState;
  42689. private static _TmpVector;
  42690. /**
  42691. * Fires when the state of the experience helper has changed
  42692. */
  42693. onStateChangedObservable: Observable<WebXRState>;
  42694. /** Session manager used to keep track of xr session */
  42695. sessionManager: WebXRSessionManager;
  42696. private _nonVRCamera;
  42697. private _originalSceneAutoClear;
  42698. private _supported;
  42699. /**
  42700. * Creates the experience helper
  42701. * @param scene the scene to attach the experience helper to
  42702. * @returns a promise for the experience helper
  42703. */
  42704. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42705. /**
  42706. * Creates a WebXRExperienceHelper
  42707. * @param scene The scene the helper should be created in
  42708. */
  42709. private constructor();
  42710. /**
  42711. * Exits XR mode and returns the scene to its original state
  42712. * @returns promise that resolves after xr mode has exited
  42713. */
  42714. exitXRAsync(): Promise<unknown>;
  42715. /**
  42716. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42717. * @param sessionCreationOptions options for the XR session
  42718. * @param referenceSpaceType frame of reference of the XR session
  42719. * @param outputCanvas the output canvas that will be used to enter XR mode
  42720. * @returns promise that resolves after xr mode has entered
  42721. */
  42722. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42723. /**
  42724. * Updates the global position of the camera by moving the camera's container
  42725. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42726. * @param position The desired global position of the camera
  42727. */
  42728. setPositionOfCameraUsingContainer(position: Vector3): void;
  42729. /**
  42730. * Rotates the xr camera by rotating the camera's container around the camera's position
  42731. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42732. * @param rotation the desired quaternion rotation to apply to the camera
  42733. */
  42734. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42735. /**
  42736. * Disposes of the experience helper
  42737. */
  42738. dispose(): void;
  42739. }
  42740. }
  42741. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42742. import { Nullable } from "babylonjs/types";
  42743. import { Observable } from "babylonjs/Misc/observable";
  42744. import { IDisposable, Scene } from "babylonjs/scene";
  42745. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42746. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42747. /**
  42748. * Button which can be used to enter a different mode of XR
  42749. */
  42750. export class WebXREnterExitUIButton {
  42751. /** button element */
  42752. element: HTMLElement;
  42753. /** XR initialization options for the button */
  42754. sessionMode: XRSessionMode;
  42755. /** Reference space type */
  42756. referenceSpaceType: XRReferenceSpaceType;
  42757. /**
  42758. * Creates a WebXREnterExitUIButton
  42759. * @param element button element
  42760. * @param sessionMode XR initialization session mode
  42761. * @param referenceSpaceType the type of reference space to be used
  42762. */
  42763. constructor(
  42764. /** button element */
  42765. element: HTMLElement,
  42766. /** XR initialization options for the button */
  42767. sessionMode: XRSessionMode,
  42768. /** Reference space type */
  42769. referenceSpaceType: XRReferenceSpaceType);
  42770. /**
  42771. * Overwritable function which can be used to update the button's visuals when the state changes
  42772. * @param activeButton the current active button in the UI
  42773. */
  42774. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42775. }
  42776. /**
  42777. * Options to create the webXR UI
  42778. */
  42779. export class WebXREnterExitUIOptions {
  42780. /**
  42781. * Context to enter xr with
  42782. */
  42783. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42784. /**
  42785. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42786. */
  42787. customButtons?: Array<WebXREnterExitUIButton>;
  42788. }
  42789. /**
  42790. * UI to allow the user to enter/exit XR mode
  42791. */
  42792. export class WebXREnterExitUI implements IDisposable {
  42793. private scene;
  42794. private _overlay;
  42795. private _buttons;
  42796. private _activeButton;
  42797. /**
  42798. * Fired every time the active button is changed.
  42799. *
  42800. * When xr is entered via a button that launches xr that button will be the callback parameter
  42801. *
  42802. * When exiting xr the callback parameter will be null)
  42803. */
  42804. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42805. /**
  42806. * Creates UI to allow the user to enter/exit XR mode
  42807. * @param scene the scene to add the ui to
  42808. * @param helper the xr experience helper to enter/exit xr with
  42809. * @param options options to configure the UI
  42810. * @returns the created ui
  42811. */
  42812. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42813. private constructor();
  42814. private _updateButtons;
  42815. /**
  42816. * Disposes of the object
  42817. */
  42818. dispose(): void;
  42819. }
  42820. }
  42821. declare module "babylonjs/Cameras/XR/webXRController" {
  42822. import { Nullable } from "babylonjs/types";
  42823. import { Observable } from "babylonjs/Misc/observable";
  42824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42825. import { Ray } from "babylonjs/Culling/ray";
  42826. import { Scene } from "babylonjs/scene";
  42827. /**
  42828. * Represents an XR input
  42829. */
  42830. export class WebXRController {
  42831. private scene;
  42832. /** The underlying input source for the controller */
  42833. inputSource: XRInputSource;
  42834. private parentContainer;
  42835. /**
  42836. * 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
  42837. */
  42838. grip?: AbstractMesh;
  42839. /**
  42840. * Pointer which can be used to select objects or attach a visible laser to
  42841. */
  42842. pointer: AbstractMesh;
  42843. /**
  42844. * Event that fires when the controller is removed/disposed
  42845. */
  42846. onDisposeObservable: Observable<{}>;
  42847. private _tmpMatrix;
  42848. private _tmpQuaternion;
  42849. private _tmpVector;
  42850. /**
  42851. * Creates the controller
  42852. * @see https://doc.babylonjs.com/how_to/webxr
  42853. * @param scene the scene which the controller should be associated to
  42854. * @param inputSource the underlying input source for the controller
  42855. * @param parentContainer parent that the controller meshes should be children of
  42856. */
  42857. constructor(scene: Scene,
  42858. /** The underlying input source for the controller */
  42859. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42860. /**
  42861. * Updates the controller pose based on the given XRFrame
  42862. * @param xrFrame xr frame to update the pose with
  42863. * @param referenceSpace reference space to use
  42864. */
  42865. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42866. /**
  42867. * Gets a world space ray coming from the controller
  42868. * @param result the resulting ray
  42869. */
  42870. getWorldPointerRayToRef(result: Ray): void;
  42871. /**
  42872. * Disposes of the object
  42873. */
  42874. dispose(): void;
  42875. }
  42876. }
  42877. declare module "babylonjs/Cameras/XR/webXRInput" {
  42878. import { Observable } from "babylonjs/Misc/observable";
  42879. import { IDisposable } from "babylonjs/scene";
  42880. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42881. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42882. /**
  42883. * XR input used to track XR inputs such as controllers/rays
  42884. */
  42885. export class WebXRInput implements IDisposable {
  42886. /**
  42887. * Base experience the input listens to
  42888. */
  42889. baseExperience: WebXRExperienceHelper;
  42890. /**
  42891. * XR controllers being tracked
  42892. */
  42893. controllers: Array<WebXRController>;
  42894. private _frameObserver;
  42895. private _stateObserver;
  42896. /**
  42897. * Event when a controller has been connected/added
  42898. */
  42899. onControllerAddedObservable: Observable<WebXRController>;
  42900. /**
  42901. * Event when a controller has been removed/disconnected
  42902. */
  42903. onControllerRemovedObservable: Observable<WebXRController>;
  42904. /**
  42905. * Initializes the WebXRInput
  42906. * @param baseExperience experience helper which the input should be created for
  42907. */
  42908. constructor(
  42909. /**
  42910. * Base experience the input listens to
  42911. */
  42912. baseExperience: WebXRExperienceHelper);
  42913. private _onInputSourcesChange;
  42914. private _addAndRemoveControllers;
  42915. /**
  42916. * Disposes of the object
  42917. */
  42918. dispose(): void;
  42919. }
  42920. }
  42921. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42923. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42924. /**
  42925. * Enables teleportation
  42926. */
  42927. export class WebXRControllerTeleportation {
  42928. private _teleportationFillColor;
  42929. private _teleportationBorderColor;
  42930. private _tmpRay;
  42931. private _tmpVector;
  42932. /**
  42933. * Creates a WebXRControllerTeleportation
  42934. * @param input input manager to add teleportation to
  42935. * @param floorMeshes floormeshes which can be teleported to
  42936. */
  42937. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42938. }
  42939. }
  42940. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42941. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42942. /**
  42943. * Handles pointer input automatically for the pointer of XR controllers
  42944. */
  42945. export class WebXRControllerPointerSelection {
  42946. private static _idCounter;
  42947. private _tmpRay;
  42948. /**
  42949. * Creates a WebXRControllerPointerSelection
  42950. * @param input input manager to setup pointer selection
  42951. */
  42952. constructor(input: WebXRInput);
  42953. private _convertNormalToDirectionOfRay;
  42954. private _updatePointerDistance;
  42955. }
  42956. }
  42957. declare module "babylonjs/Loading/sceneLoader" {
  42958. import { Observable } from "babylonjs/Misc/observable";
  42959. import { Nullable } from "babylonjs/types";
  42960. import { Scene } from "babylonjs/scene";
  42961. import { Engine } from "babylonjs/Engines/engine";
  42962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42963. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42964. import { AssetContainer } from "babylonjs/assetContainer";
  42965. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42966. import { Skeleton } from "babylonjs/Bones/skeleton";
  42967. /**
  42968. * Class used to represent data loading progression
  42969. */
  42970. export class SceneLoaderProgressEvent {
  42971. /** defines if data length to load can be evaluated */
  42972. readonly lengthComputable: boolean;
  42973. /** defines the loaded data length */
  42974. readonly loaded: number;
  42975. /** defines the data length to load */
  42976. readonly total: number;
  42977. /**
  42978. * Create a new progress event
  42979. * @param lengthComputable defines if data length to load can be evaluated
  42980. * @param loaded defines the loaded data length
  42981. * @param total defines the data length to load
  42982. */
  42983. constructor(
  42984. /** defines if data length to load can be evaluated */
  42985. lengthComputable: boolean,
  42986. /** defines the loaded data length */
  42987. loaded: number,
  42988. /** defines the data length to load */
  42989. total: number);
  42990. /**
  42991. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42992. * @param event defines the source event
  42993. * @returns a new SceneLoaderProgressEvent
  42994. */
  42995. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42996. }
  42997. /**
  42998. * Interface used by SceneLoader plugins to define supported file extensions
  42999. */
  43000. export interface ISceneLoaderPluginExtensions {
  43001. /**
  43002. * Defines the list of supported extensions
  43003. */
  43004. [extension: string]: {
  43005. isBinary: boolean;
  43006. };
  43007. }
  43008. /**
  43009. * Interface used by SceneLoader plugin factory
  43010. */
  43011. export interface ISceneLoaderPluginFactory {
  43012. /**
  43013. * Defines the name of the factory
  43014. */
  43015. name: string;
  43016. /**
  43017. * Function called to create a new plugin
  43018. * @return the new plugin
  43019. */
  43020. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43021. /**
  43022. * Boolean indicating if the plugin can direct load specific data
  43023. */
  43024. canDirectLoad?: (data: string) => boolean;
  43025. }
  43026. /**
  43027. * Interface used to define a SceneLoader plugin
  43028. */
  43029. export interface ISceneLoaderPlugin {
  43030. /**
  43031. * The friendly name of this plugin.
  43032. */
  43033. name: string;
  43034. /**
  43035. * The file extensions supported by this plugin.
  43036. */
  43037. extensions: string | ISceneLoaderPluginExtensions;
  43038. /**
  43039. * Import meshes into a scene.
  43040. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43041. * @param scene The scene to import into
  43042. * @param data The data to import
  43043. * @param rootUrl The root url for scene and resources
  43044. * @param meshes The meshes array to import into
  43045. * @param particleSystems The particle systems array to import into
  43046. * @param skeletons The skeletons array to import into
  43047. * @param onError The callback when import fails
  43048. * @returns True if successful or false otherwise
  43049. */
  43050. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43051. /**
  43052. * Load into a scene.
  43053. * @param scene The scene to load into
  43054. * @param data The data to import
  43055. * @param rootUrl The root url for scene and resources
  43056. * @param onError The callback when import fails
  43057. * @returns true if successful or false otherwise
  43058. */
  43059. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43060. /**
  43061. * The callback that returns true if the data can be directly loaded.
  43062. */
  43063. canDirectLoad?: (data: string) => boolean;
  43064. /**
  43065. * The callback that allows custom handling of the root url based on the response url.
  43066. */
  43067. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43068. /**
  43069. * Load into an asset container.
  43070. * @param scene The scene to load into
  43071. * @param data The data to import
  43072. * @param rootUrl The root url for scene and resources
  43073. * @param onError The callback when import fails
  43074. * @returns The loaded asset container
  43075. */
  43076. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43077. }
  43078. /**
  43079. * Interface used to define an async SceneLoader plugin
  43080. */
  43081. export interface ISceneLoaderPluginAsync {
  43082. /**
  43083. * The friendly name of this plugin.
  43084. */
  43085. name: string;
  43086. /**
  43087. * The file extensions supported by this plugin.
  43088. */
  43089. extensions: string | ISceneLoaderPluginExtensions;
  43090. /**
  43091. * Import meshes into a scene.
  43092. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43093. * @param scene The scene to import into
  43094. * @param data The data to import
  43095. * @param rootUrl The root url for scene and resources
  43096. * @param onProgress The callback when the load progresses
  43097. * @param fileName Defines the name of the file to load
  43098. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43099. */
  43100. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43101. meshes: AbstractMesh[];
  43102. particleSystems: IParticleSystem[];
  43103. skeletons: Skeleton[];
  43104. animationGroups: AnimationGroup[];
  43105. }>;
  43106. /**
  43107. * Load into a scene.
  43108. * @param scene The scene to load into
  43109. * @param data The data to import
  43110. * @param rootUrl The root url for scene and resources
  43111. * @param onProgress The callback when the load progresses
  43112. * @param fileName Defines the name of the file to load
  43113. * @returns Nothing
  43114. */
  43115. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43116. /**
  43117. * The callback that returns true if the data can be directly loaded.
  43118. */
  43119. canDirectLoad?: (data: string) => boolean;
  43120. /**
  43121. * The callback that allows custom handling of the root url based on the response url.
  43122. */
  43123. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43124. /**
  43125. * Load into an asset container.
  43126. * @param scene The scene to load into
  43127. * @param data The data to import
  43128. * @param rootUrl The root url for scene and resources
  43129. * @param onProgress The callback when the load progresses
  43130. * @param fileName Defines the name of the file to load
  43131. * @returns The loaded asset container
  43132. */
  43133. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43134. }
  43135. /**
  43136. * Class used to load scene from various file formats using registered plugins
  43137. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43138. */
  43139. export class SceneLoader {
  43140. /**
  43141. * No logging while loading
  43142. */
  43143. static readonly NO_LOGGING: number;
  43144. /**
  43145. * Minimal logging while loading
  43146. */
  43147. static readonly MINIMAL_LOGGING: number;
  43148. /**
  43149. * Summary logging while loading
  43150. */
  43151. static readonly SUMMARY_LOGGING: number;
  43152. /**
  43153. * Detailled logging while loading
  43154. */
  43155. static readonly DETAILED_LOGGING: number;
  43156. /**
  43157. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43158. */
  43159. static ForceFullSceneLoadingForIncremental: boolean;
  43160. /**
  43161. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43162. */
  43163. static ShowLoadingScreen: boolean;
  43164. /**
  43165. * Defines the current logging level (while loading the scene)
  43166. * @ignorenaming
  43167. */
  43168. static loggingLevel: number;
  43169. /**
  43170. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43171. */
  43172. static CleanBoneMatrixWeights: boolean;
  43173. /**
  43174. * Event raised when a plugin is used to load a scene
  43175. */
  43176. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43177. private static _registeredPlugins;
  43178. private static _getDefaultPlugin;
  43179. private static _getPluginForExtension;
  43180. private static _getPluginForDirectLoad;
  43181. private static _getPluginForFilename;
  43182. private static _getDirectLoad;
  43183. private static _loadData;
  43184. private static _getFileInfo;
  43185. /**
  43186. * Gets a plugin that can load the given extension
  43187. * @param extension defines the extension to load
  43188. * @returns a plugin or null if none works
  43189. */
  43190. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43191. /**
  43192. * Gets a boolean indicating that the given extension can be loaded
  43193. * @param extension defines the extension to load
  43194. * @returns true if the extension is supported
  43195. */
  43196. static IsPluginForExtensionAvailable(extension: string): boolean;
  43197. /**
  43198. * Adds a new plugin to the list of registered plugins
  43199. * @param plugin defines the plugin to add
  43200. */
  43201. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43202. /**
  43203. * Import meshes into a scene
  43204. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43205. * @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)
  43206. * @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)
  43207. * @param scene the instance of BABYLON.Scene to append to
  43208. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43209. * @param onProgress a callback with a progress event for each file being loaded
  43210. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43211. * @param pluginExtension the extension used to determine the plugin
  43212. * @returns The loaded plugin
  43213. */
  43214. 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>;
  43215. /**
  43216. * Import meshes into a scene
  43217. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43218. * @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)
  43219. * @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)
  43220. * @param scene the instance of BABYLON.Scene to append to
  43221. * @param onProgress a callback with a progress event for each file being loaded
  43222. * @param pluginExtension the extension used to determine the plugin
  43223. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43224. */
  43225. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43226. meshes: AbstractMesh[];
  43227. particleSystems: IParticleSystem[];
  43228. skeletons: Skeleton[];
  43229. animationGroups: AnimationGroup[];
  43230. }>;
  43231. /**
  43232. * Load a scene
  43233. * @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)
  43234. * @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)
  43235. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43236. * @param onSuccess a callback with the scene when import succeeds
  43237. * @param onProgress a callback with a progress event for each file being loaded
  43238. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43239. * @param pluginExtension the extension used to determine the plugin
  43240. * @returns The loaded plugin
  43241. */
  43242. 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>;
  43243. /**
  43244. * Load a scene
  43245. * @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)
  43246. * @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)
  43247. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43248. * @param onProgress a callback with a progress event for each file being loaded
  43249. * @param pluginExtension the extension used to determine the plugin
  43250. * @returns The loaded scene
  43251. */
  43252. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43253. /**
  43254. * Append a scene
  43255. * @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)
  43256. * @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)
  43257. * @param scene is the instance of BABYLON.Scene to append to
  43258. * @param onSuccess a callback with the scene when import succeeds
  43259. * @param onProgress a callback with a progress event for each file being loaded
  43260. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43261. * @param pluginExtension the extension used to determine the plugin
  43262. * @returns The loaded plugin
  43263. */
  43264. 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>;
  43265. /**
  43266. * Append a scene
  43267. * @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)
  43268. * @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)
  43269. * @param scene is the instance of BABYLON.Scene to append to
  43270. * @param onProgress a callback with a progress event for each file being loaded
  43271. * @param pluginExtension the extension used to determine the plugin
  43272. * @returns The given scene
  43273. */
  43274. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43275. /**
  43276. * Load a scene into an asset container
  43277. * @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)
  43278. * @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)
  43279. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43280. * @param onSuccess a callback with the scene when import succeeds
  43281. * @param onProgress a callback with a progress event for each file being loaded
  43282. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43283. * @param pluginExtension the extension used to determine the plugin
  43284. * @returns The loaded plugin
  43285. */
  43286. 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>;
  43287. /**
  43288. * Load a scene into an asset container
  43289. * @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)
  43290. * @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)
  43291. * @param scene is the instance of Scene to append to
  43292. * @param onProgress a callback with a progress event for each file being loaded
  43293. * @param pluginExtension the extension used to determine the plugin
  43294. * @returns The loaded asset container
  43295. */
  43296. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43297. }
  43298. }
  43299. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43300. import { Scene } from "babylonjs/scene";
  43301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43302. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43303. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43304. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43305. /**
  43306. * Generic Controller
  43307. */
  43308. export class GenericController extends WebVRController {
  43309. /**
  43310. * Base Url for the controller model.
  43311. */
  43312. static readonly MODEL_BASE_URL: string;
  43313. /**
  43314. * File name for the controller model.
  43315. */
  43316. static readonly MODEL_FILENAME: string;
  43317. /**
  43318. * Creates a new GenericController from a gamepad
  43319. * @param vrGamepad the gamepad that the controller should be created from
  43320. */
  43321. constructor(vrGamepad: any);
  43322. /**
  43323. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43324. * @param scene scene in which to add meshes
  43325. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43326. */
  43327. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43328. /**
  43329. * Called once for each button that changed state since the last frame
  43330. * @param buttonIdx Which button index changed
  43331. * @param state New state of the button
  43332. * @param changes Which properties on the state changed since last frame
  43333. */
  43334. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43335. }
  43336. }
  43337. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43338. import { Observable } from "babylonjs/Misc/observable";
  43339. import { Scene } from "babylonjs/scene";
  43340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43341. import { Ray } from "babylonjs/Culling/ray";
  43342. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43343. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43344. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43345. /**
  43346. * Defines the WindowsMotionController object that the state of the windows motion controller
  43347. */
  43348. export class WindowsMotionController extends WebVRController {
  43349. /**
  43350. * The base url used to load the left and right controller models
  43351. */
  43352. static MODEL_BASE_URL: string;
  43353. /**
  43354. * The name of the left controller model file
  43355. */
  43356. static MODEL_LEFT_FILENAME: string;
  43357. /**
  43358. * The name of the right controller model file
  43359. */
  43360. static MODEL_RIGHT_FILENAME: string;
  43361. /**
  43362. * The controller name prefix for this controller type
  43363. */
  43364. static readonly GAMEPAD_ID_PREFIX: string;
  43365. /**
  43366. * The controller id pattern for this controller type
  43367. */
  43368. private static readonly GAMEPAD_ID_PATTERN;
  43369. private _loadedMeshInfo;
  43370. private readonly _mapping;
  43371. /**
  43372. * Fired when the trackpad on this controller is clicked
  43373. */
  43374. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43375. /**
  43376. * Fired when the trackpad on this controller is modified
  43377. */
  43378. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43379. /**
  43380. * The current x and y values of this controller's trackpad
  43381. */
  43382. trackpad: StickValues;
  43383. /**
  43384. * Creates a new WindowsMotionController from a gamepad
  43385. * @param vrGamepad the gamepad that the controller should be created from
  43386. */
  43387. constructor(vrGamepad: any);
  43388. /**
  43389. * Fired when the trigger on this controller is modified
  43390. */
  43391. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43392. /**
  43393. * Fired when the menu button on this controller is modified
  43394. */
  43395. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43396. /**
  43397. * Fired when the grip button on this controller is modified
  43398. */
  43399. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43400. /**
  43401. * Fired when the thumbstick button on this controller is modified
  43402. */
  43403. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43404. /**
  43405. * Fired when the touchpad button on this controller is modified
  43406. */
  43407. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43408. /**
  43409. * Fired when the touchpad values on this controller are modified
  43410. */
  43411. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43412. private _updateTrackpad;
  43413. /**
  43414. * Called once per frame by the engine.
  43415. */
  43416. update(): void;
  43417. /**
  43418. * Called once for each button that changed state since the last frame
  43419. * @param buttonIdx Which button index changed
  43420. * @param state New state of the button
  43421. * @param changes Which properties on the state changed since last frame
  43422. */
  43423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43424. /**
  43425. * Moves the buttons on the controller mesh based on their current state
  43426. * @param buttonName the name of the button to move
  43427. * @param buttonValue the value of the button which determines the buttons new position
  43428. */
  43429. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43430. /**
  43431. * Moves the axis on the controller mesh based on its current state
  43432. * @param axis the index of the axis
  43433. * @param axisValue the value of the axis which determines the meshes new position
  43434. * @hidden
  43435. */
  43436. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43437. /**
  43438. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43439. * @param scene scene in which to add meshes
  43440. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43441. */
  43442. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43443. /**
  43444. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43445. * can be transformed by button presses and axes values, based on this._mapping.
  43446. *
  43447. * @param scene scene in which the meshes exist
  43448. * @param meshes list of meshes that make up the controller model to process
  43449. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43450. */
  43451. private processModel;
  43452. private createMeshInfo;
  43453. /**
  43454. * Gets the ray of the controller in the direction the controller is pointing
  43455. * @param length the length the resulting ray should be
  43456. * @returns a ray in the direction the controller is pointing
  43457. */
  43458. getForwardRay(length?: number): Ray;
  43459. /**
  43460. * Disposes of the controller
  43461. */
  43462. dispose(): void;
  43463. }
  43464. }
  43465. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43466. import { Observable } from "babylonjs/Misc/observable";
  43467. import { Scene } from "babylonjs/scene";
  43468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43469. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43470. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43471. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43472. /**
  43473. * Oculus Touch Controller
  43474. */
  43475. export class OculusTouchController extends WebVRController {
  43476. /**
  43477. * Base Url for the controller model.
  43478. */
  43479. static MODEL_BASE_URL: string;
  43480. /**
  43481. * File name for the left controller model.
  43482. */
  43483. static MODEL_LEFT_FILENAME: string;
  43484. /**
  43485. * File name for the right controller model.
  43486. */
  43487. static MODEL_RIGHT_FILENAME: string;
  43488. /**
  43489. * Base Url for the Quest controller model.
  43490. */
  43491. static QUEST_MODEL_BASE_URL: string;
  43492. /**
  43493. * @hidden
  43494. * If the controllers are running on a device that needs the updated Quest controller models
  43495. */
  43496. static _IsQuest: boolean;
  43497. /**
  43498. * Fired when the secondary trigger on this controller is modified
  43499. */
  43500. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43501. /**
  43502. * Fired when the thumb rest on this controller is modified
  43503. */
  43504. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43505. /**
  43506. * Creates a new OculusTouchController from a gamepad
  43507. * @param vrGamepad the gamepad that the controller should be created from
  43508. */
  43509. constructor(vrGamepad: any);
  43510. /**
  43511. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43512. * @param scene scene in which to add meshes
  43513. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43514. */
  43515. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43516. /**
  43517. * Fired when the A button on this controller is modified
  43518. */
  43519. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43520. /**
  43521. * Fired when the B button on this controller is modified
  43522. */
  43523. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43524. /**
  43525. * Fired when the X button on this controller is modified
  43526. */
  43527. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43528. /**
  43529. * Fired when the Y button on this controller is modified
  43530. */
  43531. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43532. /**
  43533. * Called once for each button that changed state since the last frame
  43534. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43535. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43536. * 2) secondary trigger (same)
  43537. * 3) A (right) X (left), touch, pressed = value
  43538. * 4) B / Y
  43539. * 5) thumb rest
  43540. * @param buttonIdx Which button index changed
  43541. * @param state New state of the button
  43542. * @param changes Which properties on the state changed since last frame
  43543. */
  43544. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43545. }
  43546. }
  43547. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43548. import { Scene } from "babylonjs/scene";
  43549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43550. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43551. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43552. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43553. import { Observable } from "babylonjs/Misc/observable";
  43554. /**
  43555. * Vive Controller
  43556. */
  43557. export class ViveController extends WebVRController {
  43558. /**
  43559. * Base Url for the controller model.
  43560. */
  43561. static MODEL_BASE_URL: string;
  43562. /**
  43563. * File name for the controller model.
  43564. */
  43565. static MODEL_FILENAME: string;
  43566. /**
  43567. * Creates a new ViveController from a gamepad
  43568. * @param vrGamepad the gamepad that the controller should be created from
  43569. */
  43570. constructor(vrGamepad: any);
  43571. /**
  43572. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43573. * @param scene scene in which to add meshes
  43574. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43575. */
  43576. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43577. /**
  43578. * Fired when the left button on this controller is modified
  43579. */
  43580. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43581. /**
  43582. * Fired when the right button on this controller is modified
  43583. */
  43584. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43585. /**
  43586. * Fired when the menu button on this controller is modified
  43587. */
  43588. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43589. /**
  43590. * Called once for each button that changed state since the last frame
  43591. * Vive mapping:
  43592. * 0: touchpad
  43593. * 1: trigger
  43594. * 2: left AND right buttons
  43595. * 3: menu button
  43596. * @param buttonIdx Which button index changed
  43597. * @param state New state of the button
  43598. * @param changes Which properties on the state changed since last frame
  43599. */
  43600. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43601. }
  43602. }
  43603. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43604. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43605. /**
  43606. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43607. */
  43608. export class WebXRControllerModelLoader {
  43609. /**
  43610. * Creates the WebXRControllerModelLoader
  43611. * @param input xr input that creates the controllers
  43612. */
  43613. constructor(input: WebXRInput);
  43614. }
  43615. }
  43616. declare module "babylonjs/Cameras/XR/index" {
  43617. export * from "babylonjs/Cameras/XR/webXRCamera";
  43618. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43619. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43620. export * from "babylonjs/Cameras/XR/webXRInput";
  43621. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43622. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43623. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43624. export * from "babylonjs/Cameras/XR/webXRController";
  43625. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43626. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43627. }
  43628. declare module "babylonjs/Cameras/RigModes/index" {
  43629. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43630. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43631. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43632. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43633. }
  43634. declare module "babylonjs/Cameras/index" {
  43635. export * from "babylonjs/Cameras/Inputs/index";
  43636. export * from "babylonjs/Cameras/cameraInputsManager";
  43637. export * from "babylonjs/Cameras/camera";
  43638. export * from "babylonjs/Cameras/targetCamera";
  43639. export * from "babylonjs/Cameras/freeCamera";
  43640. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43641. export * from "babylonjs/Cameras/touchCamera";
  43642. export * from "babylonjs/Cameras/arcRotateCamera";
  43643. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43644. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43645. export * from "babylonjs/Cameras/flyCamera";
  43646. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43647. export * from "babylonjs/Cameras/followCamera";
  43648. export * from "babylonjs/Cameras/gamepadCamera";
  43649. export * from "babylonjs/Cameras/Stereoscopic/index";
  43650. export * from "babylonjs/Cameras/universalCamera";
  43651. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43652. export * from "babylonjs/Cameras/VR/index";
  43653. export * from "babylonjs/Cameras/XR/index";
  43654. export * from "babylonjs/Cameras/RigModes/index";
  43655. }
  43656. declare module "babylonjs/Collisions/index" {
  43657. export * from "babylonjs/Collisions/collider";
  43658. export * from "babylonjs/Collisions/collisionCoordinator";
  43659. export * from "babylonjs/Collisions/pickingInfo";
  43660. export * from "babylonjs/Collisions/intersectionInfo";
  43661. export * from "babylonjs/Collisions/meshCollisionData";
  43662. }
  43663. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43664. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43665. import { Vector3 } from "babylonjs/Maths/math.vector";
  43666. import { Ray } from "babylonjs/Culling/ray";
  43667. import { Plane } from "babylonjs/Maths/math.plane";
  43668. /**
  43669. * Contains an array of blocks representing the octree
  43670. */
  43671. export interface IOctreeContainer<T> {
  43672. /**
  43673. * Blocks within the octree
  43674. */
  43675. blocks: Array<OctreeBlock<T>>;
  43676. }
  43677. /**
  43678. * Class used to store a cell in an octree
  43679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43680. */
  43681. export class OctreeBlock<T> {
  43682. /**
  43683. * Gets the content of the current block
  43684. */
  43685. entries: T[];
  43686. /**
  43687. * Gets the list of block children
  43688. */
  43689. blocks: Array<OctreeBlock<T>>;
  43690. private _depth;
  43691. private _maxDepth;
  43692. private _capacity;
  43693. private _minPoint;
  43694. private _maxPoint;
  43695. private _boundingVectors;
  43696. private _creationFunc;
  43697. /**
  43698. * Creates a new block
  43699. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43700. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43701. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43702. * @param depth defines the current depth of this block in the octree
  43703. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43704. * @param creationFunc defines a callback to call when an element is added to the block
  43705. */
  43706. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43707. /**
  43708. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43709. */
  43710. readonly capacity: number;
  43711. /**
  43712. * Gets the minimum vector (in world space) of the block's bounding box
  43713. */
  43714. readonly minPoint: Vector3;
  43715. /**
  43716. * Gets the maximum vector (in world space) of the block's bounding box
  43717. */
  43718. readonly maxPoint: Vector3;
  43719. /**
  43720. * Add a new element to this block
  43721. * @param entry defines the element to add
  43722. */
  43723. addEntry(entry: T): void;
  43724. /**
  43725. * Remove an element from this block
  43726. * @param entry defines the element to remove
  43727. */
  43728. removeEntry(entry: T): void;
  43729. /**
  43730. * Add an array of elements to this block
  43731. * @param entries defines the array of elements to add
  43732. */
  43733. addEntries(entries: T[]): void;
  43734. /**
  43735. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43736. * @param frustumPlanes defines the frustum planes to test
  43737. * @param selection defines the array to store current content if selection is positive
  43738. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43739. */
  43740. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43741. /**
  43742. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43743. * @param sphereCenter defines the bounding sphere center
  43744. * @param sphereRadius defines the bounding sphere radius
  43745. * @param selection defines the array to store current content if selection is positive
  43746. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43747. */
  43748. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43749. /**
  43750. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43751. * @param ray defines the ray to test with
  43752. * @param selection defines the array to store current content if selection is positive
  43753. */
  43754. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43755. /**
  43756. * Subdivide the content into child blocks (this block will then be empty)
  43757. */
  43758. createInnerBlocks(): void;
  43759. /**
  43760. * @hidden
  43761. */
  43762. 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;
  43763. }
  43764. }
  43765. declare module "babylonjs/Culling/Octrees/octree" {
  43766. import { SmartArray } from "babylonjs/Misc/smartArray";
  43767. import { Vector3 } from "babylonjs/Maths/math.vector";
  43768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43770. import { Ray } from "babylonjs/Culling/ray";
  43771. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43772. import { Plane } from "babylonjs/Maths/math.plane";
  43773. /**
  43774. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43775. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43776. */
  43777. export class Octree<T> {
  43778. /** 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.) */
  43779. maxDepth: number;
  43780. /**
  43781. * Blocks within the octree containing objects
  43782. */
  43783. blocks: Array<OctreeBlock<T>>;
  43784. /**
  43785. * Content stored in the octree
  43786. */
  43787. dynamicContent: T[];
  43788. private _maxBlockCapacity;
  43789. private _selectionContent;
  43790. private _creationFunc;
  43791. /**
  43792. * Creates a octree
  43793. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43794. * @param creationFunc function to be used to instatiate the octree
  43795. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43796. * @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.)
  43797. */
  43798. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43799. /** 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.) */
  43800. maxDepth?: number);
  43801. /**
  43802. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43803. * @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);
  43804. * @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);
  43805. * @param entries meshes to be added to the octree blocks
  43806. */
  43807. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43808. /**
  43809. * Adds a mesh to the octree
  43810. * @param entry Mesh to add to the octree
  43811. */
  43812. addMesh(entry: T): void;
  43813. /**
  43814. * Remove an element from the octree
  43815. * @param entry defines the element to remove
  43816. */
  43817. removeMesh(entry: T): void;
  43818. /**
  43819. * Selects an array of meshes within the frustum
  43820. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43821. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43822. * @returns array of meshes within the frustum
  43823. */
  43824. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43825. /**
  43826. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43827. * @param sphereCenter defines the bounding sphere center
  43828. * @param sphereRadius defines the bounding sphere radius
  43829. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43830. * @returns an array of objects that intersect the sphere
  43831. */
  43832. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43833. /**
  43834. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43835. * @param ray defines the ray to test with
  43836. * @returns array of intersected objects
  43837. */
  43838. intersectsRay(ray: Ray): SmartArray<T>;
  43839. /**
  43840. * Adds a mesh into the octree block if it intersects the block
  43841. */
  43842. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43843. /**
  43844. * Adds a submesh into the octree block if it intersects the block
  43845. */
  43846. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43847. }
  43848. }
  43849. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43850. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43851. import { Scene } from "babylonjs/scene";
  43852. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43854. import { Ray } from "babylonjs/Culling/ray";
  43855. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43856. import { Collider } from "babylonjs/Collisions/collider";
  43857. module "babylonjs/scene" {
  43858. interface Scene {
  43859. /**
  43860. * @hidden
  43861. * Backing Filed
  43862. */
  43863. _selectionOctree: Octree<AbstractMesh>;
  43864. /**
  43865. * Gets the octree used to boost mesh selection (picking)
  43866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43867. */
  43868. selectionOctree: Octree<AbstractMesh>;
  43869. /**
  43870. * Creates or updates the octree used to boost selection (picking)
  43871. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43872. * @param maxCapacity defines the maximum capacity per leaf
  43873. * @param maxDepth defines the maximum depth of the octree
  43874. * @returns an octree of AbstractMesh
  43875. */
  43876. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43877. }
  43878. }
  43879. module "babylonjs/Meshes/abstractMesh" {
  43880. interface AbstractMesh {
  43881. /**
  43882. * @hidden
  43883. * Backing Field
  43884. */
  43885. _submeshesOctree: Octree<SubMesh>;
  43886. /**
  43887. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43888. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43889. * @param maxCapacity defines the maximum size of each block (64 by default)
  43890. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43891. * @returns the new octree
  43892. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43894. */
  43895. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43896. }
  43897. }
  43898. /**
  43899. * Defines the octree scene component responsible to manage any octrees
  43900. * in a given scene.
  43901. */
  43902. export class OctreeSceneComponent {
  43903. /**
  43904. * The component name help to identify the component in the list of scene components.
  43905. */
  43906. readonly name: string;
  43907. /**
  43908. * The scene the component belongs to.
  43909. */
  43910. scene: Scene;
  43911. /**
  43912. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43913. */
  43914. readonly checksIsEnabled: boolean;
  43915. /**
  43916. * Creates a new instance of the component for the given scene
  43917. * @param scene Defines the scene to register the component in
  43918. */
  43919. constructor(scene: Scene);
  43920. /**
  43921. * Registers the component in a given scene
  43922. */
  43923. register(): void;
  43924. /**
  43925. * Return the list of active meshes
  43926. * @returns the list of active meshes
  43927. */
  43928. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43929. /**
  43930. * Return the list of active sub meshes
  43931. * @param mesh The mesh to get the candidates sub meshes from
  43932. * @returns the list of active sub meshes
  43933. */
  43934. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43935. private _tempRay;
  43936. /**
  43937. * Return the list of sub meshes intersecting with a given local ray
  43938. * @param mesh defines the mesh to find the submesh for
  43939. * @param localRay defines the ray in local space
  43940. * @returns the list of intersecting sub meshes
  43941. */
  43942. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43943. /**
  43944. * Return the list of sub meshes colliding with a collider
  43945. * @param mesh defines the mesh to find the submesh for
  43946. * @param collider defines the collider to evaluate the collision against
  43947. * @returns the list of colliding sub meshes
  43948. */
  43949. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43950. /**
  43951. * Rebuilds the elements related to this component in case of
  43952. * context lost for instance.
  43953. */
  43954. rebuild(): void;
  43955. /**
  43956. * Disposes the component and the associated ressources.
  43957. */
  43958. dispose(): void;
  43959. }
  43960. }
  43961. declare module "babylonjs/Culling/Octrees/index" {
  43962. export * from "babylonjs/Culling/Octrees/octree";
  43963. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43964. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43965. }
  43966. declare module "babylonjs/Culling/index" {
  43967. export * from "babylonjs/Culling/boundingBox";
  43968. export * from "babylonjs/Culling/boundingInfo";
  43969. export * from "babylonjs/Culling/boundingSphere";
  43970. export * from "babylonjs/Culling/Octrees/index";
  43971. export * from "babylonjs/Culling/ray";
  43972. }
  43973. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43974. import { IDisposable, Scene } from "babylonjs/scene";
  43975. import { Nullable } from "babylonjs/types";
  43976. import { Observable } from "babylonjs/Misc/observable";
  43977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43978. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43979. import { Camera } from "babylonjs/Cameras/camera";
  43980. /**
  43981. * Renders a layer on top of an existing scene
  43982. */
  43983. export class UtilityLayerRenderer implements IDisposable {
  43984. /** the original scene that will be rendered on top of */
  43985. originalScene: Scene;
  43986. private _pointerCaptures;
  43987. private _lastPointerEvents;
  43988. private static _DefaultUtilityLayer;
  43989. private static _DefaultKeepDepthUtilityLayer;
  43990. private _sharedGizmoLight;
  43991. private _renderCamera;
  43992. /**
  43993. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43994. * @returns the camera that is used when rendering the utility layer
  43995. */
  43996. getRenderCamera(): Nullable<Camera>;
  43997. /**
  43998. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43999. * @param cam the camera that should be used when rendering the utility layer
  44000. */
  44001. setRenderCamera(cam: Nullable<Camera>): void;
  44002. /**
  44003. * @hidden
  44004. * Light which used by gizmos to get light shading
  44005. */
  44006. _getSharedGizmoLight(): HemisphericLight;
  44007. /**
  44008. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44009. */
  44010. pickUtilitySceneFirst: boolean;
  44011. /**
  44012. * 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)
  44013. */
  44014. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44015. /**
  44016. * 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)
  44017. */
  44018. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44019. /**
  44020. * The scene that is rendered on top of the original scene
  44021. */
  44022. utilityLayerScene: Scene;
  44023. /**
  44024. * If the utility layer should automatically be rendered on top of existing scene
  44025. */
  44026. shouldRender: boolean;
  44027. /**
  44028. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44029. */
  44030. onlyCheckPointerDownEvents: boolean;
  44031. /**
  44032. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44033. */
  44034. processAllEvents: boolean;
  44035. /**
  44036. * Observable raised when the pointer move from the utility layer scene to the main scene
  44037. */
  44038. onPointerOutObservable: Observable<number>;
  44039. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44040. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44041. private _afterRenderObserver;
  44042. private _sceneDisposeObserver;
  44043. private _originalPointerObserver;
  44044. /**
  44045. * Instantiates a UtilityLayerRenderer
  44046. * @param originalScene the original scene that will be rendered on top of
  44047. * @param handleEvents boolean indicating if the utility layer should handle events
  44048. */
  44049. constructor(
  44050. /** the original scene that will be rendered on top of */
  44051. originalScene: Scene, handleEvents?: boolean);
  44052. private _notifyObservers;
  44053. /**
  44054. * Renders the utility layers scene on top of the original scene
  44055. */
  44056. render(): void;
  44057. /**
  44058. * Disposes of the renderer
  44059. */
  44060. dispose(): void;
  44061. private _updateCamera;
  44062. }
  44063. }
  44064. declare module "babylonjs/Gizmos/gizmo" {
  44065. import { Nullable } from "babylonjs/types";
  44066. import { IDisposable } from "babylonjs/scene";
  44067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44068. import { Mesh } from "babylonjs/Meshes/mesh";
  44069. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44070. /**
  44071. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44072. */
  44073. export class Gizmo implements IDisposable {
  44074. /** The utility layer the gizmo will be added to */
  44075. gizmoLayer: UtilityLayerRenderer;
  44076. /**
  44077. * The root mesh of the gizmo
  44078. */
  44079. _rootMesh: Mesh;
  44080. private _attachedMesh;
  44081. /**
  44082. * Ratio for the scale of the gizmo (Default: 1)
  44083. */
  44084. scaleRatio: number;
  44085. /**
  44086. * If a custom mesh has been set (Default: false)
  44087. */
  44088. protected _customMeshSet: boolean;
  44089. /**
  44090. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44091. * * When set, interactions will be enabled
  44092. */
  44093. attachedMesh: Nullable<AbstractMesh>;
  44094. /**
  44095. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44096. * @param mesh The mesh to replace the default mesh of the gizmo
  44097. */
  44098. setCustomMesh(mesh: Mesh): void;
  44099. /**
  44100. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44101. */
  44102. updateGizmoRotationToMatchAttachedMesh: boolean;
  44103. /**
  44104. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44105. */
  44106. updateGizmoPositionToMatchAttachedMesh: boolean;
  44107. /**
  44108. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44109. */
  44110. updateScale: boolean;
  44111. protected _interactionsEnabled: boolean;
  44112. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44113. private _beforeRenderObserver;
  44114. private _tempVector;
  44115. /**
  44116. * Creates a gizmo
  44117. * @param gizmoLayer The utility layer the gizmo will be added to
  44118. */
  44119. constructor(
  44120. /** The utility layer the gizmo will be added to */
  44121. gizmoLayer?: UtilityLayerRenderer);
  44122. /**
  44123. * Updates the gizmo to match the attached mesh's position/rotation
  44124. */
  44125. protected _update(): void;
  44126. /**
  44127. * Disposes of the gizmo
  44128. */
  44129. dispose(): void;
  44130. }
  44131. }
  44132. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44133. import { Observable } from "babylonjs/Misc/observable";
  44134. import { Nullable } from "babylonjs/types";
  44135. import { Vector3 } from "babylonjs/Maths/math.vector";
  44136. import { Color3 } from "babylonjs/Maths/math.color";
  44137. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44139. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44140. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44141. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44142. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44143. import { Scene } from "babylonjs/scene";
  44144. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44145. /**
  44146. * Single plane drag gizmo
  44147. */
  44148. export class PlaneDragGizmo extends Gizmo {
  44149. /**
  44150. * Drag behavior responsible for the gizmos dragging interactions
  44151. */
  44152. dragBehavior: PointerDragBehavior;
  44153. private _pointerObserver;
  44154. /**
  44155. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44156. */
  44157. snapDistance: number;
  44158. /**
  44159. * Event that fires each time the gizmo snaps to a new location.
  44160. * * snapDistance is the the change in distance
  44161. */
  44162. onSnapObservable: Observable<{
  44163. snapDistance: number;
  44164. }>;
  44165. private _plane;
  44166. private _coloredMaterial;
  44167. private _hoverMaterial;
  44168. private _isEnabled;
  44169. private _parent;
  44170. /** @hidden */
  44171. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44172. /** @hidden */
  44173. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44174. /**
  44175. * Creates a PlaneDragGizmo
  44176. * @param gizmoLayer The utility layer the gizmo will be added to
  44177. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44178. * @param color The color of the gizmo
  44179. */
  44180. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44181. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44182. /**
  44183. * If the gizmo is enabled
  44184. */
  44185. isEnabled: boolean;
  44186. /**
  44187. * Disposes of the gizmo
  44188. */
  44189. dispose(): void;
  44190. }
  44191. }
  44192. declare module "babylonjs/Gizmos/positionGizmo" {
  44193. import { Observable } from "babylonjs/Misc/observable";
  44194. import { Nullable } from "babylonjs/types";
  44195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44196. import { Mesh } from "babylonjs/Meshes/mesh";
  44197. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44198. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44199. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44200. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44201. /**
  44202. * Gizmo that enables dragging a mesh along 3 axis
  44203. */
  44204. export class PositionGizmo extends Gizmo {
  44205. /**
  44206. * Internal gizmo used for interactions on the x axis
  44207. */
  44208. xGizmo: AxisDragGizmo;
  44209. /**
  44210. * Internal gizmo used for interactions on the y axis
  44211. */
  44212. yGizmo: AxisDragGizmo;
  44213. /**
  44214. * Internal gizmo used for interactions on the z axis
  44215. */
  44216. zGizmo: AxisDragGizmo;
  44217. /**
  44218. * Internal gizmo used for interactions on the yz plane
  44219. */
  44220. xPlaneGizmo: PlaneDragGizmo;
  44221. /**
  44222. * Internal gizmo used for interactions on the xz plane
  44223. */
  44224. yPlaneGizmo: PlaneDragGizmo;
  44225. /**
  44226. * Internal gizmo used for interactions on the xy plane
  44227. */
  44228. zPlaneGizmo: PlaneDragGizmo;
  44229. /**
  44230. * private variables
  44231. */
  44232. private _meshAttached;
  44233. private _updateGizmoRotationToMatchAttachedMesh;
  44234. private _snapDistance;
  44235. private _scaleRatio;
  44236. /** Fires an event when any of it's sub gizmos are dragged */
  44237. onDragStartObservable: Observable<unknown>;
  44238. /** Fires an event when any of it's sub gizmos are released from dragging */
  44239. onDragEndObservable: Observable<unknown>;
  44240. /**
  44241. * If set to true, planar drag is enabled
  44242. */
  44243. private _planarGizmoEnabled;
  44244. attachedMesh: Nullable<AbstractMesh>;
  44245. /**
  44246. * Creates a PositionGizmo
  44247. * @param gizmoLayer The utility layer the gizmo will be added to
  44248. */
  44249. constructor(gizmoLayer?: UtilityLayerRenderer);
  44250. /**
  44251. * If the planar drag gizmo is enabled
  44252. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44253. */
  44254. planarGizmoEnabled: boolean;
  44255. updateGizmoRotationToMatchAttachedMesh: boolean;
  44256. /**
  44257. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44258. */
  44259. snapDistance: number;
  44260. /**
  44261. * Ratio for the scale of the gizmo (Default: 1)
  44262. */
  44263. scaleRatio: number;
  44264. /**
  44265. * Disposes of the gizmo
  44266. */
  44267. dispose(): void;
  44268. /**
  44269. * CustomMeshes are not supported by this gizmo
  44270. * @param mesh The mesh to replace the default mesh of the gizmo
  44271. */
  44272. setCustomMesh(mesh: Mesh): void;
  44273. }
  44274. }
  44275. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44276. import { Observable } from "babylonjs/Misc/observable";
  44277. import { Nullable } from "babylonjs/types";
  44278. import { Vector3 } from "babylonjs/Maths/math.vector";
  44279. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44281. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44282. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44283. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44284. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44285. import { Scene } from "babylonjs/scene";
  44286. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44287. import { Color3 } from "babylonjs/Maths/math.color";
  44288. /**
  44289. * Single axis drag gizmo
  44290. */
  44291. export class AxisDragGizmo extends Gizmo {
  44292. /**
  44293. * Drag behavior responsible for the gizmos dragging interactions
  44294. */
  44295. dragBehavior: PointerDragBehavior;
  44296. private _pointerObserver;
  44297. /**
  44298. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44299. */
  44300. snapDistance: number;
  44301. /**
  44302. * Event that fires each time the gizmo snaps to a new location.
  44303. * * snapDistance is the the change in distance
  44304. */
  44305. onSnapObservable: Observable<{
  44306. snapDistance: number;
  44307. }>;
  44308. private _isEnabled;
  44309. private _parent;
  44310. private _arrow;
  44311. private _coloredMaterial;
  44312. private _hoverMaterial;
  44313. /** @hidden */
  44314. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44315. /** @hidden */
  44316. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44317. /**
  44318. * Creates an AxisDragGizmo
  44319. * @param gizmoLayer The utility layer the gizmo will be added to
  44320. * @param dragAxis The axis which the gizmo will be able to drag on
  44321. * @param color The color of the gizmo
  44322. */
  44323. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44324. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44325. /**
  44326. * If the gizmo is enabled
  44327. */
  44328. isEnabled: boolean;
  44329. /**
  44330. * Disposes of the gizmo
  44331. */
  44332. dispose(): void;
  44333. }
  44334. }
  44335. declare module "babylonjs/Debug/axesViewer" {
  44336. import { Vector3 } from "babylonjs/Maths/math.vector";
  44337. import { Nullable } from "babylonjs/types";
  44338. import { Scene } from "babylonjs/scene";
  44339. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44340. /**
  44341. * The Axes viewer will show 3 axes in a specific point in space
  44342. */
  44343. export class AxesViewer {
  44344. private _xAxis;
  44345. private _yAxis;
  44346. private _zAxis;
  44347. private _scaleLinesFactor;
  44348. private _instanced;
  44349. /**
  44350. * Gets the hosting scene
  44351. */
  44352. scene: Scene;
  44353. /**
  44354. * Gets or sets a number used to scale line length
  44355. */
  44356. scaleLines: number;
  44357. /** Gets the node hierarchy used to render x-axis */
  44358. readonly xAxis: TransformNode;
  44359. /** Gets the node hierarchy used to render y-axis */
  44360. readonly yAxis: TransformNode;
  44361. /** Gets the node hierarchy used to render z-axis */
  44362. readonly zAxis: TransformNode;
  44363. /**
  44364. * Creates a new AxesViewer
  44365. * @param scene defines the hosting scene
  44366. * @param scaleLines defines a number used to scale line length (1 by default)
  44367. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44368. * @param xAxis defines the node hierarchy used to render the x-axis
  44369. * @param yAxis defines the node hierarchy used to render the y-axis
  44370. * @param zAxis defines the node hierarchy used to render the z-axis
  44371. */
  44372. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44373. /**
  44374. * Force the viewer to update
  44375. * @param position defines the position of the viewer
  44376. * @param xaxis defines the x axis of the viewer
  44377. * @param yaxis defines the y axis of the viewer
  44378. * @param zaxis defines the z axis of the viewer
  44379. */
  44380. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44381. /**
  44382. * Creates an instance of this axes viewer.
  44383. * @returns a new axes viewer with instanced meshes
  44384. */
  44385. createInstance(): AxesViewer;
  44386. /** Releases resources */
  44387. dispose(): void;
  44388. private static _SetRenderingGroupId;
  44389. }
  44390. }
  44391. declare module "babylonjs/Debug/boneAxesViewer" {
  44392. import { Nullable } from "babylonjs/types";
  44393. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44394. import { Vector3 } from "babylonjs/Maths/math.vector";
  44395. import { Mesh } from "babylonjs/Meshes/mesh";
  44396. import { Bone } from "babylonjs/Bones/bone";
  44397. import { Scene } from "babylonjs/scene";
  44398. /**
  44399. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44400. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44401. */
  44402. export class BoneAxesViewer extends AxesViewer {
  44403. /**
  44404. * Gets or sets the target mesh where to display the axes viewer
  44405. */
  44406. mesh: Nullable<Mesh>;
  44407. /**
  44408. * Gets or sets the target bone where to display the axes viewer
  44409. */
  44410. bone: Nullable<Bone>;
  44411. /** Gets current position */
  44412. pos: Vector3;
  44413. /** Gets direction of X axis */
  44414. xaxis: Vector3;
  44415. /** Gets direction of Y axis */
  44416. yaxis: Vector3;
  44417. /** Gets direction of Z axis */
  44418. zaxis: Vector3;
  44419. /**
  44420. * Creates a new BoneAxesViewer
  44421. * @param scene defines the hosting scene
  44422. * @param bone defines the target bone
  44423. * @param mesh defines the target mesh
  44424. * @param scaleLines defines a scaling factor for line length (1 by default)
  44425. */
  44426. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44427. /**
  44428. * Force the viewer to update
  44429. */
  44430. update(): void;
  44431. /** Releases resources */
  44432. dispose(): void;
  44433. }
  44434. }
  44435. declare module "babylonjs/Debug/debugLayer" {
  44436. import { Scene } from "babylonjs/scene";
  44437. /**
  44438. * Interface used to define scene explorer extensibility option
  44439. */
  44440. export interface IExplorerExtensibilityOption {
  44441. /**
  44442. * Define the option label
  44443. */
  44444. label: string;
  44445. /**
  44446. * Defines the action to execute on click
  44447. */
  44448. action: (entity: any) => void;
  44449. }
  44450. /**
  44451. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44452. */
  44453. export interface IExplorerExtensibilityGroup {
  44454. /**
  44455. * Defines a predicate to test if a given type mut be extended
  44456. */
  44457. predicate: (entity: any) => boolean;
  44458. /**
  44459. * Gets the list of options added to a type
  44460. */
  44461. entries: IExplorerExtensibilityOption[];
  44462. }
  44463. /**
  44464. * Interface used to define the options to use to create the Inspector
  44465. */
  44466. export interface IInspectorOptions {
  44467. /**
  44468. * Display in overlay mode (default: false)
  44469. */
  44470. overlay?: boolean;
  44471. /**
  44472. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44473. */
  44474. globalRoot?: HTMLElement;
  44475. /**
  44476. * Display the Scene explorer
  44477. */
  44478. showExplorer?: boolean;
  44479. /**
  44480. * Display the property inspector
  44481. */
  44482. showInspector?: boolean;
  44483. /**
  44484. * Display in embed mode (both panes on the right)
  44485. */
  44486. embedMode?: boolean;
  44487. /**
  44488. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44489. */
  44490. handleResize?: boolean;
  44491. /**
  44492. * Allow the panes to popup (default: true)
  44493. */
  44494. enablePopup?: boolean;
  44495. /**
  44496. * Allow the panes to be closed by users (default: true)
  44497. */
  44498. enableClose?: boolean;
  44499. /**
  44500. * Optional list of extensibility entries
  44501. */
  44502. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44503. /**
  44504. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44505. */
  44506. inspectorURL?: string;
  44507. }
  44508. module "babylonjs/scene" {
  44509. interface Scene {
  44510. /**
  44511. * @hidden
  44512. * Backing field
  44513. */
  44514. _debugLayer: DebugLayer;
  44515. /**
  44516. * Gets the debug layer (aka Inspector) associated with the scene
  44517. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44518. */
  44519. debugLayer: DebugLayer;
  44520. }
  44521. }
  44522. /**
  44523. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44524. * what is happening in your scene
  44525. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44526. */
  44527. export class DebugLayer {
  44528. /**
  44529. * Define the url to get the inspector script from.
  44530. * By default it uses the babylonjs CDN.
  44531. * @ignoreNaming
  44532. */
  44533. static InspectorURL: string;
  44534. private _scene;
  44535. private BJSINSPECTOR;
  44536. private _onPropertyChangedObservable?;
  44537. /**
  44538. * Observable triggered when a property is changed through the inspector.
  44539. */
  44540. readonly onPropertyChangedObservable: any;
  44541. /**
  44542. * Instantiates a new debug layer.
  44543. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44544. * what is happening in your scene
  44545. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44546. * @param scene Defines the scene to inspect
  44547. */
  44548. constructor(scene: Scene);
  44549. /** Creates the inspector window. */
  44550. private _createInspector;
  44551. /**
  44552. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44553. * @param entity defines the entity to select
  44554. * @param lineContainerTitle defines the specific block to highlight
  44555. */
  44556. select(entity: any, lineContainerTitle?: string): void;
  44557. /** Get the inspector from bundle or global */
  44558. private _getGlobalInspector;
  44559. /**
  44560. * Get if the inspector is visible or not.
  44561. * @returns true if visible otherwise, false
  44562. */
  44563. isVisible(): boolean;
  44564. /**
  44565. * Hide the inspector and close its window.
  44566. */
  44567. hide(): void;
  44568. /**
  44569. * Launch the debugLayer.
  44570. * @param config Define the configuration of the inspector
  44571. * @return a promise fulfilled when the debug layer is visible
  44572. */
  44573. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44574. }
  44575. }
  44576. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44577. import { Nullable } from "babylonjs/types";
  44578. import { Scene } from "babylonjs/scene";
  44579. import { Vector4 } from "babylonjs/Maths/math.vector";
  44580. import { Color4 } from "babylonjs/Maths/math.color";
  44581. import { Mesh } from "babylonjs/Meshes/mesh";
  44582. /**
  44583. * Class containing static functions to help procedurally build meshes
  44584. */
  44585. export class BoxBuilder {
  44586. /**
  44587. * Creates a box mesh
  44588. * * The parameter `size` sets the size (float) of each box side (default 1)
  44589. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44590. * * 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)
  44591. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44595. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44596. * @param name defines the name of the mesh
  44597. * @param options defines the options used to create the mesh
  44598. * @param scene defines the hosting scene
  44599. * @returns the box mesh
  44600. */
  44601. static CreateBox(name: string, options: {
  44602. size?: number;
  44603. width?: number;
  44604. height?: number;
  44605. depth?: number;
  44606. faceUV?: Vector4[];
  44607. faceColors?: Color4[];
  44608. sideOrientation?: number;
  44609. frontUVs?: Vector4;
  44610. backUVs?: Vector4;
  44611. wrap?: boolean;
  44612. topBaseAt?: number;
  44613. bottomBaseAt?: number;
  44614. updatable?: boolean;
  44615. }, scene?: Nullable<Scene>): Mesh;
  44616. }
  44617. }
  44618. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44619. import { Vector4 } from "babylonjs/Maths/math.vector";
  44620. import { Mesh } from "babylonjs/Meshes/mesh";
  44621. /**
  44622. * Class containing static functions to help procedurally build meshes
  44623. */
  44624. export class SphereBuilder {
  44625. /**
  44626. * Creates a sphere mesh
  44627. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44628. * * 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`)
  44629. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44630. * * 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
  44631. * * 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)
  44632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44635. * @param name defines the name of the mesh
  44636. * @param options defines the options used to create the mesh
  44637. * @param scene defines the hosting scene
  44638. * @returns the sphere mesh
  44639. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44640. */
  44641. static CreateSphere(name: string, options: {
  44642. segments?: number;
  44643. diameter?: number;
  44644. diameterX?: number;
  44645. diameterY?: number;
  44646. diameterZ?: number;
  44647. arc?: number;
  44648. slice?: number;
  44649. sideOrientation?: number;
  44650. frontUVs?: Vector4;
  44651. backUVs?: Vector4;
  44652. updatable?: boolean;
  44653. }, scene: any): Mesh;
  44654. }
  44655. }
  44656. declare module "babylonjs/Debug/physicsViewer" {
  44657. import { Nullable } from "babylonjs/types";
  44658. import { Scene } from "babylonjs/scene";
  44659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44660. import { Mesh } from "babylonjs/Meshes/mesh";
  44661. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44662. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44663. /**
  44664. * Used to show the physics impostor around the specific mesh
  44665. */
  44666. export class PhysicsViewer {
  44667. /** @hidden */
  44668. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44669. /** @hidden */
  44670. protected _meshes: Array<Nullable<AbstractMesh>>;
  44671. /** @hidden */
  44672. protected _scene: Nullable<Scene>;
  44673. /** @hidden */
  44674. protected _numMeshes: number;
  44675. /** @hidden */
  44676. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44677. private _renderFunction;
  44678. private _utilityLayer;
  44679. private _debugBoxMesh;
  44680. private _debugSphereMesh;
  44681. private _debugCylinderMesh;
  44682. private _debugMaterial;
  44683. private _debugMeshMeshes;
  44684. /**
  44685. * Creates a new PhysicsViewer
  44686. * @param scene defines the hosting scene
  44687. */
  44688. constructor(scene: Scene);
  44689. /** @hidden */
  44690. protected _updateDebugMeshes(): void;
  44691. /**
  44692. * Renders a specified physic impostor
  44693. * @param impostor defines the impostor to render
  44694. * @param targetMesh defines the mesh represented by the impostor
  44695. * @returns the new debug mesh used to render the impostor
  44696. */
  44697. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44698. /**
  44699. * Hides a specified physic impostor
  44700. * @param impostor defines the impostor to hide
  44701. */
  44702. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44703. private _getDebugMaterial;
  44704. private _getDebugBoxMesh;
  44705. private _getDebugSphereMesh;
  44706. private _getDebugCylinderMesh;
  44707. private _getDebugMeshMesh;
  44708. private _getDebugMesh;
  44709. /** Releases all resources */
  44710. dispose(): void;
  44711. }
  44712. }
  44713. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44714. import { Vector3 } from "babylonjs/Maths/math.vector";
  44715. import { Color4 } from "babylonjs/Maths/math.color";
  44716. import { Nullable } from "babylonjs/types";
  44717. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44718. import { Scene } from "babylonjs/scene";
  44719. /**
  44720. * Class containing static functions to help procedurally build meshes
  44721. */
  44722. export class LinesBuilder {
  44723. /**
  44724. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44725. * * 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
  44726. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44727. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44728. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44729. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44730. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44731. * * 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
  44732. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44735. * @param name defines the name of the new line system
  44736. * @param options defines the options used to create the line system
  44737. * @param scene defines the hosting scene
  44738. * @returns a new line system mesh
  44739. */
  44740. static CreateLineSystem(name: string, options: {
  44741. lines: Vector3[][];
  44742. updatable?: boolean;
  44743. instance?: Nullable<LinesMesh>;
  44744. colors?: Nullable<Color4[][]>;
  44745. useVertexAlpha?: boolean;
  44746. }, scene: Nullable<Scene>): LinesMesh;
  44747. /**
  44748. * Creates a line mesh
  44749. * 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
  44750. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44751. * * The parameter `points` is an array successive Vector3
  44752. * * 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
  44753. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44754. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44755. * * When updating an instance, remember that only point positions can change, not the number of points
  44756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44758. * @param name defines the name of the new line system
  44759. * @param options defines the options used to create the line system
  44760. * @param scene defines the hosting scene
  44761. * @returns a new line mesh
  44762. */
  44763. static CreateLines(name: string, options: {
  44764. points: Vector3[];
  44765. updatable?: boolean;
  44766. instance?: Nullable<LinesMesh>;
  44767. colors?: Color4[];
  44768. useVertexAlpha?: boolean;
  44769. }, scene?: Nullable<Scene>): LinesMesh;
  44770. /**
  44771. * Creates a dashed line mesh
  44772. * * 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
  44773. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44774. * * The parameter `points` is an array successive Vector3
  44775. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44776. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44777. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44778. * * 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
  44779. * * When updating an instance, remember that only point positions can change, not the number of points
  44780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44781. * @param name defines the name of the mesh
  44782. * @param options defines the options used to create the mesh
  44783. * @param scene defines the hosting scene
  44784. * @returns the dashed line mesh
  44785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44786. */
  44787. static CreateDashedLines(name: string, options: {
  44788. points: Vector3[];
  44789. dashSize?: number;
  44790. gapSize?: number;
  44791. dashNb?: number;
  44792. updatable?: boolean;
  44793. instance?: LinesMesh;
  44794. }, scene?: Nullable<Scene>): LinesMesh;
  44795. }
  44796. }
  44797. declare module "babylonjs/Debug/rayHelper" {
  44798. import { Nullable } from "babylonjs/types";
  44799. import { Ray } from "babylonjs/Culling/ray";
  44800. import { Vector3 } from "babylonjs/Maths/math.vector";
  44801. import { Color3 } from "babylonjs/Maths/math.color";
  44802. import { Scene } from "babylonjs/scene";
  44803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44804. import "babylonjs/Meshes/Builders/linesBuilder";
  44805. /**
  44806. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44807. * in order to better appreciate the issue one might have.
  44808. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44809. */
  44810. export class RayHelper {
  44811. /**
  44812. * Defines the ray we are currently tryin to visualize.
  44813. */
  44814. ray: Nullable<Ray>;
  44815. private _renderPoints;
  44816. private _renderLine;
  44817. private _renderFunction;
  44818. private _scene;
  44819. private _updateToMeshFunction;
  44820. private _attachedToMesh;
  44821. private _meshSpaceDirection;
  44822. private _meshSpaceOrigin;
  44823. /**
  44824. * Helper function to create a colored helper in a scene in one line.
  44825. * @param ray Defines the ray we are currently tryin to visualize
  44826. * @param scene Defines the scene the ray is used in
  44827. * @param color Defines the color we want to see the ray in
  44828. * @returns The newly created ray helper.
  44829. */
  44830. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44831. /**
  44832. * Instantiate a new ray helper.
  44833. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44834. * in order to better appreciate the issue one might have.
  44835. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44836. * @param ray Defines the ray we are currently tryin to visualize
  44837. */
  44838. constructor(ray: Ray);
  44839. /**
  44840. * Shows the ray we are willing to debug.
  44841. * @param scene Defines the scene the ray needs to be rendered in
  44842. * @param color Defines the color the ray needs to be rendered in
  44843. */
  44844. show(scene: Scene, color?: Color3): void;
  44845. /**
  44846. * Hides the ray we are debugging.
  44847. */
  44848. hide(): void;
  44849. private _render;
  44850. /**
  44851. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44852. * @param mesh Defines the mesh we want the helper attached to
  44853. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44854. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44855. * @param length Defines the length of the ray
  44856. */
  44857. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44858. /**
  44859. * Detach the ray helper from the mesh it has previously been attached to.
  44860. */
  44861. detachFromMesh(): void;
  44862. private _updateToMesh;
  44863. /**
  44864. * Dispose the helper and release its associated resources.
  44865. */
  44866. dispose(): void;
  44867. }
  44868. }
  44869. declare module "babylonjs/Debug/skeletonViewer" {
  44870. import { Color3 } from "babylonjs/Maths/math.color";
  44871. import { Scene } from "babylonjs/scene";
  44872. import { Nullable } from "babylonjs/types";
  44873. import { Skeleton } from "babylonjs/Bones/skeleton";
  44874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44875. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44876. /**
  44877. * Class used to render a debug view of a given skeleton
  44878. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44879. */
  44880. export class SkeletonViewer {
  44881. /** defines the skeleton to render */
  44882. skeleton: Skeleton;
  44883. /** defines the mesh attached to the skeleton */
  44884. mesh: AbstractMesh;
  44885. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44886. autoUpdateBonesMatrices: boolean;
  44887. /** defines the rendering group id to use with the viewer */
  44888. renderingGroupId: number;
  44889. /** Gets or sets the color used to render the skeleton */
  44890. color: Color3;
  44891. private _scene;
  44892. private _debugLines;
  44893. private _debugMesh;
  44894. private _isEnabled;
  44895. private _renderFunction;
  44896. private _utilityLayer;
  44897. /**
  44898. * Returns the mesh used to render the bones
  44899. */
  44900. readonly debugMesh: Nullable<LinesMesh>;
  44901. /**
  44902. * Creates a new SkeletonViewer
  44903. * @param skeleton defines the skeleton to render
  44904. * @param mesh defines the mesh attached to the skeleton
  44905. * @param scene defines the hosting scene
  44906. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44907. * @param renderingGroupId defines the rendering group id to use with the viewer
  44908. */
  44909. constructor(
  44910. /** defines the skeleton to render */
  44911. skeleton: Skeleton,
  44912. /** defines the mesh attached to the skeleton */
  44913. mesh: AbstractMesh, scene: Scene,
  44914. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44915. autoUpdateBonesMatrices?: boolean,
  44916. /** defines the rendering group id to use with the viewer */
  44917. renderingGroupId?: number);
  44918. /** Gets or sets a boolean indicating if the viewer is enabled */
  44919. isEnabled: boolean;
  44920. private _getBonePosition;
  44921. private _getLinesForBonesWithLength;
  44922. private _getLinesForBonesNoLength;
  44923. /** Update the viewer to sync with current skeleton state */
  44924. update(): void;
  44925. /** Release associated resources */
  44926. dispose(): void;
  44927. }
  44928. }
  44929. declare module "babylonjs/Debug/index" {
  44930. export * from "babylonjs/Debug/axesViewer";
  44931. export * from "babylonjs/Debug/boneAxesViewer";
  44932. export * from "babylonjs/Debug/debugLayer";
  44933. export * from "babylonjs/Debug/physicsViewer";
  44934. export * from "babylonjs/Debug/rayHelper";
  44935. export * from "babylonjs/Debug/skeletonViewer";
  44936. }
  44937. declare module "babylonjs/Engines/nullEngine" {
  44938. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44939. import { Scene } from "babylonjs/scene";
  44940. import { Engine } from "babylonjs/Engines/engine";
  44941. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44942. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44943. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44944. import { Effect } from "babylonjs/Materials/effect";
  44945. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44946. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44947. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44948. /**
  44949. * Options to create the null engine
  44950. */
  44951. export class NullEngineOptions {
  44952. /**
  44953. * Render width (Default: 512)
  44954. */
  44955. renderWidth: number;
  44956. /**
  44957. * Render height (Default: 256)
  44958. */
  44959. renderHeight: number;
  44960. /**
  44961. * Texture size (Default: 512)
  44962. */
  44963. textureSize: number;
  44964. /**
  44965. * If delta time between frames should be constant
  44966. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44967. */
  44968. deterministicLockstep: boolean;
  44969. /**
  44970. * Maximum about of steps between frames (Default: 4)
  44971. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44972. */
  44973. lockstepMaxSteps: number;
  44974. }
  44975. /**
  44976. * The null engine class provides support for headless version of babylon.js.
  44977. * This can be used in server side scenario or for testing purposes
  44978. */
  44979. export class NullEngine extends Engine {
  44980. private _options;
  44981. /**
  44982. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44983. */
  44984. isDeterministicLockStep(): boolean;
  44985. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44986. getLockstepMaxSteps(): number;
  44987. /**
  44988. * Sets hardware scaling, used to save performance if needed
  44989. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44990. */
  44991. getHardwareScalingLevel(): number;
  44992. constructor(options?: NullEngineOptions);
  44993. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44994. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44995. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44996. getRenderWidth(useScreen?: boolean): number;
  44997. getRenderHeight(useScreen?: boolean): number;
  44998. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44999. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45000. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45001. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45002. bindSamplers(effect: Effect): void;
  45003. enableEffect(effect: Effect): void;
  45004. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45005. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45006. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45007. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45008. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45009. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45010. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45011. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45012. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45013. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45014. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45015. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45016. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45017. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45018. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45019. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45020. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45021. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45022. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45023. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45024. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45025. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45026. bindBuffers(vertexBuffers: {
  45027. [key: string]: VertexBuffer;
  45028. }, indexBuffer: DataBuffer, effect: Effect): void;
  45029. wipeCaches(bruteForce?: boolean): void;
  45030. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45031. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45032. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45033. /** @hidden */
  45034. _createTexture(): WebGLTexture;
  45035. /** @hidden */
  45036. _releaseTexture(texture: InternalTexture): void;
  45037. 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;
  45038. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45039. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45040. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45041. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45042. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45043. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45044. areAllEffectsReady(): boolean;
  45045. /**
  45046. * @hidden
  45047. * Get the current error code of the webGL context
  45048. * @returns the error code
  45049. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45050. */
  45051. getError(): number;
  45052. /** @hidden */
  45053. _getUnpackAlignement(): number;
  45054. /** @hidden */
  45055. _unpackFlipY(value: boolean): void;
  45056. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45057. /**
  45058. * Updates a dynamic vertex buffer.
  45059. * @param vertexBuffer the vertex buffer to update
  45060. * @param data the data used to update the vertex buffer
  45061. * @param byteOffset the byte offset of the data (optional)
  45062. * @param byteLength the byte length of the data (optional)
  45063. */
  45064. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45065. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45066. /** @hidden */
  45067. _bindTexture(channel: number, texture: InternalTexture): void;
  45068. /** @hidden */
  45069. _releaseBuffer(buffer: DataBuffer): boolean;
  45070. releaseEffects(): void;
  45071. displayLoadingUI(): void;
  45072. hideLoadingUI(): void;
  45073. /** @hidden */
  45074. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45075. /** @hidden */
  45076. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45077. /** @hidden */
  45078. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45079. /** @hidden */
  45080. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45081. }
  45082. }
  45083. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45084. import { Nullable, int } from "babylonjs/types";
  45085. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45086. /** @hidden */
  45087. export class _OcclusionDataStorage {
  45088. /** @hidden */
  45089. occlusionInternalRetryCounter: number;
  45090. /** @hidden */
  45091. isOcclusionQueryInProgress: boolean;
  45092. /** @hidden */
  45093. isOccluded: boolean;
  45094. /** @hidden */
  45095. occlusionRetryCount: number;
  45096. /** @hidden */
  45097. occlusionType: number;
  45098. /** @hidden */
  45099. occlusionQueryAlgorithmType: number;
  45100. }
  45101. module "babylonjs/Engines/engine" {
  45102. interface Engine {
  45103. /**
  45104. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45105. * @return the new query
  45106. */
  45107. createQuery(): WebGLQuery;
  45108. /**
  45109. * Delete and release a webGL query
  45110. * @param query defines the query to delete
  45111. * @return the current engine
  45112. */
  45113. deleteQuery(query: WebGLQuery): Engine;
  45114. /**
  45115. * Check if a given query has resolved and got its value
  45116. * @param query defines the query to check
  45117. * @returns true if the query got its value
  45118. */
  45119. isQueryResultAvailable(query: WebGLQuery): boolean;
  45120. /**
  45121. * Gets the value of a given query
  45122. * @param query defines the query to check
  45123. * @returns the value of the query
  45124. */
  45125. getQueryResult(query: WebGLQuery): number;
  45126. /**
  45127. * Initiates an occlusion query
  45128. * @param algorithmType defines the algorithm to use
  45129. * @param query defines the query to use
  45130. * @returns the current engine
  45131. * @see http://doc.babylonjs.com/features/occlusionquery
  45132. */
  45133. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45134. /**
  45135. * Ends an occlusion query
  45136. * @see http://doc.babylonjs.com/features/occlusionquery
  45137. * @param algorithmType defines the algorithm to use
  45138. * @returns the current engine
  45139. */
  45140. endOcclusionQuery(algorithmType: number): Engine;
  45141. /**
  45142. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45143. * Please note that only one query can be issued at a time
  45144. * @returns a time token used to track the time span
  45145. */
  45146. startTimeQuery(): Nullable<_TimeToken>;
  45147. /**
  45148. * Ends a time query
  45149. * @param token defines the token used to measure the time span
  45150. * @returns the time spent (in ns)
  45151. */
  45152. endTimeQuery(token: _TimeToken): int;
  45153. /** @hidden */
  45154. _currentNonTimestampToken: Nullable<_TimeToken>;
  45155. /** @hidden */
  45156. _createTimeQuery(): WebGLQuery;
  45157. /** @hidden */
  45158. _deleteTimeQuery(query: WebGLQuery): void;
  45159. /** @hidden */
  45160. _getGlAlgorithmType(algorithmType: number): number;
  45161. /** @hidden */
  45162. _getTimeQueryResult(query: WebGLQuery): any;
  45163. /** @hidden */
  45164. _getTimeQueryAvailability(query: WebGLQuery): any;
  45165. }
  45166. }
  45167. module "babylonjs/Meshes/abstractMesh" {
  45168. interface AbstractMesh {
  45169. /**
  45170. * Backing filed
  45171. * @hidden
  45172. */
  45173. __occlusionDataStorage: _OcclusionDataStorage;
  45174. /**
  45175. * Access property
  45176. * @hidden
  45177. */
  45178. _occlusionDataStorage: _OcclusionDataStorage;
  45179. /**
  45180. * 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.
  45181. * The default value is -1 which means don't break the query and wait till the result
  45182. * @see http://doc.babylonjs.com/features/occlusionquery
  45183. */
  45184. occlusionRetryCount: number;
  45185. /**
  45186. * 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:
  45187. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45188. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45189. * * 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.
  45190. * @see http://doc.babylonjs.com/features/occlusionquery
  45191. */
  45192. occlusionType: number;
  45193. /**
  45194. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45195. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45196. * * 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.
  45197. * @see http://doc.babylonjs.com/features/occlusionquery
  45198. */
  45199. occlusionQueryAlgorithmType: number;
  45200. /**
  45201. * 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
  45202. * @see http://doc.babylonjs.com/features/occlusionquery
  45203. */
  45204. isOccluded: boolean;
  45205. /**
  45206. * Flag to check the progress status of the query
  45207. * @see http://doc.babylonjs.com/features/occlusionquery
  45208. */
  45209. isOcclusionQueryInProgress: boolean;
  45210. }
  45211. }
  45212. }
  45213. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45214. import { Nullable } from "babylonjs/types";
  45215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45216. /** @hidden */
  45217. export var _forceTransformFeedbackToBundle: boolean;
  45218. module "babylonjs/Engines/engine" {
  45219. interface Engine {
  45220. /**
  45221. * Creates a webGL transform feedback object
  45222. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45223. * @returns the webGL transform feedback object
  45224. */
  45225. createTransformFeedback(): WebGLTransformFeedback;
  45226. /**
  45227. * Delete a webGL transform feedback object
  45228. * @param value defines the webGL transform feedback object to delete
  45229. */
  45230. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45231. /**
  45232. * Bind a webGL transform feedback object to the webgl context
  45233. * @param value defines the webGL transform feedback object to bind
  45234. */
  45235. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45236. /**
  45237. * Begins a transform feedback operation
  45238. * @param usePoints defines if points or triangles must be used
  45239. */
  45240. beginTransformFeedback(usePoints: boolean): void;
  45241. /**
  45242. * Ends a transform feedback operation
  45243. */
  45244. endTransformFeedback(): void;
  45245. /**
  45246. * Specify the varyings to use with transform feedback
  45247. * @param program defines the associated webGL program
  45248. * @param value defines the list of strings representing the varying names
  45249. */
  45250. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45251. /**
  45252. * Bind a webGL buffer for a transform feedback operation
  45253. * @param value defines the webGL buffer to bind
  45254. */
  45255. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45256. }
  45257. }
  45258. }
  45259. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45260. import { Scene } from "babylonjs/scene";
  45261. import { Engine } from "babylonjs/Engines/engine";
  45262. import { Texture } from "babylonjs/Materials/Textures/texture";
  45263. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45264. import "babylonjs/Engines/Extensions/engine.multiRender";
  45265. /**
  45266. * Creation options of the multi render target texture.
  45267. */
  45268. export interface IMultiRenderTargetOptions {
  45269. /**
  45270. * Define if the texture needs to create mip maps after render.
  45271. */
  45272. generateMipMaps?: boolean;
  45273. /**
  45274. * Define the types of all the draw buffers we want to create
  45275. */
  45276. types?: number[];
  45277. /**
  45278. * Define the sampling modes of all the draw buffers we want to create
  45279. */
  45280. samplingModes?: number[];
  45281. /**
  45282. * Define if a depth buffer is required
  45283. */
  45284. generateDepthBuffer?: boolean;
  45285. /**
  45286. * Define if a stencil buffer is required
  45287. */
  45288. generateStencilBuffer?: boolean;
  45289. /**
  45290. * Define if a depth texture is required instead of a depth buffer
  45291. */
  45292. generateDepthTexture?: boolean;
  45293. /**
  45294. * Define the number of desired draw buffers
  45295. */
  45296. textureCount?: number;
  45297. /**
  45298. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45299. */
  45300. doNotChangeAspectRatio?: boolean;
  45301. /**
  45302. * Define the default type of the buffers we are creating
  45303. */
  45304. defaultType?: number;
  45305. }
  45306. /**
  45307. * A multi render target, like a render target provides the ability to render to a texture.
  45308. * Unlike the render target, it can render to several draw buffers in one draw.
  45309. * This is specially interesting in deferred rendering or for any effects requiring more than
  45310. * just one color from a single pass.
  45311. */
  45312. export class MultiRenderTarget extends RenderTargetTexture {
  45313. private _internalTextures;
  45314. private _textures;
  45315. private _multiRenderTargetOptions;
  45316. /**
  45317. * Get if draw buffers are currently supported by the used hardware and browser.
  45318. */
  45319. readonly isSupported: boolean;
  45320. /**
  45321. * Get the list of textures generated by the multi render target.
  45322. */
  45323. readonly textures: Texture[];
  45324. /**
  45325. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45326. */
  45327. readonly depthTexture: Texture;
  45328. /**
  45329. * Set the wrapping mode on U of all the textures we are rendering to.
  45330. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45331. */
  45332. wrapU: number;
  45333. /**
  45334. * Set the wrapping mode on V of all the textures we are rendering to.
  45335. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45336. */
  45337. wrapV: number;
  45338. /**
  45339. * Instantiate a new multi render target texture.
  45340. * A multi render target, like a render target provides the ability to render to a texture.
  45341. * Unlike the render target, it can render to several draw buffers in one draw.
  45342. * This is specially interesting in deferred rendering or for any effects requiring more than
  45343. * just one color from a single pass.
  45344. * @param name Define the name of the texture
  45345. * @param size Define the size of the buffers to render to
  45346. * @param count Define the number of target we are rendering into
  45347. * @param scene Define the scene the texture belongs to
  45348. * @param options Define the options used to create the multi render target
  45349. */
  45350. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45351. /** @hidden */
  45352. _rebuild(): void;
  45353. private _createInternalTextures;
  45354. private _createTextures;
  45355. /**
  45356. * Define the number of samples used if MSAA is enabled.
  45357. */
  45358. samples: number;
  45359. /**
  45360. * Resize all the textures in the multi render target.
  45361. * Be carrefull as it will recreate all the data in the new texture.
  45362. * @param size Define the new size
  45363. */
  45364. resize(size: any): void;
  45365. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45366. /**
  45367. * Dispose the render targets and their associated resources
  45368. */
  45369. dispose(): void;
  45370. /**
  45371. * Release all the underlying texture used as draw buffers.
  45372. */
  45373. releaseInternalTextures(): void;
  45374. }
  45375. }
  45376. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45377. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45378. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45379. import { Nullable } from "babylonjs/types";
  45380. module "babylonjs/Engines/engine" {
  45381. interface Engine {
  45382. /**
  45383. * Unbind a list of render target textures from the webGL context
  45384. * This is used only when drawBuffer extension or webGL2 are active
  45385. * @param textures defines the render target textures to unbind
  45386. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45387. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45388. */
  45389. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45390. /**
  45391. * Create a multi render target texture
  45392. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45393. * @param size defines the size of the texture
  45394. * @param options defines the creation options
  45395. * @returns the cube texture as an InternalTexture
  45396. */
  45397. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45398. /**
  45399. * Update the sample count for a given multiple render target texture
  45400. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45401. * @param textures defines the textures to update
  45402. * @param samples defines the sample count to set
  45403. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45404. */
  45405. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45406. }
  45407. }
  45408. }
  45409. declare module "babylonjs/Engines/Extensions/index" {
  45410. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45411. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45412. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45413. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45414. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45415. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45416. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45417. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45418. }
  45419. declare module "babylonjs/Engines/index" {
  45420. export * from "babylonjs/Engines/constants";
  45421. export * from "babylonjs/Engines/engine";
  45422. export * from "babylonjs/Engines/engineStore";
  45423. export * from "babylonjs/Engines/nullEngine";
  45424. export * from "babylonjs/Engines/Extensions/index";
  45425. export * from "babylonjs/Engines/IPipelineContext";
  45426. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45427. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45428. }
  45429. declare module "babylonjs/Events/clipboardEvents" {
  45430. /**
  45431. * Gather the list of clipboard event types as constants.
  45432. */
  45433. export class ClipboardEventTypes {
  45434. /**
  45435. * The clipboard event is fired when a copy command is active (pressed).
  45436. */
  45437. static readonly COPY: number;
  45438. /**
  45439. * The clipboard event is fired when a cut command is active (pressed).
  45440. */
  45441. static readonly CUT: number;
  45442. /**
  45443. * The clipboard event is fired when a paste command is active (pressed).
  45444. */
  45445. static readonly PASTE: number;
  45446. }
  45447. /**
  45448. * This class is used to store clipboard related info for the onClipboardObservable event.
  45449. */
  45450. export class ClipboardInfo {
  45451. /**
  45452. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45453. */
  45454. type: number;
  45455. /**
  45456. * Defines the related dom event
  45457. */
  45458. event: ClipboardEvent;
  45459. /**
  45460. *Creates an instance of ClipboardInfo.
  45461. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45462. * @param event Defines the related dom event
  45463. */
  45464. constructor(
  45465. /**
  45466. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45467. */
  45468. type: number,
  45469. /**
  45470. * Defines the related dom event
  45471. */
  45472. event: ClipboardEvent);
  45473. /**
  45474. * Get the clipboard event's type from the keycode.
  45475. * @param keyCode Defines the keyCode for the current keyboard event.
  45476. * @return {number}
  45477. */
  45478. static GetTypeFromCharacter(keyCode: number): number;
  45479. }
  45480. }
  45481. declare module "babylonjs/Events/index" {
  45482. export * from "babylonjs/Events/keyboardEvents";
  45483. export * from "babylonjs/Events/pointerEvents";
  45484. export * from "babylonjs/Events/clipboardEvents";
  45485. }
  45486. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45487. import { Scene } from "babylonjs/scene";
  45488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45489. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45490. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45491. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45492. /**
  45493. * Google Daydream controller
  45494. */
  45495. export class DaydreamController extends WebVRController {
  45496. /**
  45497. * Base Url for the controller model.
  45498. */
  45499. static MODEL_BASE_URL: string;
  45500. /**
  45501. * File name for the controller model.
  45502. */
  45503. static MODEL_FILENAME: string;
  45504. /**
  45505. * Gamepad Id prefix used to identify Daydream Controller.
  45506. */
  45507. static readonly GAMEPAD_ID_PREFIX: string;
  45508. /**
  45509. * Creates a new DaydreamController from a gamepad
  45510. * @param vrGamepad the gamepad that the controller should be created from
  45511. */
  45512. constructor(vrGamepad: any);
  45513. /**
  45514. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45515. * @param scene scene in which to add meshes
  45516. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45517. */
  45518. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45519. /**
  45520. * Called once for each button that changed state since the last frame
  45521. * @param buttonIdx Which button index changed
  45522. * @param state New state of the button
  45523. * @param changes Which properties on the state changed since last frame
  45524. */
  45525. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45526. }
  45527. }
  45528. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45529. import { Scene } from "babylonjs/scene";
  45530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45531. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45532. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45533. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45534. /**
  45535. * Gear VR Controller
  45536. */
  45537. export class GearVRController extends WebVRController {
  45538. /**
  45539. * Base Url for the controller model.
  45540. */
  45541. static MODEL_BASE_URL: string;
  45542. /**
  45543. * File name for the controller model.
  45544. */
  45545. static MODEL_FILENAME: string;
  45546. /**
  45547. * Gamepad Id prefix used to identify this controller.
  45548. */
  45549. static readonly GAMEPAD_ID_PREFIX: string;
  45550. private readonly _buttonIndexToObservableNameMap;
  45551. /**
  45552. * Creates a new GearVRController from a gamepad
  45553. * @param vrGamepad the gamepad that the controller should be created from
  45554. */
  45555. constructor(vrGamepad: any);
  45556. /**
  45557. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45558. * @param scene scene in which to add meshes
  45559. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45560. */
  45561. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45562. /**
  45563. * Called once for each button that changed state since the last frame
  45564. * @param buttonIdx Which button index changed
  45565. * @param state New state of the button
  45566. * @param changes Which properties on the state changed since last frame
  45567. */
  45568. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45569. }
  45570. }
  45571. declare module "babylonjs/Gamepads/Controllers/index" {
  45572. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45573. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45574. export * from "babylonjs/Gamepads/Controllers/genericController";
  45575. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45576. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45577. export * from "babylonjs/Gamepads/Controllers/viveController";
  45578. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45579. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45580. }
  45581. declare module "babylonjs/Gamepads/index" {
  45582. export * from "babylonjs/Gamepads/Controllers/index";
  45583. export * from "babylonjs/Gamepads/gamepad";
  45584. export * from "babylonjs/Gamepads/gamepadManager";
  45585. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45586. export * from "babylonjs/Gamepads/xboxGamepad";
  45587. export * from "babylonjs/Gamepads/dualShockGamepad";
  45588. }
  45589. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45590. import { Scene } from "babylonjs/scene";
  45591. import { Vector4 } from "babylonjs/Maths/math.vector";
  45592. import { Color4 } from "babylonjs/Maths/math.color";
  45593. import { Mesh } from "babylonjs/Meshes/mesh";
  45594. import { Nullable } from "babylonjs/types";
  45595. /**
  45596. * Class containing static functions to help procedurally build meshes
  45597. */
  45598. export class PolyhedronBuilder {
  45599. /**
  45600. * Creates a polyhedron mesh
  45601. * * 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
  45602. * * The parameter `size` (positive float, default 1) sets the polygon size
  45603. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45604. * * 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`
  45605. * * 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
  45606. * * 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)`)
  45607. * * 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
  45608. * * 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
  45609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45612. * @param name defines the name of the mesh
  45613. * @param options defines the options used to create the mesh
  45614. * @param scene defines the hosting scene
  45615. * @returns the polyhedron mesh
  45616. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45617. */
  45618. static CreatePolyhedron(name: string, options: {
  45619. type?: number;
  45620. size?: number;
  45621. sizeX?: number;
  45622. sizeY?: number;
  45623. sizeZ?: number;
  45624. custom?: any;
  45625. faceUV?: Vector4[];
  45626. faceColors?: Color4[];
  45627. flat?: boolean;
  45628. updatable?: boolean;
  45629. sideOrientation?: number;
  45630. frontUVs?: Vector4;
  45631. backUVs?: Vector4;
  45632. }, scene?: Nullable<Scene>): Mesh;
  45633. }
  45634. }
  45635. declare module "babylonjs/Gizmos/scaleGizmo" {
  45636. import { Observable } from "babylonjs/Misc/observable";
  45637. import { Nullable } from "babylonjs/types";
  45638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45639. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45640. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45641. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45642. /**
  45643. * Gizmo that enables scaling a mesh along 3 axis
  45644. */
  45645. export class ScaleGizmo extends Gizmo {
  45646. /**
  45647. * Internal gizmo used for interactions on the x axis
  45648. */
  45649. xGizmo: AxisScaleGizmo;
  45650. /**
  45651. * Internal gizmo used for interactions on the y axis
  45652. */
  45653. yGizmo: AxisScaleGizmo;
  45654. /**
  45655. * Internal gizmo used for interactions on the z axis
  45656. */
  45657. zGizmo: AxisScaleGizmo;
  45658. /**
  45659. * Internal gizmo used to scale all axis equally
  45660. */
  45661. uniformScaleGizmo: AxisScaleGizmo;
  45662. private _meshAttached;
  45663. private _updateGizmoRotationToMatchAttachedMesh;
  45664. private _snapDistance;
  45665. private _scaleRatio;
  45666. private _uniformScalingMesh;
  45667. private _octahedron;
  45668. /** Fires an event when any of it's sub gizmos are dragged */
  45669. onDragStartObservable: Observable<unknown>;
  45670. /** Fires an event when any of it's sub gizmos are released from dragging */
  45671. onDragEndObservable: Observable<unknown>;
  45672. attachedMesh: Nullable<AbstractMesh>;
  45673. /**
  45674. * Creates a ScaleGizmo
  45675. * @param gizmoLayer The utility layer the gizmo will be added to
  45676. */
  45677. constructor(gizmoLayer?: UtilityLayerRenderer);
  45678. updateGizmoRotationToMatchAttachedMesh: boolean;
  45679. /**
  45680. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45681. */
  45682. snapDistance: number;
  45683. /**
  45684. * Ratio for the scale of the gizmo (Default: 1)
  45685. */
  45686. scaleRatio: number;
  45687. /**
  45688. * Disposes of the gizmo
  45689. */
  45690. dispose(): void;
  45691. }
  45692. }
  45693. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45694. import { Observable } from "babylonjs/Misc/observable";
  45695. import { Nullable } from "babylonjs/types";
  45696. import { Vector3 } from "babylonjs/Maths/math.vector";
  45697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45698. import { Mesh } from "babylonjs/Meshes/mesh";
  45699. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45700. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45701. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45702. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45703. import { Color3 } from "babylonjs/Maths/math.color";
  45704. /**
  45705. * Single axis scale gizmo
  45706. */
  45707. export class AxisScaleGizmo extends Gizmo {
  45708. /**
  45709. * Drag behavior responsible for the gizmos dragging interactions
  45710. */
  45711. dragBehavior: PointerDragBehavior;
  45712. private _pointerObserver;
  45713. /**
  45714. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45715. */
  45716. snapDistance: number;
  45717. /**
  45718. * Event that fires each time the gizmo snaps to a new location.
  45719. * * snapDistance is the the change in distance
  45720. */
  45721. onSnapObservable: Observable<{
  45722. snapDistance: number;
  45723. }>;
  45724. /**
  45725. * If the scaling operation should be done on all axis (default: false)
  45726. */
  45727. uniformScaling: boolean;
  45728. private _isEnabled;
  45729. private _parent;
  45730. private _arrow;
  45731. private _coloredMaterial;
  45732. private _hoverMaterial;
  45733. /**
  45734. * Creates an AxisScaleGizmo
  45735. * @param gizmoLayer The utility layer the gizmo will be added to
  45736. * @param dragAxis The axis which the gizmo will be able to scale on
  45737. * @param color The color of the gizmo
  45738. */
  45739. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45740. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45741. /**
  45742. * If the gizmo is enabled
  45743. */
  45744. isEnabled: boolean;
  45745. /**
  45746. * Disposes of the gizmo
  45747. */
  45748. dispose(): void;
  45749. /**
  45750. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45751. * @param mesh The mesh to replace the default mesh of the gizmo
  45752. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45753. */
  45754. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45755. }
  45756. }
  45757. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45758. import { Observable } from "babylonjs/Misc/observable";
  45759. import { Nullable } from "babylonjs/types";
  45760. import { Vector3 } from "babylonjs/Maths/math.vector";
  45761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45762. import { Mesh } from "babylonjs/Meshes/mesh";
  45763. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45764. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45765. import { Color3 } from "babylonjs/Maths/math.color";
  45766. import "babylonjs/Meshes/Builders/boxBuilder";
  45767. /**
  45768. * Bounding box gizmo
  45769. */
  45770. export class BoundingBoxGizmo extends Gizmo {
  45771. private _lineBoundingBox;
  45772. private _rotateSpheresParent;
  45773. private _scaleBoxesParent;
  45774. private _boundingDimensions;
  45775. private _renderObserver;
  45776. private _pointerObserver;
  45777. private _scaleDragSpeed;
  45778. private _tmpQuaternion;
  45779. private _tmpVector;
  45780. private _tmpRotationMatrix;
  45781. /**
  45782. * 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)
  45783. */
  45784. ignoreChildren: boolean;
  45785. /**
  45786. * 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)
  45787. */
  45788. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45789. /**
  45790. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45791. */
  45792. rotationSphereSize: number;
  45793. /**
  45794. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45795. */
  45796. scaleBoxSize: number;
  45797. /**
  45798. * 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)
  45799. */
  45800. fixedDragMeshScreenSize: boolean;
  45801. /**
  45802. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45803. */
  45804. fixedDragMeshScreenSizeDistanceFactor: number;
  45805. /**
  45806. * Fired when a rotation sphere or scale box is dragged
  45807. */
  45808. onDragStartObservable: Observable<{}>;
  45809. /**
  45810. * Fired when a scale box is dragged
  45811. */
  45812. onScaleBoxDragObservable: Observable<{}>;
  45813. /**
  45814. * Fired when a scale box drag is ended
  45815. */
  45816. onScaleBoxDragEndObservable: Observable<{}>;
  45817. /**
  45818. * Fired when a rotation sphere is dragged
  45819. */
  45820. onRotationSphereDragObservable: Observable<{}>;
  45821. /**
  45822. * Fired when a rotation sphere drag is ended
  45823. */
  45824. onRotationSphereDragEndObservable: Observable<{}>;
  45825. /**
  45826. * 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)
  45827. */
  45828. scalePivot: Nullable<Vector3>;
  45829. /**
  45830. * Mesh used as a pivot to rotate the attached mesh
  45831. */
  45832. private _anchorMesh;
  45833. private _existingMeshScale;
  45834. private _dragMesh;
  45835. private pointerDragBehavior;
  45836. private coloredMaterial;
  45837. private hoverColoredMaterial;
  45838. /**
  45839. * Sets the color of the bounding box gizmo
  45840. * @param color the color to set
  45841. */
  45842. setColor(color: Color3): void;
  45843. /**
  45844. * Creates an BoundingBoxGizmo
  45845. * @param gizmoLayer The utility layer the gizmo will be added to
  45846. * @param color The color of the gizmo
  45847. */
  45848. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45849. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45850. private _selectNode;
  45851. /**
  45852. * Updates the bounding box information for the Gizmo
  45853. */
  45854. updateBoundingBox(): void;
  45855. private _updateRotationSpheres;
  45856. private _updateScaleBoxes;
  45857. /**
  45858. * Enables rotation on the specified axis and disables rotation on the others
  45859. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45860. */
  45861. setEnabledRotationAxis(axis: string): void;
  45862. /**
  45863. * Enables/disables scaling
  45864. * @param enable if scaling should be enabled
  45865. */
  45866. setEnabledScaling(enable: boolean): void;
  45867. private _updateDummy;
  45868. /**
  45869. * Enables a pointer drag behavior on the bounding box of the gizmo
  45870. */
  45871. enableDragBehavior(): void;
  45872. /**
  45873. * Disposes of the gizmo
  45874. */
  45875. dispose(): void;
  45876. /**
  45877. * 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)
  45878. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45879. * @returns the bounding box mesh with the passed in mesh as a child
  45880. */
  45881. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45882. /**
  45883. * CustomMeshes are not supported by this gizmo
  45884. * @param mesh The mesh to replace the default mesh of the gizmo
  45885. */
  45886. setCustomMesh(mesh: Mesh): void;
  45887. }
  45888. }
  45889. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45890. import { Observable } from "babylonjs/Misc/observable";
  45891. import { Nullable } from "babylonjs/types";
  45892. import { Vector3 } from "babylonjs/Maths/math.vector";
  45893. import { Color3 } from "babylonjs/Maths/math.color";
  45894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45895. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45896. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45897. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45898. import "babylonjs/Meshes/Builders/linesBuilder";
  45899. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45900. /**
  45901. * Single plane rotation gizmo
  45902. */
  45903. export class PlaneRotationGizmo extends Gizmo {
  45904. /**
  45905. * Drag behavior responsible for the gizmos dragging interactions
  45906. */
  45907. dragBehavior: PointerDragBehavior;
  45908. private _pointerObserver;
  45909. /**
  45910. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45911. */
  45912. snapDistance: number;
  45913. /**
  45914. * Event that fires each time the gizmo snaps to a new location.
  45915. * * snapDistance is the the change in distance
  45916. */
  45917. onSnapObservable: Observable<{
  45918. snapDistance: number;
  45919. }>;
  45920. private _isEnabled;
  45921. private _parent;
  45922. /**
  45923. * Creates a PlaneRotationGizmo
  45924. * @param gizmoLayer The utility layer the gizmo will be added to
  45925. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45926. * @param color The color of the gizmo
  45927. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45928. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45929. */
  45930. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45931. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45932. /**
  45933. * If the gizmo is enabled
  45934. */
  45935. isEnabled: boolean;
  45936. /**
  45937. * Disposes of the gizmo
  45938. */
  45939. dispose(): void;
  45940. }
  45941. }
  45942. declare module "babylonjs/Gizmos/rotationGizmo" {
  45943. import { Observable } from "babylonjs/Misc/observable";
  45944. import { Nullable } from "babylonjs/types";
  45945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45946. import { Mesh } from "babylonjs/Meshes/mesh";
  45947. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45948. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45949. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45950. /**
  45951. * Gizmo that enables rotating a mesh along 3 axis
  45952. */
  45953. export class RotationGizmo extends Gizmo {
  45954. /**
  45955. * Internal gizmo used for interactions on the x axis
  45956. */
  45957. xGizmo: PlaneRotationGizmo;
  45958. /**
  45959. * Internal gizmo used for interactions on the y axis
  45960. */
  45961. yGizmo: PlaneRotationGizmo;
  45962. /**
  45963. * Internal gizmo used for interactions on the z axis
  45964. */
  45965. zGizmo: PlaneRotationGizmo;
  45966. /** Fires an event when any of it's sub gizmos are dragged */
  45967. onDragStartObservable: Observable<unknown>;
  45968. /** Fires an event when any of it's sub gizmos are released from dragging */
  45969. onDragEndObservable: Observable<unknown>;
  45970. private _meshAttached;
  45971. attachedMesh: Nullable<AbstractMesh>;
  45972. /**
  45973. * Creates a RotationGizmo
  45974. * @param gizmoLayer The utility layer the gizmo will be added to
  45975. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45976. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45977. */
  45978. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45979. updateGizmoRotationToMatchAttachedMesh: boolean;
  45980. /**
  45981. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45982. */
  45983. snapDistance: number;
  45984. /**
  45985. * Ratio for the scale of the gizmo (Default: 1)
  45986. */
  45987. scaleRatio: number;
  45988. /**
  45989. * Disposes of the gizmo
  45990. */
  45991. dispose(): void;
  45992. /**
  45993. * CustomMeshes are not supported by this gizmo
  45994. * @param mesh The mesh to replace the default mesh of the gizmo
  45995. */
  45996. setCustomMesh(mesh: Mesh): void;
  45997. }
  45998. }
  45999. declare module "babylonjs/Gizmos/gizmoManager" {
  46000. import { Observable } from "babylonjs/Misc/observable";
  46001. import { Nullable } from "babylonjs/types";
  46002. import { Scene, IDisposable } from "babylonjs/scene";
  46003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46004. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46005. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46006. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46007. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46008. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46009. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46010. /**
  46011. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46012. */
  46013. export class GizmoManager implements IDisposable {
  46014. private scene;
  46015. /**
  46016. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46017. */
  46018. gizmos: {
  46019. positionGizmo: Nullable<PositionGizmo>;
  46020. rotationGizmo: Nullable<RotationGizmo>;
  46021. scaleGizmo: Nullable<ScaleGizmo>;
  46022. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46023. };
  46024. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46025. clearGizmoOnEmptyPointerEvent: boolean;
  46026. /** Fires an event when the manager is attached to a mesh */
  46027. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46028. private _gizmosEnabled;
  46029. private _pointerObserver;
  46030. private _attachedMesh;
  46031. private _boundingBoxColor;
  46032. private _defaultUtilityLayer;
  46033. private _defaultKeepDepthUtilityLayer;
  46034. /**
  46035. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46036. */
  46037. boundingBoxDragBehavior: SixDofDragBehavior;
  46038. /**
  46039. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46040. */
  46041. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46042. /**
  46043. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46044. */
  46045. usePointerToAttachGizmos: boolean;
  46046. /**
  46047. * Utility layer that the bounding box gizmo belongs to
  46048. */
  46049. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46050. /**
  46051. * Utility layer that all gizmos besides bounding box belong to
  46052. */
  46053. readonly utilityLayer: UtilityLayerRenderer;
  46054. /**
  46055. * Instatiates a gizmo manager
  46056. * @param scene the scene to overlay the gizmos on top of
  46057. */
  46058. constructor(scene: Scene);
  46059. /**
  46060. * Attaches a set of gizmos to the specified mesh
  46061. * @param mesh The mesh the gizmo's should be attached to
  46062. */
  46063. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46064. /**
  46065. * If the position gizmo is enabled
  46066. */
  46067. positionGizmoEnabled: boolean;
  46068. /**
  46069. * If the rotation gizmo is enabled
  46070. */
  46071. rotationGizmoEnabled: boolean;
  46072. /**
  46073. * If the scale gizmo is enabled
  46074. */
  46075. scaleGizmoEnabled: boolean;
  46076. /**
  46077. * If the boundingBox gizmo is enabled
  46078. */
  46079. boundingBoxGizmoEnabled: boolean;
  46080. /**
  46081. * Disposes of the gizmo manager
  46082. */
  46083. dispose(): void;
  46084. }
  46085. }
  46086. declare module "babylonjs/Lights/directionalLight" {
  46087. import { Camera } from "babylonjs/Cameras/camera";
  46088. import { Scene } from "babylonjs/scene";
  46089. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46091. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46092. import { Effect } from "babylonjs/Materials/effect";
  46093. /**
  46094. * A directional light is defined by a direction (what a surprise!).
  46095. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46096. * 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.
  46097. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46098. */
  46099. export class DirectionalLight extends ShadowLight {
  46100. private _shadowFrustumSize;
  46101. /**
  46102. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46103. */
  46104. /**
  46105. * Specifies a fix frustum size for the shadow generation.
  46106. */
  46107. shadowFrustumSize: number;
  46108. private _shadowOrthoScale;
  46109. /**
  46110. * Gets the shadow projection scale against the optimal computed one.
  46111. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46112. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46113. */
  46114. /**
  46115. * Sets the shadow projection scale against the optimal computed one.
  46116. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46117. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46118. */
  46119. shadowOrthoScale: number;
  46120. /**
  46121. * Automatically compute the projection matrix to best fit (including all the casters)
  46122. * on each frame.
  46123. */
  46124. autoUpdateExtends: boolean;
  46125. private _orthoLeft;
  46126. private _orthoRight;
  46127. private _orthoTop;
  46128. private _orthoBottom;
  46129. /**
  46130. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46131. * The directional light is emitted from everywhere in the given direction.
  46132. * It can cast shadows.
  46133. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46134. * @param name The friendly name of the light
  46135. * @param direction The direction of the light
  46136. * @param scene The scene the light belongs to
  46137. */
  46138. constructor(name: string, direction: Vector3, scene: Scene);
  46139. /**
  46140. * Returns the string "DirectionalLight".
  46141. * @return The class name
  46142. */
  46143. getClassName(): string;
  46144. /**
  46145. * Returns the integer 1.
  46146. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46147. */
  46148. getTypeID(): number;
  46149. /**
  46150. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46151. * Returns the DirectionalLight Shadow projection matrix.
  46152. */
  46153. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46154. /**
  46155. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46156. * Returns the DirectionalLight Shadow projection matrix.
  46157. */
  46158. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46159. /**
  46160. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46161. * Returns the DirectionalLight Shadow projection matrix.
  46162. */
  46163. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46164. protected _buildUniformLayout(): void;
  46165. /**
  46166. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46167. * @param effect The effect to update
  46168. * @param lightIndex The index of the light in the effect to update
  46169. * @returns The directional light
  46170. */
  46171. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46172. /**
  46173. * Gets the minZ used for shadow according to both the scene and the light.
  46174. *
  46175. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46176. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46177. * @param activeCamera The camera we are returning the min for
  46178. * @returns the depth min z
  46179. */
  46180. getDepthMinZ(activeCamera: Camera): number;
  46181. /**
  46182. * Gets the maxZ used for shadow according to both the scene and the light.
  46183. *
  46184. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46185. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46186. * @param activeCamera The camera we are returning the max for
  46187. * @returns the depth max z
  46188. */
  46189. getDepthMaxZ(activeCamera: Camera): number;
  46190. /**
  46191. * Prepares the list of defines specific to the light type.
  46192. * @param defines the list of defines
  46193. * @param lightIndex defines the index of the light for the effect
  46194. */
  46195. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46196. }
  46197. }
  46198. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46199. import { Mesh } from "babylonjs/Meshes/mesh";
  46200. /**
  46201. * Class containing static functions to help procedurally build meshes
  46202. */
  46203. export class HemisphereBuilder {
  46204. /**
  46205. * Creates a hemisphere mesh
  46206. * @param name defines the name of the mesh
  46207. * @param options defines the options used to create the mesh
  46208. * @param scene defines the hosting scene
  46209. * @returns the hemisphere mesh
  46210. */
  46211. static CreateHemisphere(name: string, options: {
  46212. segments?: number;
  46213. diameter?: number;
  46214. sideOrientation?: number;
  46215. }, scene: any): Mesh;
  46216. }
  46217. }
  46218. declare module "babylonjs/Lights/spotLight" {
  46219. import { Nullable } from "babylonjs/types";
  46220. import { Scene } from "babylonjs/scene";
  46221. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46223. import { Effect } from "babylonjs/Materials/effect";
  46224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46225. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46226. /**
  46227. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46228. * These values define a cone of light starting from the position, emitting toward the direction.
  46229. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46230. * and the exponent defines the speed of the decay of the light with distance (reach).
  46231. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46232. */
  46233. export class SpotLight extends ShadowLight {
  46234. private _angle;
  46235. private _innerAngle;
  46236. private _cosHalfAngle;
  46237. private _lightAngleScale;
  46238. private _lightAngleOffset;
  46239. /**
  46240. * Gets the cone angle of the spot light in Radians.
  46241. */
  46242. /**
  46243. * Sets the cone angle of the spot light in Radians.
  46244. */
  46245. angle: number;
  46246. /**
  46247. * Only used in gltf falloff mode, this defines the angle where
  46248. * the directional falloff will start before cutting at angle which could be seen
  46249. * as outer angle.
  46250. */
  46251. /**
  46252. * Only used in gltf falloff mode, this defines the angle where
  46253. * the directional falloff will start before cutting at angle which could be seen
  46254. * as outer angle.
  46255. */
  46256. innerAngle: number;
  46257. private _shadowAngleScale;
  46258. /**
  46259. * Allows scaling the angle of the light for shadow generation only.
  46260. */
  46261. /**
  46262. * Allows scaling the angle of the light for shadow generation only.
  46263. */
  46264. shadowAngleScale: number;
  46265. /**
  46266. * The light decay speed with the distance from the emission spot.
  46267. */
  46268. exponent: number;
  46269. private _projectionTextureMatrix;
  46270. /**
  46271. * Allows reading the projecton texture
  46272. */
  46273. readonly projectionTextureMatrix: Matrix;
  46274. protected _projectionTextureLightNear: number;
  46275. /**
  46276. * Gets the near clip of the Spotlight for texture projection.
  46277. */
  46278. /**
  46279. * Sets the near clip of the Spotlight for texture projection.
  46280. */
  46281. projectionTextureLightNear: number;
  46282. protected _projectionTextureLightFar: number;
  46283. /**
  46284. * Gets the far clip of the Spotlight for texture projection.
  46285. */
  46286. /**
  46287. * Sets the far clip of the Spotlight for texture projection.
  46288. */
  46289. projectionTextureLightFar: number;
  46290. protected _projectionTextureUpDirection: Vector3;
  46291. /**
  46292. * Gets the Up vector of the Spotlight for texture projection.
  46293. */
  46294. /**
  46295. * Sets the Up vector of the Spotlight for texture projection.
  46296. */
  46297. projectionTextureUpDirection: Vector3;
  46298. private _projectionTexture;
  46299. /**
  46300. * Gets the projection texture of the light.
  46301. */
  46302. /**
  46303. * Sets the projection texture of the light.
  46304. */
  46305. projectionTexture: Nullable<BaseTexture>;
  46306. private _projectionTextureViewLightDirty;
  46307. private _projectionTextureProjectionLightDirty;
  46308. private _projectionTextureDirty;
  46309. private _projectionTextureViewTargetVector;
  46310. private _projectionTextureViewLightMatrix;
  46311. private _projectionTextureProjectionLightMatrix;
  46312. private _projectionTextureScalingMatrix;
  46313. /**
  46314. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46315. * It can cast shadows.
  46316. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46317. * @param name The light friendly name
  46318. * @param position The position of the spot light in the scene
  46319. * @param direction The direction of the light in the scene
  46320. * @param angle The cone angle of the light in Radians
  46321. * @param exponent The light decay speed with the distance from the emission spot
  46322. * @param scene The scene the lights belongs to
  46323. */
  46324. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46325. /**
  46326. * Returns the string "SpotLight".
  46327. * @returns the class name
  46328. */
  46329. getClassName(): string;
  46330. /**
  46331. * Returns the integer 2.
  46332. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46333. */
  46334. getTypeID(): number;
  46335. /**
  46336. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46337. */
  46338. protected _setDirection(value: Vector3): void;
  46339. /**
  46340. * Overrides the position setter to recompute the projection texture view light Matrix.
  46341. */
  46342. protected _setPosition(value: Vector3): void;
  46343. /**
  46344. * 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.
  46345. * Returns the SpotLight.
  46346. */
  46347. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46348. protected _computeProjectionTextureViewLightMatrix(): void;
  46349. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46350. /**
  46351. * Main function for light texture projection matrix computing.
  46352. */
  46353. protected _computeProjectionTextureMatrix(): void;
  46354. protected _buildUniformLayout(): void;
  46355. private _computeAngleValues;
  46356. /**
  46357. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46358. * @param effect The effect to update
  46359. * @param lightIndex The index of the light in the effect to update
  46360. * @returns The spot light
  46361. */
  46362. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46363. /**
  46364. * Disposes the light and the associated resources.
  46365. */
  46366. dispose(): void;
  46367. /**
  46368. * Prepares the list of defines specific to the light type.
  46369. * @param defines the list of defines
  46370. * @param lightIndex defines the index of the light for the effect
  46371. */
  46372. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46373. }
  46374. }
  46375. declare module "babylonjs/Gizmos/lightGizmo" {
  46376. import { Nullable } from "babylonjs/types";
  46377. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46378. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46379. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46380. import { Light } from "babylonjs/Lights/light";
  46381. /**
  46382. * Gizmo that enables viewing a light
  46383. */
  46384. export class LightGizmo extends Gizmo {
  46385. private _lightMesh;
  46386. private _material;
  46387. private cachedPosition;
  46388. private cachedForward;
  46389. /**
  46390. * Creates a LightGizmo
  46391. * @param gizmoLayer The utility layer the gizmo will be added to
  46392. */
  46393. constructor(gizmoLayer?: UtilityLayerRenderer);
  46394. private _light;
  46395. /**
  46396. * The light that the gizmo is attached to
  46397. */
  46398. light: Nullable<Light>;
  46399. /**
  46400. * Gets the material used to render the light gizmo
  46401. */
  46402. readonly material: StandardMaterial;
  46403. /**
  46404. * @hidden
  46405. * Updates the gizmo to match the attached mesh's position/rotation
  46406. */
  46407. protected _update(): void;
  46408. private static _Scale;
  46409. /**
  46410. * Creates the lines for a light mesh
  46411. */
  46412. private static _createLightLines;
  46413. /**
  46414. * Disposes of the light gizmo
  46415. */
  46416. dispose(): void;
  46417. private static _CreateHemisphericLightMesh;
  46418. private static _CreatePointLightMesh;
  46419. private static _CreateSpotLightMesh;
  46420. private static _CreateDirectionalLightMesh;
  46421. }
  46422. }
  46423. declare module "babylonjs/Gizmos/index" {
  46424. export * from "babylonjs/Gizmos/axisDragGizmo";
  46425. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46426. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46427. export * from "babylonjs/Gizmos/gizmo";
  46428. export * from "babylonjs/Gizmos/gizmoManager";
  46429. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46430. export * from "babylonjs/Gizmos/positionGizmo";
  46431. export * from "babylonjs/Gizmos/rotationGizmo";
  46432. export * from "babylonjs/Gizmos/scaleGizmo";
  46433. export * from "babylonjs/Gizmos/lightGizmo";
  46434. export * from "babylonjs/Gizmos/planeDragGizmo";
  46435. }
  46436. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46437. /** @hidden */
  46438. export var backgroundFragmentDeclaration: {
  46439. name: string;
  46440. shader: string;
  46441. };
  46442. }
  46443. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46444. /** @hidden */
  46445. export var backgroundUboDeclaration: {
  46446. name: string;
  46447. shader: string;
  46448. };
  46449. }
  46450. declare module "babylonjs/Shaders/background.fragment" {
  46451. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46452. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46453. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46454. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46455. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46456. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46457. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46458. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46459. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46460. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46461. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46462. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46463. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46464. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46465. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46466. /** @hidden */
  46467. export var backgroundPixelShader: {
  46468. name: string;
  46469. shader: string;
  46470. };
  46471. }
  46472. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46473. /** @hidden */
  46474. export var backgroundVertexDeclaration: {
  46475. name: string;
  46476. shader: string;
  46477. };
  46478. }
  46479. declare module "babylonjs/Shaders/background.vertex" {
  46480. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46481. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46482. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46483. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46484. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46485. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46486. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46487. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46488. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46489. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46490. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46491. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46492. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46493. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46494. /** @hidden */
  46495. export var backgroundVertexShader: {
  46496. name: string;
  46497. shader: string;
  46498. };
  46499. }
  46500. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46501. import { Nullable, int, float } from "babylonjs/types";
  46502. import { Scene } from "babylonjs/scene";
  46503. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46504. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46506. import { Mesh } from "babylonjs/Meshes/mesh";
  46507. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46508. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46509. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46510. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46511. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46512. import { Color3 } from "babylonjs/Maths/math.color";
  46513. import "babylonjs/Shaders/background.fragment";
  46514. import "babylonjs/Shaders/background.vertex";
  46515. /**
  46516. * Background material used to create an efficient environement around your scene.
  46517. */
  46518. export class BackgroundMaterial extends PushMaterial {
  46519. /**
  46520. * Standard reflectance value at parallel view angle.
  46521. */
  46522. static StandardReflectance0: number;
  46523. /**
  46524. * Standard reflectance value at grazing angle.
  46525. */
  46526. static StandardReflectance90: number;
  46527. protected _primaryColor: Color3;
  46528. /**
  46529. * Key light Color (multiply against the environement texture)
  46530. */
  46531. primaryColor: Color3;
  46532. protected __perceptualColor: Nullable<Color3>;
  46533. /**
  46534. * Experimental Internal Use Only.
  46535. *
  46536. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46537. * This acts as a helper to set the primary color to a more "human friendly" value.
  46538. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46539. * output color as close as possible from the chosen value.
  46540. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46541. * part of lighting setup.)
  46542. */
  46543. _perceptualColor: Nullable<Color3>;
  46544. protected _primaryColorShadowLevel: float;
  46545. /**
  46546. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46547. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46548. */
  46549. primaryColorShadowLevel: float;
  46550. protected _primaryColorHighlightLevel: float;
  46551. /**
  46552. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46553. * The primary color is used at the level chosen to define what the white area would look.
  46554. */
  46555. primaryColorHighlightLevel: float;
  46556. protected _reflectionTexture: Nullable<BaseTexture>;
  46557. /**
  46558. * Reflection Texture used in the material.
  46559. * Should be author in a specific way for the best result (refer to the documentation).
  46560. */
  46561. reflectionTexture: Nullable<BaseTexture>;
  46562. protected _reflectionBlur: float;
  46563. /**
  46564. * Reflection Texture level of blur.
  46565. *
  46566. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46567. * texture twice.
  46568. */
  46569. reflectionBlur: float;
  46570. protected _diffuseTexture: Nullable<BaseTexture>;
  46571. /**
  46572. * Diffuse Texture used in the material.
  46573. * Should be author in a specific way for the best result (refer to the documentation).
  46574. */
  46575. diffuseTexture: Nullable<BaseTexture>;
  46576. protected _shadowLights: Nullable<IShadowLight[]>;
  46577. /**
  46578. * Specify the list of lights casting shadow on the material.
  46579. * All scene shadow lights will be included if null.
  46580. */
  46581. shadowLights: Nullable<IShadowLight[]>;
  46582. protected _shadowLevel: float;
  46583. /**
  46584. * Helps adjusting the shadow to a softer level if required.
  46585. * 0 means black shadows and 1 means no shadows.
  46586. */
  46587. shadowLevel: float;
  46588. protected _sceneCenter: Vector3;
  46589. /**
  46590. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46591. * It is usually zero but might be interesting to modify according to your setup.
  46592. */
  46593. sceneCenter: Vector3;
  46594. protected _opacityFresnel: boolean;
  46595. /**
  46596. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46597. * This helps ensuring a nice transition when the camera goes under the ground.
  46598. */
  46599. opacityFresnel: boolean;
  46600. protected _reflectionFresnel: boolean;
  46601. /**
  46602. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46603. * This helps adding a mirror texture on the ground.
  46604. */
  46605. reflectionFresnel: boolean;
  46606. protected _reflectionFalloffDistance: number;
  46607. /**
  46608. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46609. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46610. */
  46611. reflectionFalloffDistance: number;
  46612. protected _reflectionAmount: number;
  46613. /**
  46614. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46615. */
  46616. reflectionAmount: number;
  46617. protected _reflectionReflectance0: number;
  46618. /**
  46619. * This specifies the weight of the reflection at grazing angle.
  46620. */
  46621. reflectionReflectance0: number;
  46622. protected _reflectionReflectance90: number;
  46623. /**
  46624. * This specifies the weight of the reflection at a perpendicular point of view.
  46625. */
  46626. reflectionReflectance90: number;
  46627. /**
  46628. * Sets the reflection reflectance fresnel values according to the default standard
  46629. * empirically know to work well :-)
  46630. */
  46631. reflectionStandardFresnelWeight: number;
  46632. protected _useRGBColor: boolean;
  46633. /**
  46634. * Helps to directly use the maps channels instead of their level.
  46635. */
  46636. useRGBColor: boolean;
  46637. protected _enableNoise: boolean;
  46638. /**
  46639. * This helps reducing the banding effect that could occur on the background.
  46640. */
  46641. enableNoise: boolean;
  46642. /**
  46643. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46644. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46645. * Recommended to be keep at 1.0 except for special cases.
  46646. */
  46647. fovMultiplier: number;
  46648. private _fovMultiplier;
  46649. /**
  46650. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46651. */
  46652. useEquirectangularFOV: boolean;
  46653. private _maxSimultaneousLights;
  46654. /**
  46655. * Number of Simultaneous lights allowed on the material.
  46656. */
  46657. maxSimultaneousLights: int;
  46658. /**
  46659. * Default configuration related to image processing available in the Background Material.
  46660. */
  46661. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46662. /**
  46663. * Keep track of the image processing observer to allow dispose and replace.
  46664. */
  46665. private _imageProcessingObserver;
  46666. /**
  46667. * Attaches a new image processing configuration to the PBR Material.
  46668. * @param configuration (if null the scene configuration will be use)
  46669. */
  46670. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46671. /**
  46672. * Gets the image processing configuration used either in this material.
  46673. */
  46674. /**
  46675. * Sets the Default image processing configuration used either in the this material.
  46676. *
  46677. * If sets to null, the scene one is in use.
  46678. */
  46679. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46680. /**
  46681. * Gets wether the color curves effect is enabled.
  46682. */
  46683. /**
  46684. * Sets wether the color curves effect is enabled.
  46685. */
  46686. cameraColorCurvesEnabled: boolean;
  46687. /**
  46688. * Gets wether the color grading effect is enabled.
  46689. */
  46690. /**
  46691. * Gets wether the color grading effect is enabled.
  46692. */
  46693. cameraColorGradingEnabled: boolean;
  46694. /**
  46695. * Gets wether tonemapping is enabled or not.
  46696. */
  46697. /**
  46698. * Sets wether tonemapping is enabled or not
  46699. */
  46700. cameraToneMappingEnabled: boolean;
  46701. /**
  46702. * The camera exposure used on this material.
  46703. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46704. * This corresponds to a photographic exposure.
  46705. */
  46706. /**
  46707. * The camera exposure used on this material.
  46708. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46709. * This corresponds to a photographic exposure.
  46710. */
  46711. cameraExposure: float;
  46712. /**
  46713. * Gets The camera contrast used on this material.
  46714. */
  46715. /**
  46716. * Sets The camera contrast used on this material.
  46717. */
  46718. cameraContrast: float;
  46719. /**
  46720. * Gets the Color Grading 2D Lookup Texture.
  46721. */
  46722. /**
  46723. * Sets the Color Grading 2D Lookup Texture.
  46724. */
  46725. cameraColorGradingTexture: Nullable<BaseTexture>;
  46726. /**
  46727. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46728. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46729. * 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;
  46730. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46731. */
  46732. /**
  46733. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46734. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46735. * 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;
  46736. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46737. */
  46738. cameraColorCurves: Nullable<ColorCurves>;
  46739. /**
  46740. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46741. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46742. */
  46743. switchToBGR: boolean;
  46744. private _renderTargets;
  46745. private _reflectionControls;
  46746. private _white;
  46747. private _primaryShadowColor;
  46748. private _primaryHighlightColor;
  46749. /**
  46750. * Instantiates a Background Material in the given scene
  46751. * @param name The friendly name of the material
  46752. * @param scene The scene to add the material to
  46753. */
  46754. constructor(name: string, scene: Scene);
  46755. /**
  46756. * Gets a boolean indicating that current material needs to register RTT
  46757. */
  46758. readonly hasRenderTargetTextures: boolean;
  46759. /**
  46760. * The entire material has been created in order to prevent overdraw.
  46761. * @returns false
  46762. */
  46763. needAlphaTesting(): boolean;
  46764. /**
  46765. * The entire material has been created in order to prevent overdraw.
  46766. * @returns true if blending is enable
  46767. */
  46768. needAlphaBlending(): boolean;
  46769. /**
  46770. * Checks wether the material is ready to be rendered for a given mesh.
  46771. * @param mesh The mesh to render
  46772. * @param subMesh The submesh to check against
  46773. * @param useInstances Specify wether or not the material is used with instances
  46774. * @returns true if all the dependencies are ready (Textures, Effects...)
  46775. */
  46776. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46777. /**
  46778. * Compute the primary color according to the chosen perceptual color.
  46779. */
  46780. private _computePrimaryColorFromPerceptualColor;
  46781. /**
  46782. * Compute the highlights and shadow colors according to their chosen levels.
  46783. */
  46784. private _computePrimaryColors;
  46785. /**
  46786. * Build the uniform buffer used in the material.
  46787. */
  46788. buildUniformLayout(): void;
  46789. /**
  46790. * Unbind the material.
  46791. */
  46792. unbind(): void;
  46793. /**
  46794. * Bind only the world matrix to the material.
  46795. * @param world The world matrix to bind.
  46796. */
  46797. bindOnlyWorldMatrix(world: Matrix): void;
  46798. /**
  46799. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46800. * @param world The world matrix to bind.
  46801. * @param subMesh The submesh to bind for.
  46802. */
  46803. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46804. /**
  46805. * Dispose the material.
  46806. * @param forceDisposeEffect Force disposal of the associated effect.
  46807. * @param forceDisposeTextures Force disposal of the associated textures.
  46808. */
  46809. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46810. /**
  46811. * Clones the material.
  46812. * @param name The cloned name.
  46813. * @returns The cloned material.
  46814. */
  46815. clone(name: string): BackgroundMaterial;
  46816. /**
  46817. * Serializes the current material to its JSON representation.
  46818. * @returns The JSON representation.
  46819. */
  46820. serialize(): any;
  46821. /**
  46822. * Gets the class name of the material
  46823. * @returns "BackgroundMaterial"
  46824. */
  46825. getClassName(): string;
  46826. /**
  46827. * Parse a JSON input to create back a background material.
  46828. * @param source The JSON data to parse
  46829. * @param scene The scene to create the parsed material in
  46830. * @param rootUrl The root url of the assets the material depends upon
  46831. * @returns the instantiated BackgroundMaterial.
  46832. */
  46833. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46834. }
  46835. }
  46836. declare module "babylonjs/Helpers/environmentHelper" {
  46837. import { Observable } from "babylonjs/Misc/observable";
  46838. import { Nullable } from "babylonjs/types";
  46839. import { Scene } from "babylonjs/scene";
  46840. import { Vector3 } from "babylonjs/Maths/math.vector";
  46841. import { Color3 } from "babylonjs/Maths/math.color";
  46842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46843. import { Mesh } from "babylonjs/Meshes/mesh";
  46844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46845. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46846. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46847. import "babylonjs/Meshes/Builders/planeBuilder";
  46848. import "babylonjs/Meshes/Builders/boxBuilder";
  46849. /**
  46850. * Represents the different options available during the creation of
  46851. * a Environment helper.
  46852. *
  46853. * This can control the default ground, skybox and image processing setup of your scene.
  46854. */
  46855. export interface IEnvironmentHelperOptions {
  46856. /**
  46857. * Specifies wether or not to create a ground.
  46858. * True by default.
  46859. */
  46860. createGround: boolean;
  46861. /**
  46862. * Specifies the ground size.
  46863. * 15 by default.
  46864. */
  46865. groundSize: number;
  46866. /**
  46867. * The texture used on the ground for the main color.
  46868. * Comes from the BabylonJS CDN by default.
  46869. *
  46870. * Remarks: Can be either a texture or a url.
  46871. */
  46872. groundTexture: string | BaseTexture;
  46873. /**
  46874. * The color mixed in the ground texture by default.
  46875. * BabylonJS clearColor by default.
  46876. */
  46877. groundColor: Color3;
  46878. /**
  46879. * Specifies the ground opacity.
  46880. * 1 by default.
  46881. */
  46882. groundOpacity: number;
  46883. /**
  46884. * Enables the ground to receive shadows.
  46885. * True by default.
  46886. */
  46887. enableGroundShadow: boolean;
  46888. /**
  46889. * Helps preventing the shadow to be fully black on the ground.
  46890. * 0.5 by default.
  46891. */
  46892. groundShadowLevel: number;
  46893. /**
  46894. * Creates a mirror texture attach to the ground.
  46895. * false by default.
  46896. */
  46897. enableGroundMirror: boolean;
  46898. /**
  46899. * Specifies the ground mirror size ratio.
  46900. * 0.3 by default as the default kernel is 64.
  46901. */
  46902. groundMirrorSizeRatio: number;
  46903. /**
  46904. * Specifies the ground mirror blur kernel size.
  46905. * 64 by default.
  46906. */
  46907. groundMirrorBlurKernel: number;
  46908. /**
  46909. * Specifies the ground mirror visibility amount.
  46910. * 1 by default
  46911. */
  46912. groundMirrorAmount: number;
  46913. /**
  46914. * Specifies the ground mirror reflectance weight.
  46915. * This uses the standard weight of the background material to setup the fresnel effect
  46916. * of the mirror.
  46917. * 1 by default.
  46918. */
  46919. groundMirrorFresnelWeight: number;
  46920. /**
  46921. * Specifies the ground mirror Falloff distance.
  46922. * This can helps reducing the size of the reflection.
  46923. * 0 by Default.
  46924. */
  46925. groundMirrorFallOffDistance: number;
  46926. /**
  46927. * Specifies the ground mirror texture type.
  46928. * Unsigned Int by Default.
  46929. */
  46930. groundMirrorTextureType: number;
  46931. /**
  46932. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46933. * the shown objects.
  46934. */
  46935. groundYBias: number;
  46936. /**
  46937. * Specifies wether or not to create a skybox.
  46938. * True by default.
  46939. */
  46940. createSkybox: boolean;
  46941. /**
  46942. * Specifies the skybox size.
  46943. * 20 by default.
  46944. */
  46945. skyboxSize: number;
  46946. /**
  46947. * The texture used on the skybox for the main color.
  46948. * Comes from the BabylonJS CDN by default.
  46949. *
  46950. * Remarks: Can be either a texture or a url.
  46951. */
  46952. skyboxTexture: string | BaseTexture;
  46953. /**
  46954. * The color mixed in the skybox texture by default.
  46955. * BabylonJS clearColor by default.
  46956. */
  46957. skyboxColor: Color3;
  46958. /**
  46959. * The background rotation around the Y axis of the scene.
  46960. * This helps aligning the key lights of your scene with the background.
  46961. * 0 by default.
  46962. */
  46963. backgroundYRotation: number;
  46964. /**
  46965. * Compute automatically the size of the elements to best fit with the scene.
  46966. */
  46967. sizeAuto: boolean;
  46968. /**
  46969. * Default position of the rootMesh if autoSize is not true.
  46970. */
  46971. rootPosition: Vector3;
  46972. /**
  46973. * Sets up the image processing in the scene.
  46974. * true by default.
  46975. */
  46976. setupImageProcessing: boolean;
  46977. /**
  46978. * The texture used as your environment texture in the scene.
  46979. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46980. *
  46981. * Remarks: Can be either a texture or a url.
  46982. */
  46983. environmentTexture: string | BaseTexture;
  46984. /**
  46985. * The value of the exposure to apply to the scene.
  46986. * 0.6 by default if setupImageProcessing is true.
  46987. */
  46988. cameraExposure: number;
  46989. /**
  46990. * The value of the contrast to apply to the scene.
  46991. * 1.6 by default if setupImageProcessing is true.
  46992. */
  46993. cameraContrast: number;
  46994. /**
  46995. * Specifies wether or not tonemapping should be enabled in the scene.
  46996. * true by default if setupImageProcessing is true.
  46997. */
  46998. toneMappingEnabled: boolean;
  46999. }
  47000. /**
  47001. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47002. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47003. * It also helps with the default setup of your imageProcessing configuration.
  47004. */
  47005. export class EnvironmentHelper {
  47006. /**
  47007. * Default ground texture URL.
  47008. */
  47009. private static _groundTextureCDNUrl;
  47010. /**
  47011. * Default skybox texture URL.
  47012. */
  47013. private static _skyboxTextureCDNUrl;
  47014. /**
  47015. * Default environment texture URL.
  47016. */
  47017. private static _environmentTextureCDNUrl;
  47018. /**
  47019. * Creates the default options for the helper.
  47020. */
  47021. private static _getDefaultOptions;
  47022. private _rootMesh;
  47023. /**
  47024. * Gets the root mesh created by the helper.
  47025. */
  47026. readonly rootMesh: Mesh;
  47027. private _skybox;
  47028. /**
  47029. * Gets the skybox created by the helper.
  47030. */
  47031. readonly skybox: Nullable<Mesh>;
  47032. private _skyboxTexture;
  47033. /**
  47034. * Gets the skybox texture created by the helper.
  47035. */
  47036. readonly skyboxTexture: Nullable<BaseTexture>;
  47037. private _skyboxMaterial;
  47038. /**
  47039. * Gets the skybox material created by the helper.
  47040. */
  47041. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47042. private _ground;
  47043. /**
  47044. * Gets the ground mesh created by the helper.
  47045. */
  47046. readonly ground: Nullable<Mesh>;
  47047. private _groundTexture;
  47048. /**
  47049. * Gets the ground texture created by the helper.
  47050. */
  47051. readonly groundTexture: Nullable<BaseTexture>;
  47052. private _groundMirror;
  47053. /**
  47054. * Gets the ground mirror created by the helper.
  47055. */
  47056. readonly groundMirror: Nullable<MirrorTexture>;
  47057. /**
  47058. * Gets the ground mirror render list to helps pushing the meshes
  47059. * you wish in the ground reflection.
  47060. */
  47061. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47062. private _groundMaterial;
  47063. /**
  47064. * Gets the ground material created by the helper.
  47065. */
  47066. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47067. /**
  47068. * Stores the creation options.
  47069. */
  47070. private readonly _scene;
  47071. private _options;
  47072. /**
  47073. * This observable will be notified with any error during the creation of the environment,
  47074. * mainly texture creation errors.
  47075. */
  47076. onErrorObservable: Observable<{
  47077. message?: string;
  47078. exception?: any;
  47079. }>;
  47080. /**
  47081. * constructor
  47082. * @param options Defines the options we want to customize the helper
  47083. * @param scene The scene to add the material to
  47084. */
  47085. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47086. /**
  47087. * Updates the background according to the new options
  47088. * @param options
  47089. */
  47090. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47091. /**
  47092. * Sets the primary color of all the available elements.
  47093. * @param color the main color to affect to the ground and the background
  47094. */
  47095. setMainColor(color: Color3): void;
  47096. /**
  47097. * Setup the image processing according to the specified options.
  47098. */
  47099. private _setupImageProcessing;
  47100. /**
  47101. * Setup the environment texture according to the specified options.
  47102. */
  47103. private _setupEnvironmentTexture;
  47104. /**
  47105. * Setup the background according to the specified options.
  47106. */
  47107. private _setupBackground;
  47108. /**
  47109. * Get the scene sizes according to the setup.
  47110. */
  47111. private _getSceneSize;
  47112. /**
  47113. * Setup the ground according to the specified options.
  47114. */
  47115. private _setupGround;
  47116. /**
  47117. * Setup the ground material according to the specified options.
  47118. */
  47119. private _setupGroundMaterial;
  47120. /**
  47121. * Setup the ground diffuse texture according to the specified options.
  47122. */
  47123. private _setupGroundDiffuseTexture;
  47124. /**
  47125. * Setup the ground mirror texture according to the specified options.
  47126. */
  47127. private _setupGroundMirrorTexture;
  47128. /**
  47129. * Setup the ground to receive the mirror texture.
  47130. */
  47131. private _setupMirrorInGroundMaterial;
  47132. /**
  47133. * Setup the skybox according to the specified options.
  47134. */
  47135. private _setupSkybox;
  47136. /**
  47137. * Setup the skybox material according to the specified options.
  47138. */
  47139. private _setupSkyboxMaterial;
  47140. /**
  47141. * Setup the skybox reflection texture according to the specified options.
  47142. */
  47143. private _setupSkyboxReflectionTexture;
  47144. private _errorHandler;
  47145. /**
  47146. * Dispose all the elements created by the Helper.
  47147. */
  47148. dispose(): void;
  47149. }
  47150. }
  47151. declare module "babylonjs/Helpers/photoDome" {
  47152. import { Observable } from "babylonjs/Misc/observable";
  47153. import { Nullable } from "babylonjs/types";
  47154. import { Scene } from "babylonjs/scene";
  47155. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47156. import { Mesh } from "babylonjs/Meshes/mesh";
  47157. import { Texture } from "babylonjs/Materials/Textures/texture";
  47158. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47159. import "babylonjs/Meshes/Builders/sphereBuilder";
  47160. /**
  47161. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47162. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47163. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47164. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47165. */
  47166. export class PhotoDome extends TransformNode {
  47167. /**
  47168. * Define the image as a Monoscopic panoramic 360 image.
  47169. */
  47170. static readonly MODE_MONOSCOPIC: number;
  47171. /**
  47172. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47173. */
  47174. static readonly MODE_TOPBOTTOM: number;
  47175. /**
  47176. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47177. */
  47178. static readonly MODE_SIDEBYSIDE: number;
  47179. private _useDirectMapping;
  47180. /**
  47181. * The texture being displayed on the sphere
  47182. */
  47183. protected _photoTexture: Texture;
  47184. /**
  47185. * Gets or sets the texture being displayed on the sphere
  47186. */
  47187. photoTexture: Texture;
  47188. /**
  47189. * Observable raised when an error occured while loading the 360 image
  47190. */
  47191. onLoadErrorObservable: Observable<string>;
  47192. /**
  47193. * The skybox material
  47194. */
  47195. protected _material: BackgroundMaterial;
  47196. /**
  47197. * The surface used for the skybox
  47198. */
  47199. protected _mesh: Mesh;
  47200. /**
  47201. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47202. * Also see the options.resolution property.
  47203. */
  47204. fovMultiplier: number;
  47205. private _imageMode;
  47206. /**
  47207. * Gets or set the current video mode for the video. It can be:
  47208. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47209. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47210. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47211. */
  47212. imageMode: number;
  47213. /**
  47214. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47215. * @param name Element's name, child elements will append suffixes for their own names.
  47216. * @param urlsOfPhoto defines the url of the photo to display
  47217. * @param options defines an object containing optional or exposed sub element properties
  47218. * @param onError defines a callback called when an error occured while loading the texture
  47219. */
  47220. constructor(name: string, urlOfPhoto: string, options: {
  47221. resolution?: number;
  47222. size?: number;
  47223. useDirectMapping?: boolean;
  47224. faceForward?: boolean;
  47225. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47226. private _onBeforeCameraRenderObserver;
  47227. private _changeImageMode;
  47228. /**
  47229. * Releases resources associated with this node.
  47230. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47231. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47232. */
  47233. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47234. }
  47235. }
  47236. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47237. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47238. /** @hidden */
  47239. export var rgbdDecodePixelShader: {
  47240. name: string;
  47241. shader: string;
  47242. };
  47243. }
  47244. declare module "babylonjs/Misc/brdfTextureTools" {
  47245. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47246. import { Scene } from "babylonjs/scene";
  47247. import "babylonjs/Shaders/rgbdDecode.fragment";
  47248. /**
  47249. * Class used to host texture specific utilities
  47250. */
  47251. export class BRDFTextureTools {
  47252. /**
  47253. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47254. * @param texture the texture to expand.
  47255. */
  47256. private static _ExpandDefaultBRDFTexture;
  47257. /**
  47258. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47259. * @param scene defines the hosting scene
  47260. * @returns the environment BRDF texture
  47261. */
  47262. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47263. private static _environmentBRDFBase64Texture;
  47264. }
  47265. }
  47266. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47267. import { Nullable } from "babylonjs/types";
  47268. import { Color3 } from "babylonjs/Maths/math.color";
  47269. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47270. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47271. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47272. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47273. import { Engine } from "babylonjs/Engines/engine";
  47274. import { Scene } from "babylonjs/scene";
  47275. /**
  47276. * @hidden
  47277. */
  47278. export interface IMaterialClearCoatDefines {
  47279. CLEARCOAT: boolean;
  47280. CLEARCOAT_DEFAULTIOR: boolean;
  47281. CLEARCOAT_TEXTURE: boolean;
  47282. CLEARCOAT_TEXTUREDIRECTUV: number;
  47283. CLEARCOAT_BUMP: boolean;
  47284. CLEARCOAT_BUMPDIRECTUV: number;
  47285. CLEARCOAT_TINT: boolean;
  47286. CLEARCOAT_TINT_TEXTURE: boolean;
  47287. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47288. /** @hidden */
  47289. _areTexturesDirty: boolean;
  47290. }
  47291. /**
  47292. * Define the code related to the clear coat parameters of the pbr material.
  47293. */
  47294. export class PBRClearCoatConfiguration {
  47295. /**
  47296. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47297. * The default fits with a polyurethane material.
  47298. */
  47299. private static readonly _DefaultIndexOfRefraction;
  47300. private _isEnabled;
  47301. /**
  47302. * Defines if the clear coat is enabled in the material.
  47303. */
  47304. isEnabled: boolean;
  47305. /**
  47306. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47307. */
  47308. intensity: number;
  47309. /**
  47310. * Defines the clear coat layer roughness.
  47311. */
  47312. roughness: number;
  47313. private _indexOfRefraction;
  47314. /**
  47315. * Defines the index of refraction of the clear coat.
  47316. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47317. * The default fits with a polyurethane material.
  47318. * Changing the default value is more performance intensive.
  47319. */
  47320. indexOfRefraction: number;
  47321. private _texture;
  47322. /**
  47323. * Stores the clear coat values in a texture.
  47324. */
  47325. texture: Nullable<BaseTexture>;
  47326. private _bumpTexture;
  47327. /**
  47328. * Define the clear coat specific bump texture.
  47329. */
  47330. bumpTexture: Nullable<BaseTexture>;
  47331. private _isTintEnabled;
  47332. /**
  47333. * Defines if the clear coat tint is enabled in the material.
  47334. */
  47335. isTintEnabled: boolean;
  47336. /**
  47337. * Defines the clear coat tint of the material.
  47338. * This is only use if tint is enabled
  47339. */
  47340. tintColor: Color3;
  47341. /**
  47342. * Defines the distance at which the tint color should be found in the
  47343. * clear coat media.
  47344. * This is only use if tint is enabled
  47345. */
  47346. tintColorAtDistance: number;
  47347. /**
  47348. * Defines the clear coat layer thickness.
  47349. * This is only use if tint is enabled
  47350. */
  47351. tintThickness: number;
  47352. private _tintTexture;
  47353. /**
  47354. * Stores the clear tint values in a texture.
  47355. * rgb is tint
  47356. * a is a thickness factor
  47357. */
  47358. tintTexture: Nullable<BaseTexture>;
  47359. /** @hidden */
  47360. private _internalMarkAllSubMeshesAsTexturesDirty;
  47361. /** @hidden */
  47362. _markAllSubMeshesAsTexturesDirty(): void;
  47363. /**
  47364. * Instantiate a new istance of clear coat configuration.
  47365. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47366. */
  47367. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47368. /**
  47369. * Gets wehter the submesh is ready to be used or not.
  47370. * @param defines the list of "defines" to update.
  47371. * @param scene defines the scene the material belongs to.
  47372. * @param engine defines the engine the material belongs to.
  47373. * @param disableBumpMap defines wether the material disables bump or not.
  47374. * @returns - boolean indicating that the submesh is ready or not.
  47375. */
  47376. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47377. /**
  47378. * Checks to see if a texture is used in the material.
  47379. * @param defines the list of "defines" to update.
  47380. * @param scene defines the scene to the material belongs to.
  47381. */
  47382. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47383. /**
  47384. * Binds the material data.
  47385. * @param uniformBuffer defines the Uniform buffer to fill in.
  47386. * @param scene defines the scene the material belongs to.
  47387. * @param engine defines the engine the material belongs to.
  47388. * @param disableBumpMap defines wether the material disables bump or not.
  47389. * @param isFrozen defines wether the material is frozen or not.
  47390. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47391. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47392. */
  47393. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47394. /**
  47395. * Checks to see if a texture is used in the material.
  47396. * @param texture - Base texture to use.
  47397. * @returns - Boolean specifying if a texture is used in the material.
  47398. */
  47399. hasTexture(texture: BaseTexture): boolean;
  47400. /**
  47401. * Returns an array of the actively used textures.
  47402. * @param activeTextures Array of BaseTextures
  47403. */
  47404. getActiveTextures(activeTextures: BaseTexture[]): void;
  47405. /**
  47406. * Returns the animatable textures.
  47407. * @param animatables Array of animatable textures.
  47408. */
  47409. getAnimatables(animatables: IAnimatable[]): void;
  47410. /**
  47411. * Disposes the resources of the material.
  47412. * @param forceDisposeTextures - Forces the disposal of all textures.
  47413. */
  47414. dispose(forceDisposeTextures?: boolean): void;
  47415. /**
  47416. * Get the current class name of the texture useful for serialization or dynamic coding.
  47417. * @returns "PBRClearCoatConfiguration"
  47418. */
  47419. getClassName(): string;
  47420. /**
  47421. * Add fallbacks to the effect fallbacks list.
  47422. * @param defines defines the Base texture to use.
  47423. * @param fallbacks defines the current fallback list.
  47424. * @param currentRank defines the current fallback rank.
  47425. * @returns the new fallback rank.
  47426. */
  47427. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47428. /**
  47429. * Add the required uniforms to the current list.
  47430. * @param uniforms defines the current uniform list.
  47431. */
  47432. static AddUniforms(uniforms: string[]): void;
  47433. /**
  47434. * Add the required samplers to the current list.
  47435. * @param samplers defines the current sampler list.
  47436. */
  47437. static AddSamplers(samplers: string[]): void;
  47438. /**
  47439. * Add the required uniforms to the current buffer.
  47440. * @param uniformBuffer defines the current uniform buffer.
  47441. */
  47442. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47443. /**
  47444. * Makes a duplicate of the current configuration into another one.
  47445. * @param clearCoatConfiguration define the config where to copy the info
  47446. */
  47447. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47448. /**
  47449. * Serializes this clear coat configuration.
  47450. * @returns - An object with the serialized config.
  47451. */
  47452. serialize(): any;
  47453. /**
  47454. * Parses a anisotropy Configuration from a serialized object.
  47455. * @param source - Serialized object.
  47456. * @param scene Defines the scene we are parsing for
  47457. * @param rootUrl Defines the rootUrl to load from
  47458. */
  47459. parse(source: any, scene: Scene, rootUrl: string): void;
  47460. }
  47461. }
  47462. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47463. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47464. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47466. import { Vector2 } from "babylonjs/Maths/math.vector";
  47467. import { Scene } from "babylonjs/scene";
  47468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47469. import { Nullable } from "babylonjs/types";
  47470. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47471. /**
  47472. * @hidden
  47473. */
  47474. export interface IMaterialAnisotropicDefines {
  47475. ANISOTROPIC: boolean;
  47476. ANISOTROPIC_TEXTURE: boolean;
  47477. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47478. MAINUV1: boolean;
  47479. _areTexturesDirty: boolean;
  47480. _needUVs: boolean;
  47481. }
  47482. /**
  47483. * Define the code related to the anisotropic parameters of the pbr material.
  47484. */
  47485. export class PBRAnisotropicConfiguration {
  47486. private _isEnabled;
  47487. /**
  47488. * Defines if the anisotropy is enabled in the material.
  47489. */
  47490. isEnabled: boolean;
  47491. /**
  47492. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47493. */
  47494. intensity: number;
  47495. /**
  47496. * Defines if the effect is along the tangents, bitangents or in between.
  47497. * By default, the effect is "strectching" the highlights along the tangents.
  47498. */
  47499. direction: Vector2;
  47500. private _texture;
  47501. /**
  47502. * Stores the anisotropy values in a texture.
  47503. * rg is direction (like normal from -1 to 1)
  47504. * b is a intensity
  47505. */
  47506. texture: Nullable<BaseTexture>;
  47507. /** @hidden */
  47508. private _internalMarkAllSubMeshesAsTexturesDirty;
  47509. /** @hidden */
  47510. _markAllSubMeshesAsTexturesDirty(): void;
  47511. /**
  47512. * Instantiate a new istance of anisotropy configuration.
  47513. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47514. */
  47515. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47516. /**
  47517. * Specifies that the submesh is ready to be used.
  47518. * @param defines the list of "defines" to update.
  47519. * @param scene defines the scene the material belongs to.
  47520. * @returns - boolean indicating that the submesh is ready or not.
  47521. */
  47522. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47523. /**
  47524. * Checks to see if a texture is used in the material.
  47525. * @param defines the list of "defines" to update.
  47526. * @param mesh the mesh we are preparing the defines for.
  47527. * @param scene defines the scene the material belongs to.
  47528. */
  47529. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47530. /**
  47531. * Binds the material data.
  47532. * @param uniformBuffer defines the Uniform buffer to fill in.
  47533. * @param scene defines the scene the material belongs to.
  47534. * @param isFrozen defines wether the material is frozen or not.
  47535. */
  47536. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47537. /**
  47538. * Checks to see if a texture is used in the material.
  47539. * @param texture - Base texture to use.
  47540. * @returns - Boolean specifying if a texture is used in the material.
  47541. */
  47542. hasTexture(texture: BaseTexture): boolean;
  47543. /**
  47544. * Returns an array of the actively used textures.
  47545. * @param activeTextures Array of BaseTextures
  47546. */
  47547. getActiveTextures(activeTextures: BaseTexture[]): void;
  47548. /**
  47549. * Returns the animatable textures.
  47550. * @param animatables Array of animatable textures.
  47551. */
  47552. getAnimatables(animatables: IAnimatable[]): void;
  47553. /**
  47554. * Disposes the resources of the material.
  47555. * @param forceDisposeTextures - Forces the disposal of all textures.
  47556. */
  47557. dispose(forceDisposeTextures?: boolean): void;
  47558. /**
  47559. * Get the current class name of the texture useful for serialization or dynamic coding.
  47560. * @returns "PBRAnisotropicConfiguration"
  47561. */
  47562. getClassName(): string;
  47563. /**
  47564. * Add fallbacks to the effect fallbacks list.
  47565. * @param defines defines the Base texture to use.
  47566. * @param fallbacks defines the current fallback list.
  47567. * @param currentRank defines the current fallback rank.
  47568. * @returns the new fallback rank.
  47569. */
  47570. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47571. /**
  47572. * Add the required uniforms to the current list.
  47573. * @param uniforms defines the current uniform list.
  47574. */
  47575. static AddUniforms(uniforms: string[]): void;
  47576. /**
  47577. * Add the required uniforms to the current buffer.
  47578. * @param uniformBuffer defines the current uniform buffer.
  47579. */
  47580. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47581. /**
  47582. * Add the required samplers to the current list.
  47583. * @param samplers defines the current sampler list.
  47584. */
  47585. static AddSamplers(samplers: string[]): void;
  47586. /**
  47587. * Makes a duplicate of the current configuration into another one.
  47588. * @param anisotropicConfiguration define the config where to copy the info
  47589. */
  47590. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47591. /**
  47592. * Serializes this anisotropy configuration.
  47593. * @returns - An object with the serialized config.
  47594. */
  47595. serialize(): any;
  47596. /**
  47597. * Parses a anisotropy Configuration from a serialized object.
  47598. * @param source - Serialized object.
  47599. * @param scene Defines the scene we are parsing for
  47600. * @param rootUrl Defines the rootUrl to load from
  47601. */
  47602. parse(source: any, scene: Scene, rootUrl: string): void;
  47603. }
  47604. }
  47605. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47606. import { Scene } from "babylonjs/scene";
  47607. /**
  47608. * @hidden
  47609. */
  47610. export interface IMaterialBRDFDefines {
  47611. BRDF_V_HEIGHT_CORRELATED: boolean;
  47612. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47613. SPHERICAL_HARMONICS: boolean;
  47614. /** @hidden */
  47615. _areMiscDirty: boolean;
  47616. }
  47617. /**
  47618. * Define the code related to the BRDF parameters of the pbr material.
  47619. */
  47620. export class PBRBRDFConfiguration {
  47621. /**
  47622. * Default value used for the energy conservation.
  47623. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47624. */
  47625. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47626. /**
  47627. * Default value used for the Smith Visibility Height Correlated mode.
  47628. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47629. */
  47630. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47631. /**
  47632. * Default value used for the IBL diffuse part.
  47633. * This can help switching back to the polynomials mode globally which is a tiny bit
  47634. * less GPU intensive at the drawback of a lower quality.
  47635. */
  47636. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47637. private _useEnergyConservation;
  47638. /**
  47639. * Defines if the material uses energy conservation.
  47640. */
  47641. useEnergyConservation: boolean;
  47642. private _useSmithVisibilityHeightCorrelated;
  47643. /**
  47644. * LEGACY Mode set to false
  47645. * Defines if the material uses height smith correlated visibility term.
  47646. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47647. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47648. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47649. * Not relying on height correlated will also disable energy conservation.
  47650. */
  47651. useSmithVisibilityHeightCorrelated: boolean;
  47652. private _useSphericalHarmonics;
  47653. /**
  47654. * LEGACY Mode set to false
  47655. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47656. * diffuse part of the IBL.
  47657. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47658. * to the ground truth.
  47659. */
  47660. useSphericalHarmonics: boolean;
  47661. /** @hidden */
  47662. private _internalMarkAllSubMeshesAsMiscDirty;
  47663. /** @hidden */
  47664. _markAllSubMeshesAsMiscDirty(): void;
  47665. /**
  47666. * Instantiate a new istance of clear coat configuration.
  47667. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47668. */
  47669. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47670. /**
  47671. * Checks to see if a texture is used in the material.
  47672. * @param defines the list of "defines" to update.
  47673. */
  47674. prepareDefines(defines: IMaterialBRDFDefines): void;
  47675. /**
  47676. * Get the current class name of the texture useful for serialization or dynamic coding.
  47677. * @returns "PBRClearCoatConfiguration"
  47678. */
  47679. getClassName(): string;
  47680. /**
  47681. * Makes a duplicate of the current configuration into another one.
  47682. * @param brdfConfiguration define the config where to copy the info
  47683. */
  47684. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47685. /**
  47686. * Serializes this BRDF configuration.
  47687. * @returns - An object with the serialized config.
  47688. */
  47689. serialize(): any;
  47690. /**
  47691. * Parses a anisotropy Configuration from a serialized object.
  47692. * @param source - Serialized object.
  47693. * @param scene Defines the scene we are parsing for
  47694. * @param rootUrl Defines the rootUrl to load from
  47695. */
  47696. parse(source: any, scene: Scene, rootUrl: string): void;
  47697. }
  47698. }
  47699. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47700. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47701. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47702. import { Color3 } from "babylonjs/Maths/math.color";
  47703. import { Scene } from "babylonjs/scene";
  47704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47705. import { Nullable } from "babylonjs/types";
  47706. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47707. /**
  47708. * @hidden
  47709. */
  47710. export interface IMaterialSheenDefines {
  47711. SHEEN: boolean;
  47712. SHEEN_TEXTURE: boolean;
  47713. SHEEN_TEXTUREDIRECTUV: number;
  47714. SHEEN_LINKWITHALBEDO: boolean;
  47715. /** @hidden */
  47716. _areTexturesDirty: boolean;
  47717. }
  47718. /**
  47719. * Define the code related to the Sheen parameters of the pbr material.
  47720. */
  47721. export class PBRSheenConfiguration {
  47722. private _isEnabled;
  47723. /**
  47724. * Defines if the material uses sheen.
  47725. */
  47726. isEnabled: boolean;
  47727. private _linkSheenWithAlbedo;
  47728. /**
  47729. * Defines if the sheen is linked to the sheen color.
  47730. */
  47731. linkSheenWithAlbedo: boolean;
  47732. /**
  47733. * Defines the sheen intensity.
  47734. */
  47735. intensity: number;
  47736. /**
  47737. * Defines the sheen color.
  47738. */
  47739. color: Color3;
  47740. private _texture;
  47741. /**
  47742. * Stores the sheen tint values in a texture.
  47743. * rgb is tint
  47744. * a is a intensity
  47745. */
  47746. texture: Nullable<BaseTexture>;
  47747. /** @hidden */
  47748. private _internalMarkAllSubMeshesAsTexturesDirty;
  47749. /** @hidden */
  47750. _markAllSubMeshesAsTexturesDirty(): void;
  47751. /**
  47752. * Instantiate a new istance of clear coat configuration.
  47753. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47754. */
  47755. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47756. /**
  47757. * Specifies that the submesh is ready to be used.
  47758. * @param defines the list of "defines" to update.
  47759. * @param scene defines the scene the material belongs to.
  47760. * @returns - boolean indicating that the submesh is ready or not.
  47761. */
  47762. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47763. /**
  47764. * Checks to see if a texture is used in the material.
  47765. * @param defines the list of "defines" to update.
  47766. * @param scene defines the scene the material belongs to.
  47767. */
  47768. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47769. /**
  47770. * Binds the material data.
  47771. * @param uniformBuffer defines the Uniform buffer to fill in.
  47772. * @param scene defines the scene the material belongs to.
  47773. * @param isFrozen defines wether the material is frozen or not.
  47774. */
  47775. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47776. /**
  47777. * Checks to see if a texture is used in the material.
  47778. * @param texture - Base texture to use.
  47779. * @returns - Boolean specifying if a texture is used in the material.
  47780. */
  47781. hasTexture(texture: BaseTexture): boolean;
  47782. /**
  47783. * Returns an array of the actively used textures.
  47784. * @param activeTextures Array of BaseTextures
  47785. */
  47786. getActiveTextures(activeTextures: BaseTexture[]): void;
  47787. /**
  47788. * Returns the animatable textures.
  47789. * @param animatables Array of animatable textures.
  47790. */
  47791. getAnimatables(animatables: IAnimatable[]): void;
  47792. /**
  47793. * Disposes the resources of the material.
  47794. * @param forceDisposeTextures - Forces the disposal of all textures.
  47795. */
  47796. dispose(forceDisposeTextures?: boolean): void;
  47797. /**
  47798. * Get the current class name of the texture useful for serialization or dynamic coding.
  47799. * @returns "PBRSheenConfiguration"
  47800. */
  47801. getClassName(): string;
  47802. /**
  47803. * Add fallbacks to the effect fallbacks list.
  47804. * @param defines defines the Base texture to use.
  47805. * @param fallbacks defines the current fallback list.
  47806. * @param currentRank defines the current fallback rank.
  47807. * @returns the new fallback rank.
  47808. */
  47809. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47810. /**
  47811. * Add the required uniforms to the current list.
  47812. * @param uniforms defines the current uniform list.
  47813. */
  47814. static AddUniforms(uniforms: string[]): void;
  47815. /**
  47816. * Add the required uniforms to the current buffer.
  47817. * @param uniformBuffer defines the current uniform buffer.
  47818. */
  47819. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47820. /**
  47821. * Add the required samplers to the current list.
  47822. * @param samplers defines the current sampler list.
  47823. */
  47824. static AddSamplers(samplers: string[]): void;
  47825. /**
  47826. * Makes a duplicate of the current configuration into another one.
  47827. * @param sheenConfiguration define the config where to copy the info
  47828. */
  47829. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47830. /**
  47831. * Serializes this BRDF configuration.
  47832. * @returns - An object with the serialized config.
  47833. */
  47834. serialize(): any;
  47835. /**
  47836. * Parses a anisotropy Configuration from a serialized object.
  47837. * @param source - Serialized object.
  47838. * @param scene Defines the scene we are parsing for
  47839. * @param rootUrl Defines the rootUrl to load from
  47840. */
  47841. parse(source: any, scene: Scene, rootUrl: string): void;
  47842. }
  47843. }
  47844. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47845. import { Nullable } from "babylonjs/types";
  47846. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47847. import { Color3 } from "babylonjs/Maths/math.color";
  47848. import { SmartArray } from "babylonjs/Misc/smartArray";
  47849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47850. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47851. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47852. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47853. import { Engine } from "babylonjs/Engines/engine";
  47854. import { Scene } from "babylonjs/scene";
  47855. /**
  47856. * @hidden
  47857. */
  47858. export interface IMaterialSubSurfaceDefines {
  47859. SUBSURFACE: boolean;
  47860. SS_REFRACTION: boolean;
  47861. SS_TRANSLUCENCY: boolean;
  47862. SS_SCATERRING: boolean;
  47863. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47864. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47865. SS_REFRACTIONMAP_3D: boolean;
  47866. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47867. SS_LODINREFRACTIONALPHA: boolean;
  47868. SS_GAMMAREFRACTION: boolean;
  47869. SS_RGBDREFRACTION: boolean;
  47870. SS_LINEARSPECULARREFRACTION: boolean;
  47871. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47872. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47873. /** @hidden */
  47874. _areTexturesDirty: boolean;
  47875. }
  47876. /**
  47877. * Define the code related to the sub surface parameters of the pbr material.
  47878. */
  47879. export class PBRSubSurfaceConfiguration {
  47880. private _isRefractionEnabled;
  47881. /**
  47882. * Defines if the refraction is enabled in the material.
  47883. */
  47884. isRefractionEnabled: boolean;
  47885. private _isTranslucencyEnabled;
  47886. /**
  47887. * Defines if the translucency is enabled in the material.
  47888. */
  47889. isTranslucencyEnabled: boolean;
  47890. private _isScatteringEnabled;
  47891. /**
  47892. * Defines the refraction intensity of the material.
  47893. * The refraction when enabled replaces the Diffuse part of the material.
  47894. * The intensity helps transitionning between diffuse and refraction.
  47895. */
  47896. refractionIntensity: number;
  47897. /**
  47898. * Defines the translucency intensity of the material.
  47899. * When translucency has been enabled, this defines how much of the "translucency"
  47900. * is addded to the diffuse part of the material.
  47901. */
  47902. translucencyIntensity: number;
  47903. /**
  47904. * Defines the scattering intensity of the material.
  47905. * When scattering has been enabled, this defines how much of the "scattered light"
  47906. * is addded to the diffuse part of the material.
  47907. */
  47908. scatteringIntensity: number;
  47909. private _thicknessTexture;
  47910. /**
  47911. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47912. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47913. * 0 would mean minimumThickness
  47914. * 1 would mean maximumThickness
  47915. * The other channels might be use as a mask to vary the different effects intensity.
  47916. */
  47917. thicknessTexture: Nullable<BaseTexture>;
  47918. private _refractionTexture;
  47919. /**
  47920. * Defines the texture to use for refraction.
  47921. */
  47922. refractionTexture: Nullable<BaseTexture>;
  47923. private _indexOfRefraction;
  47924. /**
  47925. * Defines the index of refraction used in the material.
  47926. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47927. */
  47928. indexOfRefraction: number;
  47929. private _invertRefractionY;
  47930. /**
  47931. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47932. */
  47933. invertRefractionY: boolean;
  47934. private _linkRefractionWithTransparency;
  47935. /**
  47936. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47937. * Materials half opaque for instance using refraction could benefit from this control.
  47938. */
  47939. linkRefractionWithTransparency: boolean;
  47940. /**
  47941. * Defines the minimum thickness stored in the thickness map.
  47942. * If no thickness map is defined, this value will be used to simulate thickness.
  47943. */
  47944. minimumThickness: number;
  47945. /**
  47946. * Defines the maximum thickness stored in the thickness map.
  47947. */
  47948. maximumThickness: number;
  47949. /**
  47950. * Defines the volume tint of the material.
  47951. * This is used for both translucency and scattering.
  47952. */
  47953. tintColor: Color3;
  47954. /**
  47955. * Defines the distance at which the tint color should be found in the media.
  47956. * This is used for refraction only.
  47957. */
  47958. tintColorAtDistance: number;
  47959. /**
  47960. * Defines how far each channel transmit through the media.
  47961. * It is defined as a color to simplify it selection.
  47962. */
  47963. diffusionDistance: Color3;
  47964. private _useMaskFromThicknessTexture;
  47965. /**
  47966. * Stores the intensity of the different subsurface effects in the thickness texture.
  47967. * * the green channel is the translucency intensity.
  47968. * * the blue channel is the scattering intensity.
  47969. * * the alpha channel is the refraction intensity.
  47970. */
  47971. useMaskFromThicknessTexture: boolean;
  47972. /** @hidden */
  47973. private _internalMarkAllSubMeshesAsTexturesDirty;
  47974. /** @hidden */
  47975. _markAllSubMeshesAsTexturesDirty(): void;
  47976. /**
  47977. * Instantiate a new istance of sub surface configuration.
  47978. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47979. */
  47980. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47981. /**
  47982. * Gets wehter the submesh is ready to be used or not.
  47983. * @param defines the list of "defines" to update.
  47984. * @param scene defines the scene the material belongs to.
  47985. * @returns - boolean indicating that the submesh is ready or not.
  47986. */
  47987. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47988. /**
  47989. * Checks to see if a texture is used in the material.
  47990. * @param defines the list of "defines" to update.
  47991. * @param scene defines the scene to the material belongs to.
  47992. */
  47993. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47994. /**
  47995. * Binds the material data.
  47996. * @param uniformBuffer defines the Uniform buffer to fill in.
  47997. * @param scene defines the scene the material belongs to.
  47998. * @param engine defines the engine the material belongs to.
  47999. * @param isFrozen defines wether the material is frozen or not.
  48000. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48001. */
  48002. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48003. /**
  48004. * Unbinds the material from the mesh.
  48005. * @param activeEffect defines the effect that should be unbound from.
  48006. * @returns true if unbound, otherwise false
  48007. */
  48008. unbind(activeEffect: Effect): boolean;
  48009. /**
  48010. * Returns the texture used for refraction or null if none is used.
  48011. * @param scene defines the scene the material belongs to.
  48012. * @returns - Refraction texture if present. If no refraction texture and refraction
  48013. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48014. */
  48015. private _getRefractionTexture;
  48016. /**
  48017. * Returns true if alpha blending should be disabled.
  48018. */
  48019. readonly disableAlphaBlending: boolean;
  48020. /**
  48021. * Fills the list of render target textures.
  48022. * @param renderTargets the list of render targets to update
  48023. */
  48024. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48025. /**
  48026. * Checks to see if a texture is used in the material.
  48027. * @param texture - Base texture to use.
  48028. * @returns - Boolean specifying if a texture is used in the material.
  48029. */
  48030. hasTexture(texture: BaseTexture): boolean;
  48031. /**
  48032. * Gets a boolean indicating that current material needs to register RTT
  48033. * @returns true if this uses a render target otherwise false.
  48034. */
  48035. hasRenderTargetTextures(): boolean;
  48036. /**
  48037. * Returns an array of the actively used textures.
  48038. * @param activeTextures Array of BaseTextures
  48039. */
  48040. getActiveTextures(activeTextures: BaseTexture[]): void;
  48041. /**
  48042. * Returns the animatable textures.
  48043. * @param animatables Array of animatable textures.
  48044. */
  48045. getAnimatables(animatables: IAnimatable[]): void;
  48046. /**
  48047. * Disposes the resources of the material.
  48048. * @param forceDisposeTextures - Forces the disposal of all textures.
  48049. */
  48050. dispose(forceDisposeTextures?: boolean): void;
  48051. /**
  48052. * Get the current class name of the texture useful for serialization or dynamic coding.
  48053. * @returns "PBRSubSurfaceConfiguration"
  48054. */
  48055. getClassName(): string;
  48056. /**
  48057. * Add fallbacks to the effect fallbacks list.
  48058. * @param defines defines the Base texture to use.
  48059. * @param fallbacks defines the current fallback list.
  48060. * @param currentRank defines the current fallback rank.
  48061. * @returns the new fallback rank.
  48062. */
  48063. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48064. /**
  48065. * Add the required uniforms to the current list.
  48066. * @param uniforms defines the current uniform list.
  48067. */
  48068. static AddUniforms(uniforms: string[]): void;
  48069. /**
  48070. * Add the required samplers to the current list.
  48071. * @param samplers defines the current sampler list.
  48072. */
  48073. static AddSamplers(samplers: string[]): void;
  48074. /**
  48075. * Add the required uniforms to the current buffer.
  48076. * @param uniformBuffer defines the current uniform buffer.
  48077. */
  48078. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48079. /**
  48080. * Makes a duplicate of the current configuration into another one.
  48081. * @param configuration define the config where to copy the info
  48082. */
  48083. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48084. /**
  48085. * Serializes this Sub Surface configuration.
  48086. * @returns - An object with the serialized config.
  48087. */
  48088. serialize(): any;
  48089. /**
  48090. * Parses a anisotropy Configuration from a serialized object.
  48091. * @param source - Serialized object.
  48092. * @param scene Defines the scene we are parsing for
  48093. * @param rootUrl Defines the rootUrl to load from
  48094. */
  48095. parse(source: any, scene: Scene, rootUrl: string): void;
  48096. }
  48097. }
  48098. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48099. /** @hidden */
  48100. export var pbrFragmentDeclaration: {
  48101. name: string;
  48102. shader: string;
  48103. };
  48104. }
  48105. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48106. /** @hidden */
  48107. export var pbrUboDeclaration: {
  48108. name: string;
  48109. shader: string;
  48110. };
  48111. }
  48112. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48113. /** @hidden */
  48114. export var pbrFragmentExtraDeclaration: {
  48115. name: string;
  48116. shader: string;
  48117. };
  48118. }
  48119. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48120. /** @hidden */
  48121. export var pbrFragmentSamplersDeclaration: {
  48122. name: string;
  48123. shader: string;
  48124. };
  48125. }
  48126. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48127. /** @hidden */
  48128. export var pbrHelperFunctions: {
  48129. name: string;
  48130. shader: string;
  48131. };
  48132. }
  48133. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48134. /** @hidden */
  48135. export var harmonicsFunctions: {
  48136. name: string;
  48137. shader: string;
  48138. };
  48139. }
  48140. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48141. /** @hidden */
  48142. export var pbrDirectLightingSetupFunctions: {
  48143. name: string;
  48144. shader: string;
  48145. };
  48146. }
  48147. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48148. /** @hidden */
  48149. export var pbrDirectLightingFalloffFunctions: {
  48150. name: string;
  48151. shader: string;
  48152. };
  48153. }
  48154. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48155. /** @hidden */
  48156. export var pbrBRDFFunctions: {
  48157. name: string;
  48158. shader: string;
  48159. };
  48160. }
  48161. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48162. /** @hidden */
  48163. export var pbrDirectLightingFunctions: {
  48164. name: string;
  48165. shader: string;
  48166. };
  48167. }
  48168. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48169. /** @hidden */
  48170. export var pbrIBLFunctions: {
  48171. name: string;
  48172. shader: string;
  48173. };
  48174. }
  48175. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48176. /** @hidden */
  48177. export var pbrDebug: {
  48178. name: string;
  48179. shader: string;
  48180. };
  48181. }
  48182. declare module "babylonjs/Shaders/pbr.fragment" {
  48183. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48184. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48185. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48186. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48187. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48188. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48189. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48190. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48191. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48192. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48193. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48194. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48195. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48196. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48197. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48198. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48199. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48200. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48201. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48202. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48203. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48204. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48205. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48206. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48207. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48208. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48209. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48210. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48211. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48212. /** @hidden */
  48213. export var pbrPixelShader: {
  48214. name: string;
  48215. shader: string;
  48216. };
  48217. }
  48218. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48219. /** @hidden */
  48220. export var pbrVertexDeclaration: {
  48221. name: string;
  48222. shader: string;
  48223. };
  48224. }
  48225. declare module "babylonjs/Shaders/pbr.vertex" {
  48226. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48227. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48228. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48229. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48230. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48231. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48232. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48233. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48234. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48235. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48236. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48237. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48238. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48239. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48240. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48241. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48242. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48243. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48244. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48245. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48246. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48247. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48248. /** @hidden */
  48249. export var pbrVertexShader: {
  48250. name: string;
  48251. shader: string;
  48252. };
  48253. }
  48254. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48255. import { Nullable } from "babylonjs/types";
  48256. import { Scene } from "babylonjs/scene";
  48257. import { Matrix } from "babylonjs/Maths/math.vector";
  48258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48260. import { Mesh } from "babylonjs/Meshes/mesh";
  48261. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48262. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48263. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48264. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48265. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48266. import { Color3 } from "babylonjs/Maths/math.color";
  48267. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48268. import { Material } from "babylonjs/Materials/material";
  48269. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48270. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48272. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48273. import "babylonjs/Shaders/pbr.fragment";
  48274. import "babylonjs/Shaders/pbr.vertex";
  48275. /**
  48276. * Manages the defines for the PBR Material.
  48277. * @hidden
  48278. */
  48279. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48280. PBR: boolean;
  48281. MAINUV1: boolean;
  48282. MAINUV2: boolean;
  48283. UV1: boolean;
  48284. UV2: boolean;
  48285. ALBEDO: boolean;
  48286. ALBEDODIRECTUV: number;
  48287. VERTEXCOLOR: boolean;
  48288. AMBIENT: boolean;
  48289. AMBIENTDIRECTUV: number;
  48290. AMBIENTINGRAYSCALE: boolean;
  48291. OPACITY: boolean;
  48292. VERTEXALPHA: boolean;
  48293. OPACITYDIRECTUV: number;
  48294. OPACITYRGB: boolean;
  48295. ALPHATEST: boolean;
  48296. DEPTHPREPASS: boolean;
  48297. ALPHABLEND: boolean;
  48298. ALPHAFROMALBEDO: boolean;
  48299. ALPHATESTVALUE: string;
  48300. SPECULAROVERALPHA: boolean;
  48301. RADIANCEOVERALPHA: boolean;
  48302. ALPHAFRESNEL: boolean;
  48303. LINEARALPHAFRESNEL: boolean;
  48304. PREMULTIPLYALPHA: boolean;
  48305. EMISSIVE: boolean;
  48306. EMISSIVEDIRECTUV: number;
  48307. REFLECTIVITY: boolean;
  48308. REFLECTIVITYDIRECTUV: number;
  48309. SPECULARTERM: boolean;
  48310. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48311. MICROSURFACEAUTOMATIC: boolean;
  48312. LODBASEDMICROSFURACE: boolean;
  48313. MICROSURFACEMAP: boolean;
  48314. MICROSURFACEMAPDIRECTUV: number;
  48315. METALLICWORKFLOW: boolean;
  48316. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48317. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48318. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48319. AOSTOREINMETALMAPRED: boolean;
  48320. ENVIRONMENTBRDF: boolean;
  48321. ENVIRONMENTBRDF_RGBD: boolean;
  48322. NORMAL: boolean;
  48323. TANGENT: boolean;
  48324. BUMP: boolean;
  48325. BUMPDIRECTUV: number;
  48326. OBJECTSPACE_NORMALMAP: boolean;
  48327. PARALLAX: boolean;
  48328. PARALLAXOCCLUSION: boolean;
  48329. NORMALXYSCALE: boolean;
  48330. LIGHTMAP: boolean;
  48331. LIGHTMAPDIRECTUV: number;
  48332. USELIGHTMAPASSHADOWMAP: boolean;
  48333. GAMMALIGHTMAP: boolean;
  48334. REFLECTION: boolean;
  48335. REFLECTIONMAP_3D: boolean;
  48336. REFLECTIONMAP_SPHERICAL: boolean;
  48337. REFLECTIONMAP_PLANAR: boolean;
  48338. REFLECTIONMAP_CUBIC: boolean;
  48339. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48340. REFLECTIONMAP_PROJECTION: boolean;
  48341. REFLECTIONMAP_SKYBOX: boolean;
  48342. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48343. REFLECTIONMAP_EXPLICIT: boolean;
  48344. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48345. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48346. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48347. INVERTCUBICMAP: boolean;
  48348. USESPHERICALFROMREFLECTIONMAP: boolean;
  48349. USEIRRADIANCEMAP: boolean;
  48350. SPHERICAL_HARMONICS: boolean;
  48351. USESPHERICALINVERTEX: boolean;
  48352. REFLECTIONMAP_OPPOSITEZ: boolean;
  48353. LODINREFLECTIONALPHA: boolean;
  48354. GAMMAREFLECTION: boolean;
  48355. RGBDREFLECTION: boolean;
  48356. LINEARSPECULARREFLECTION: boolean;
  48357. RADIANCEOCCLUSION: boolean;
  48358. HORIZONOCCLUSION: boolean;
  48359. INSTANCES: boolean;
  48360. NUM_BONE_INFLUENCERS: number;
  48361. BonesPerMesh: number;
  48362. BONETEXTURE: boolean;
  48363. NONUNIFORMSCALING: boolean;
  48364. MORPHTARGETS: boolean;
  48365. MORPHTARGETS_NORMAL: boolean;
  48366. MORPHTARGETS_TANGENT: boolean;
  48367. MORPHTARGETS_UV: boolean;
  48368. NUM_MORPH_INFLUENCERS: number;
  48369. IMAGEPROCESSING: boolean;
  48370. VIGNETTE: boolean;
  48371. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48372. VIGNETTEBLENDMODEOPAQUE: boolean;
  48373. TONEMAPPING: boolean;
  48374. TONEMAPPING_ACES: boolean;
  48375. CONTRAST: boolean;
  48376. COLORCURVES: boolean;
  48377. COLORGRADING: boolean;
  48378. COLORGRADING3D: boolean;
  48379. SAMPLER3DGREENDEPTH: boolean;
  48380. SAMPLER3DBGRMAP: boolean;
  48381. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48382. EXPOSURE: boolean;
  48383. MULTIVIEW: boolean;
  48384. USEPHYSICALLIGHTFALLOFF: boolean;
  48385. USEGLTFLIGHTFALLOFF: boolean;
  48386. TWOSIDEDLIGHTING: boolean;
  48387. SHADOWFLOAT: boolean;
  48388. CLIPPLANE: boolean;
  48389. CLIPPLANE2: boolean;
  48390. CLIPPLANE3: boolean;
  48391. CLIPPLANE4: boolean;
  48392. POINTSIZE: boolean;
  48393. FOG: boolean;
  48394. LOGARITHMICDEPTH: boolean;
  48395. FORCENORMALFORWARD: boolean;
  48396. SPECULARAA: boolean;
  48397. CLEARCOAT: boolean;
  48398. CLEARCOAT_DEFAULTIOR: boolean;
  48399. CLEARCOAT_TEXTURE: boolean;
  48400. CLEARCOAT_TEXTUREDIRECTUV: number;
  48401. CLEARCOAT_BUMP: boolean;
  48402. CLEARCOAT_BUMPDIRECTUV: number;
  48403. CLEARCOAT_TINT: boolean;
  48404. CLEARCOAT_TINT_TEXTURE: boolean;
  48405. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48406. ANISOTROPIC: boolean;
  48407. ANISOTROPIC_TEXTURE: boolean;
  48408. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48409. BRDF_V_HEIGHT_CORRELATED: boolean;
  48410. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48411. SHEEN: boolean;
  48412. SHEEN_TEXTURE: boolean;
  48413. SHEEN_TEXTUREDIRECTUV: number;
  48414. SHEEN_LINKWITHALBEDO: boolean;
  48415. SUBSURFACE: boolean;
  48416. SS_REFRACTION: boolean;
  48417. SS_TRANSLUCENCY: boolean;
  48418. SS_SCATERRING: boolean;
  48419. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48420. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48421. SS_REFRACTIONMAP_3D: boolean;
  48422. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48423. SS_LODINREFRACTIONALPHA: boolean;
  48424. SS_GAMMAREFRACTION: boolean;
  48425. SS_RGBDREFRACTION: boolean;
  48426. SS_LINEARSPECULARREFRACTION: boolean;
  48427. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48428. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48429. UNLIT: boolean;
  48430. DEBUGMODE: number;
  48431. /**
  48432. * Initializes the PBR Material defines.
  48433. */
  48434. constructor();
  48435. /**
  48436. * Resets the PBR Material defines.
  48437. */
  48438. reset(): void;
  48439. }
  48440. /**
  48441. * The Physically based material base class of BJS.
  48442. *
  48443. * This offers the main features of a standard PBR material.
  48444. * For more information, please refer to the documentation :
  48445. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48446. */
  48447. export abstract class PBRBaseMaterial extends PushMaterial {
  48448. /**
  48449. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48450. */
  48451. static readonly PBRMATERIAL_OPAQUE: number;
  48452. /**
  48453. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48454. */
  48455. static readonly PBRMATERIAL_ALPHATEST: number;
  48456. /**
  48457. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48458. */
  48459. static readonly PBRMATERIAL_ALPHABLEND: number;
  48460. /**
  48461. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48462. * They are also discarded below the alpha cutoff threshold to improve performances.
  48463. */
  48464. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48465. /**
  48466. * Defines the default value of how much AO map is occluding the analytical lights
  48467. * (point spot...).
  48468. */
  48469. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48470. /**
  48471. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48472. */
  48473. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48474. /**
  48475. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48476. * to enhance interoperability with other engines.
  48477. */
  48478. static readonly LIGHTFALLOFF_GLTF: number;
  48479. /**
  48480. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48481. * to enhance interoperability with other materials.
  48482. */
  48483. static readonly LIGHTFALLOFF_STANDARD: number;
  48484. /**
  48485. * Intensity of the direct lights e.g. the four lights available in your scene.
  48486. * This impacts both the direct diffuse and specular highlights.
  48487. */
  48488. protected _directIntensity: number;
  48489. /**
  48490. * Intensity of the emissive part of the material.
  48491. * This helps controlling the emissive effect without modifying the emissive color.
  48492. */
  48493. protected _emissiveIntensity: number;
  48494. /**
  48495. * Intensity of the environment e.g. how much the environment will light the object
  48496. * either through harmonics for rough material or through the refelction for shiny ones.
  48497. */
  48498. protected _environmentIntensity: number;
  48499. /**
  48500. * This is a special control allowing the reduction of the specular highlights coming from the
  48501. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48502. */
  48503. protected _specularIntensity: number;
  48504. /**
  48505. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48506. */
  48507. private _lightingInfos;
  48508. /**
  48509. * Debug Control allowing disabling the bump map on this material.
  48510. */
  48511. protected _disableBumpMap: boolean;
  48512. /**
  48513. * AKA Diffuse Texture in standard nomenclature.
  48514. */
  48515. protected _albedoTexture: Nullable<BaseTexture>;
  48516. /**
  48517. * AKA Occlusion Texture in other nomenclature.
  48518. */
  48519. protected _ambientTexture: Nullable<BaseTexture>;
  48520. /**
  48521. * AKA Occlusion Texture Intensity in other nomenclature.
  48522. */
  48523. protected _ambientTextureStrength: number;
  48524. /**
  48525. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48526. * 1 means it completely occludes it
  48527. * 0 mean it has no impact
  48528. */
  48529. protected _ambientTextureImpactOnAnalyticalLights: number;
  48530. /**
  48531. * Stores the alpha values in a texture.
  48532. */
  48533. protected _opacityTexture: Nullable<BaseTexture>;
  48534. /**
  48535. * Stores the reflection values in a texture.
  48536. */
  48537. protected _reflectionTexture: Nullable<BaseTexture>;
  48538. /**
  48539. * Stores the emissive values in a texture.
  48540. */
  48541. protected _emissiveTexture: Nullable<BaseTexture>;
  48542. /**
  48543. * AKA Specular texture in other nomenclature.
  48544. */
  48545. protected _reflectivityTexture: Nullable<BaseTexture>;
  48546. /**
  48547. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48548. */
  48549. protected _metallicTexture: Nullable<BaseTexture>;
  48550. /**
  48551. * Specifies the metallic scalar of the metallic/roughness workflow.
  48552. * Can also be used to scale the metalness values of the metallic texture.
  48553. */
  48554. protected _metallic: Nullable<number>;
  48555. /**
  48556. * Specifies the roughness scalar of the metallic/roughness workflow.
  48557. * Can also be used to scale the roughness values of the metallic texture.
  48558. */
  48559. protected _roughness: Nullable<number>;
  48560. /**
  48561. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48562. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48563. */
  48564. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48565. /**
  48566. * Stores surface normal data used to displace a mesh in a texture.
  48567. */
  48568. protected _bumpTexture: Nullable<BaseTexture>;
  48569. /**
  48570. * Stores the pre-calculated light information of a mesh in a texture.
  48571. */
  48572. protected _lightmapTexture: Nullable<BaseTexture>;
  48573. /**
  48574. * The color of a material in ambient lighting.
  48575. */
  48576. protected _ambientColor: Color3;
  48577. /**
  48578. * AKA Diffuse Color in other nomenclature.
  48579. */
  48580. protected _albedoColor: Color3;
  48581. /**
  48582. * AKA Specular Color in other nomenclature.
  48583. */
  48584. protected _reflectivityColor: Color3;
  48585. /**
  48586. * The color applied when light is reflected from a material.
  48587. */
  48588. protected _reflectionColor: Color3;
  48589. /**
  48590. * The color applied when light is emitted from a material.
  48591. */
  48592. protected _emissiveColor: Color3;
  48593. /**
  48594. * AKA Glossiness in other nomenclature.
  48595. */
  48596. protected _microSurface: number;
  48597. /**
  48598. * Specifies that the material will use the light map as a show map.
  48599. */
  48600. protected _useLightmapAsShadowmap: boolean;
  48601. /**
  48602. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48603. * makes the reflect vector face the model (under horizon).
  48604. */
  48605. protected _useHorizonOcclusion: boolean;
  48606. /**
  48607. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48608. * too much the area relying on ambient texture to define their ambient occlusion.
  48609. */
  48610. protected _useRadianceOcclusion: boolean;
  48611. /**
  48612. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48613. */
  48614. protected _useAlphaFromAlbedoTexture: boolean;
  48615. /**
  48616. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48617. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48618. */
  48619. protected _useSpecularOverAlpha: boolean;
  48620. /**
  48621. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48622. */
  48623. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48624. /**
  48625. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48626. */
  48627. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48628. /**
  48629. * Specifies if the metallic texture contains the roughness information in its green channel.
  48630. */
  48631. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48632. /**
  48633. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48634. */
  48635. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48636. /**
  48637. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48638. */
  48639. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48640. /**
  48641. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48642. */
  48643. protected _useAmbientInGrayScale: boolean;
  48644. /**
  48645. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48646. * The material will try to infer what glossiness each pixel should be.
  48647. */
  48648. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48649. /**
  48650. * Defines the falloff type used in this material.
  48651. * It by default is Physical.
  48652. */
  48653. protected _lightFalloff: number;
  48654. /**
  48655. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48656. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48657. */
  48658. protected _useRadianceOverAlpha: boolean;
  48659. /**
  48660. * Allows using an object space normal map (instead of tangent space).
  48661. */
  48662. protected _useObjectSpaceNormalMap: boolean;
  48663. /**
  48664. * Allows using the bump map in parallax mode.
  48665. */
  48666. protected _useParallax: boolean;
  48667. /**
  48668. * Allows using the bump map in parallax occlusion mode.
  48669. */
  48670. protected _useParallaxOcclusion: boolean;
  48671. /**
  48672. * Controls the scale bias of the parallax mode.
  48673. */
  48674. protected _parallaxScaleBias: number;
  48675. /**
  48676. * If sets to true, disables all the lights affecting the material.
  48677. */
  48678. protected _disableLighting: boolean;
  48679. /**
  48680. * Number of Simultaneous lights allowed on the material.
  48681. */
  48682. protected _maxSimultaneousLights: number;
  48683. /**
  48684. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48685. */
  48686. protected _invertNormalMapX: boolean;
  48687. /**
  48688. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48689. */
  48690. protected _invertNormalMapY: boolean;
  48691. /**
  48692. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48693. */
  48694. protected _twoSidedLighting: boolean;
  48695. /**
  48696. * Defines the alpha limits in alpha test mode.
  48697. */
  48698. protected _alphaCutOff: number;
  48699. /**
  48700. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48701. */
  48702. protected _forceAlphaTest: boolean;
  48703. /**
  48704. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48705. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48706. */
  48707. protected _useAlphaFresnel: boolean;
  48708. /**
  48709. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48710. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48711. */
  48712. protected _useLinearAlphaFresnel: boolean;
  48713. /**
  48714. * The transparency mode of the material.
  48715. */
  48716. protected _transparencyMode: Nullable<number>;
  48717. /**
  48718. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48719. * from cos thetav and roughness:
  48720. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48721. */
  48722. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48723. /**
  48724. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48725. */
  48726. protected _forceIrradianceInFragment: boolean;
  48727. /**
  48728. * Force normal to face away from face.
  48729. */
  48730. protected _forceNormalForward: boolean;
  48731. /**
  48732. * Enables specular anti aliasing in the PBR shader.
  48733. * It will both interacts on the Geometry for analytical and IBL lighting.
  48734. * It also prefilter the roughness map based on the bump values.
  48735. */
  48736. protected _enableSpecularAntiAliasing: boolean;
  48737. /**
  48738. * Default configuration related to image processing available in the PBR Material.
  48739. */
  48740. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48741. /**
  48742. * Keep track of the image processing observer to allow dispose and replace.
  48743. */
  48744. private _imageProcessingObserver;
  48745. /**
  48746. * Attaches a new image processing configuration to the PBR Material.
  48747. * @param configuration
  48748. */
  48749. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48750. /**
  48751. * Stores the available render targets.
  48752. */
  48753. private _renderTargets;
  48754. /**
  48755. * Sets the global ambient color for the material used in lighting calculations.
  48756. */
  48757. private _globalAmbientColor;
  48758. /**
  48759. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48760. */
  48761. private _useLogarithmicDepth;
  48762. /**
  48763. * If set to true, no lighting calculations will be applied.
  48764. */
  48765. private _unlit;
  48766. private _debugMode;
  48767. /**
  48768. * @hidden
  48769. * This is reserved for the inspector.
  48770. * Defines the material debug mode.
  48771. * It helps seeing only some components of the material while troubleshooting.
  48772. */
  48773. debugMode: number;
  48774. /**
  48775. * @hidden
  48776. * This is reserved for the inspector.
  48777. * Specify from where on screen the debug mode should start.
  48778. * The value goes from -1 (full screen) to 1 (not visible)
  48779. * It helps with side by side comparison against the final render
  48780. * This defaults to -1
  48781. */
  48782. private debugLimit;
  48783. /**
  48784. * @hidden
  48785. * This is reserved for the inspector.
  48786. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48787. * You can use the factor to better multiply the final value.
  48788. */
  48789. private debugFactor;
  48790. /**
  48791. * Defines the clear coat layer parameters for the material.
  48792. */
  48793. readonly clearCoat: PBRClearCoatConfiguration;
  48794. /**
  48795. * Defines the anisotropic parameters for the material.
  48796. */
  48797. readonly anisotropy: PBRAnisotropicConfiguration;
  48798. /**
  48799. * Defines the BRDF parameters for the material.
  48800. */
  48801. readonly brdf: PBRBRDFConfiguration;
  48802. /**
  48803. * Defines the Sheen parameters for the material.
  48804. */
  48805. readonly sheen: PBRSheenConfiguration;
  48806. /**
  48807. * Defines the SubSurface parameters for the material.
  48808. */
  48809. readonly subSurface: PBRSubSurfaceConfiguration;
  48810. /**
  48811. * Custom callback helping to override the default shader used in the material.
  48812. */
  48813. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48814. /**
  48815. * Instantiates a new PBRMaterial instance.
  48816. *
  48817. * @param name The material name
  48818. * @param scene The scene the material will be use in.
  48819. */
  48820. constructor(name: string, scene: Scene);
  48821. /**
  48822. * Gets a boolean indicating that current material needs to register RTT
  48823. */
  48824. readonly hasRenderTargetTextures: boolean;
  48825. /**
  48826. * Gets the name of the material class.
  48827. */
  48828. getClassName(): string;
  48829. /**
  48830. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48831. */
  48832. /**
  48833. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48834. */
  48835. useLogarithmicDepth: boolean;
  48836. /**
  48837. * Gets the current transparency mode.
  48838. */
  48839. /**
  48840. * Sets the transparency mode of the material.
  48841. *
  48842. * | Value | Type | Description |
  48843. * | ----- | ----------------------------------- | ----------- |
  48844. * | 0 | OPAQUE | |
  48845. * | 1 | ALPHATEST | |
  48846. * | 2 | ALPHABLEND | |
  48847. * | 3 | ALPHATESTANDBLEND | |
  48848. *
  48849. */
  48850. transparencyMode: Nullable<number>;
  48851. /**
  48852. * Returns true if alpha blending should be disabled.
  48853. */
  48854. private readonly _disableAlphaBlending;
  48855. /**
  48856. * Specifies whether or not this material should be rendered in alpha blend mode.
  48857. */
  48858. needAlphaBlending(): boolean;
  48859. /**
  48860. * Specifies if the mesh will require alpha blending.
  48861. * @param mesh - BJS mesh.
  48862. */
  48863. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48864. /**
  48865. * Specifies whether or not this material should be rendered in alpha test mode.
  48866. */
  48867. needAlphaTesting(): boolean;
  48868. /**
  48869. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48870. */
  48871. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48872. /**
  48873. * Gets the texture used for the alpha test.
  48874. */
  48875. getAlphaTestTexture(): Nullable<BaseTexture>;
  48876. /**
  48877. * Specifies that the submesh is ready to be used.
  48878. * @param mesh - BJS mesh.
  48879. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48880. * @param useInstances - Specifies that instances should be used.
  48881. * @returns - boolean indicating that the submesh is ready or not.
  48882. */
  48883. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48884. /**
  48885. * Specifies if the material uses metallic roughness workflow.
  48886. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48887. */
  48888. isMetallicWorkflow(): boolean;
  48889. private _prepareEffect;
  48890. private _prepareDefines;
  48891. /**
  48892. * Force shader compilation
  48893. */
  48894. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48895. clipPlane: boolean;
  48896. }>): void;
  48897. /**
  48898. * Initializes the uniform buffer layout for the shader.
  48899. */
  48900. buildUniformLayout(): void;
  48901. /**
  48902. * Unbinds the material from the mesh
  48903. */
  48904. unbind(): void;
  48905. /**
  48906. * Binds the submesh data.
  48907. * @param world - The world matrix.
  48908. * @param mesh - The BJS mesh.
  48909. * @param subMesh - A submesh of the BJS mesh.
  48910. */
  48911. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48912. /**
  48913. * Returns the animatable textures.
  48914. * @returns - Array of animatable textures.
  48915. */
  48916. getAnimatables(): IAnimatable[];
  48917. /**
  48918. * Returns the texture used for reflections.
  48919. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48920. */
  48921. private _getReflectionTexture;
  48922. /**
  48923. * Returns an array of the actively used textures.
  48924. * @returns - Array of BaseTextures
  48925. */
  48926. getActiveTextures(): BaseTexture[];
  48927. /**
  48928. * Checks to see if a texture is used in the material.
  48929. * @param texture - Base texture to use.
  48930. * @returns - Boolean specifying if a texture is used in the material.
  48931. */
  48932. hasTexture(texture: BaseTexture): boolean;
  48933. /**
  48934. * Disposes the resources of the material.
  48935. * @param forceDisposeEffect - Forces the disposal of effects.
  48936. * @param forceDisposeTextures - Forces the disposal of all textures.
  48937. */
  48938. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48939. }
  48940. }
  48941. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48942. import { Nullable } from "babylonjs/types";
  48943. import { Scene } from "babylonjs/scene";
  48944. import { Color3 } from "babylonjs/Maths/math.color";
  48945. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48946. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48948. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48949. /**
  48950. * The Physically based material of BJS.
  48951. *
  48952. * This offers the main features of a standard PBR material.
  48953. * For more information, please refer to the documentation :
  48954. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48955. */
  48956. export class PBRMaterial extends PBRBaseMaterial {
  48957. /**
  48958. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48959. */
  48960. static readonly PBRMATERIAL_OPAQUE: number;
  48961. /**
  48962. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48963. */
  48964. static readonly PBRMATERIAL_ALPHATEST: number;
  48965. /**
  48966. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48967. */
  48968. static readonly PBRMATERIAL_ALPHABLEND: number;
  48969. /**
  48970. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48971. * They are also discarded below the alpha cutoff threshold to improve performances.
  48972. */
  48973. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48974. /**
  48975. * Defines the default value of how much AO map is occluding the analytical lights
  48976. * (point spot...).
  48977. */
  48978. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48979. /**
  48980. * Intensity of the direct lights e.g. the four lights available in your scene.
  48981. * This impacts both the direct diffuse and specular highlights.
  48982. */
  48983. directIntensity: number;
  48984. /**
  48985. * Intensity of the emissive part of the material.
  48986. * This helps controlling the emissive effect without modifying the emissive color.
  48987. */
  48988. emissiveIntensity: number;
  48989. /**
  48990. * Intensity of the environment e.g. how much the environment will light the object
  48991. * either through harmonics for rough material or through the refelction for shiny ones.
  48992. */
  48993. environmentIntensity: number;
  48994. /**
  48995. * This is a special control allowing the reduction of the specular highlights coming from the
  48996. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48997. */
  48998. specularIntensity: number;
  48999. /**
  49000. * Debug Control allowing disabling the bump map on this material.
  49001. */
  49002. disableBumpMap: boolean;
  49003. /**
  49004. * AKA Diffuse Texture in standard nomenclature.
  49005. */
  49006. albedoTexture: BaseTexture;
  49007. /**
  49008. * AKA Occlusion Texture in other nomenclature.
  49009. */
  49010. ambientTexture: BaseTexture;
  49011. /**
  49012. * AKA Occlusion Texture Intensity in other nomenclature.
  49013. */
  49014. ambientTextureStrength: number;
  49015. /**
  49016. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49017. * 1 means it completely occludes it
  49018. * 0 mean it has no impact
  49019. */
  49020. ambientTextureImpactOnAnalyticalLights: number;
  49021. /**
  49022. * Stores the alpha values in a texture.
  49023. */
  49024. opacityTexture: BaseTexture;
  49025. /**
  49026. * Stores the reflection values in a texture.
  49027. */
  49028. reflectionTexture: Nullable<BaseTexture>;
  49029. /**
  49030. * Stores the emissive values in a texture.
  49031. */
  49032. emissiveTexture: BaseTexture;
  49033. /**
  49034. * AKA Specular texture in other nomenclature.
  49035. */
  49036. reflectivityTexture: BaseTexture;
  49037. /**
  49038. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49039. */
  49040. metallicTexture: BaseTexture;
  49041. /**
  49042. * Specifies the metallic scalar of the metallic/roughness workflow.
  49043. * Can also be used to scale the metalness values of the metallic texture.
  49044. */
  49045. metallic: Nullable<number>;
  49046. /**
  49047. * Specifies the roughness scalar of the metallic/roughness workflow.
  49048. * Can also be used to scale the roughness values of the metallic texture.
  49049. */
  49050. roughness: Nullable<number>;
  49051. /**
  49052. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49053. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49054. */
  49055. microSurfaceTexture: BaseTexture;
  49056. /**
  49057. * Stores surface normal data used to displace a mesh in a texture.
  49058. */
  49059. bumpTexture: BaseTexture;
  49060. /**
  49061. * Stores the pre-calculated light information of a mesh in a texture.
  49062. */
  49063. lightmapTexture: BaseTexture;
  49064. /**
  49065. * Stores the refracted light information in a texture.
  49066. */
  49067. refractionTexture: Nullable<BaseTexture>;
  49068. /**
  49069. * The color of a material in ambient lighting.
  49070. */
  49071. ambientColor: Color3;
  49072. /**
  49073. * AKA Diffuse Color in other nomenclature.
  49074. */
  49075. albedoColor: Color3;
  49076. /**
  49077. * AKA Specular Color in other nomenclature.
  49078. */
  49079. reflectivityColor: Color3;
  49080. /**
  49081. * The color reflected from the material.
  49082. */
  49083. reflectionColor: Color3;
  49084. /**
  49085. * The color emitted from the material.
  49086. */
  49087. emissiveColor: Color3;
  49088. /**
  49089. * AKA Glossiness in other nomenclature.
  49090. */
  49091. microSurface: number;
  49092. /**
  49093. * source material index of refraction (IOR)' / 'destination material IOR.
  49094. */
  49095. indexOfRefraction: number;
  49096. /**
  49097. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49098. */
  49099. invertRefractionY: boolean;
  49100. /**
  49101. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49102. * Materials half opaque for instance using refraction could benefit from this control.
  49103. */
  49104. linkRefractionWithTransparency: boolean;
  49105. /**
  49106. * If true, the light map contains occlusion information instead of lighting info.
  49107. */
  49108. useLightmapAsShadowmap: boolean;
  49109. /**
  49110. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49111. */
  49112. useAlphaFromAlbedoTexture: boolean;
  49113. /**
  49114. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49115. */
  49116. forceAlphaTest: boolean;
  49117. /**
  49118. * Defines the alpha limits in alpha test mode.
  49119. */
  49120. alphaCutOff: number;
  49121. /**
  49122. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49123. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49124. */
  49125. useSpecularOverAlpha: boolean;
  49126. /**
  49127. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49128. */
  49129. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49130. /**
  49131. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49132. */
  49133. useRoughnessFromMetallicTextureAlpha: boolean;
  49134. /**
  49135. * Specifies if the metallic texture contains the roughness information in its green channel.
  49136. */
  49137. useRoughnessFromMetallicTextureGreen: boolean;
  49138. /**
  49139. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49140. */
  49141. useMetallnessFromMetallicTextureBlue: boolean;
  49142. /**
  49143. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49144. */
  49145. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49146. /**
  49147. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49148. */
  49149. useAmbientInGrayScale: boolean;
  49150. /**
  49151. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49152. * The material will try to infer what glossiness each pixel should be.
  49153. */
  49154. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49155. /**
  49156. * BJS is using an harcoded light falloff based on a manually sets up range.
  49157. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49158. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49159. */
  49160. /**
  49161. * BJS is using an harcoded light falloff based on a manually sets up range.
  49162. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49163. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49164. */
  49165. usePhysicalLightFalloff: boolean;
  49166. /**
  49167. * In order to support the falloff compatibility with gltf, a special mode has been added
  49168. * to reproduce the gltf light falloff.
  49169. */
  49170. /**
  49171. * In order to support the falloff compatibility with gltf, a special mode has been added
  49172. * to reproduce the gltf light falloff.
  49173. */
  49174. useGLTFLightFalloff: boolean;
  49175. /**
  49176. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49177. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49178. */
  49179. useRadianceOverAlpha: boolean;
  49180. /**
  49181. * Allows using an object space normal map (instead of tangent space).
  49182. */
  49183. useObjectSpaceNormalMap: boolean;
  49184. /**
  49185. * Allows using the bump map in parallax mode.
  49186. */
  49187. useParallax: boolean;
  49188. /**
  49189. * Allows using the bump map in parallax occlusion mode.
  49190. */
  49191. useParallaxOcclusion: boolean;
  49192. /**
  49193. * Controls the scale bias of the parallax mode.
  49194. */
  49195. parallaxScaleBias: number;
  49196. /**
  49197. * If sets to true, disables all the lights affecting the material.
  49198. */
  49199. disableLighting: boolean;
  49200. /**
  49201. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49202. */
  49203. forceIrradianceInFragment: boolean;
  49204. /**
  49205. * Number of Simultaneous lights allowed on the material.
  49206. */
  49207. maxSimultaneousLights: number;
  49208. /**
  49209. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49210. */
  49211. invertNormalMapX: boolean;
  49212. /**
  49213. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49214. */
  49215. invertNormalMapY: boolean;
  49216. /**
  49217. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49218. */
  49219. twoSidedLighting: boolean;
  49220. /**
  49221. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49222. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49223. */
  49224. useAlphaFresnel: boolean;
  49225. /**
  49226. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49227. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49228. */
  49229. useLinearAlphaFresnel: boolean;
  49230. /**
  49231. * Let user defines the brdf lookup texture used for IBL.
  49232. * A default 8bit version is embedded but you could point at :
  49233. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49234. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49235. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49236. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49237. */
  49238. environmentBRDFTexture: Nullable<BaseTexture>;
  49239. /**
  49240. * Force normal to face away from face.
  49241. */
  49242. forceNormalForward: boolean;
  49243. /**
  49244. * Enables specular anti aliasing in the PBR shader.
  49245. * It will both interacts on the Geometry for analytical and IBL lighting.
  49246. * It also prefilter the roughness map based on the bump values.
  49247. */
  49248. enableSpecularAntiAliasing: boolean;
  49249. /**
  49250. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49251. * makes the reflect vector face the model (under horizon).
  49252. */
  49253. useHorizonOcclusion: boolean;
  49254. /**
  49255. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49256. * too much the area relying on ambient texture to define their ambient occlusion.
  49257. */
  49258. useRadianceOcclusion: boolean;
  49259. /**
  49260. * If set to true, no lighting calculations will be applied.
  49261. */
  49262. unlit: boolean;
  49263. /**
  49264. * Gets the image processing configuration used either in this material.
  49265. */
  49266. /**
  49267. * Sets the Default image processing configuration used either in the this material.
  49268. *
  49269. * If sets to null, the scene one is in use.
  49270. */
  49271. imageProcessingConfiguration: ImageProcessingConfiguration;
  49272. /**
  49273. * Gets wether the color curves effect is enabled.
  49274. */
  49275. /**
  49276. * Sets wether the color curves effect is enabled.
  49277. */
  49278. cameraColorCurvesEnabled: boolean;
  49279. /**
  49280. * Gets wether the color grading effect is enabled.
  49281. */
  49282. /**
  49283. * Gets wether the color grading effect is enabled.
  49284. */
  49285. cameraColorGradingEnabled: boolean;
  49286. /**
  49287. * Gets wether tonemapping is enabled or not.
  49288. */
  49289. /**
  49290. * Sets wether tonemapping is enabled or not
  49291. */
  49292. cameraToneMappingEnabled: boolean;
  49293. /**
  49294. * The camera exposure used on this material.
  49295. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49296. * This corresponds to a photographic exposure.
  49297. */
  49298. /**
  49299. * The camera exposure used on this material.
  49300. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49301. * This corresponds to a photographic exposure.
  49302. */
  49303. cameraExposure: number;
  49304. /**
  49305. * Gets The camera contrast used on this material.
  49306. */
  49307. /**
  49308. * Sets The camera contrast used on this material.
  49309. */
  49310. cameraContrast: number;
  49311. /**
  49312. * Gets the Color Grading 2D Lookup Texture.
  49313. */
  49314. /**
  49315. * Sets the Color Grading 2D Lookup Texture.
  49316. */
  49317. cameraColorGradingTexture: Nullable<BaseTexture>;
  49318. /**
  49319. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49320. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49321. * 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;
  49322. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49323. */
  49324. /**
  49325. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49326. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49327. * 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;
  49328. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49329. */
  49330. cameraColorCurves: Nullable<ColorCurves>;
  49331. /**
  49332. * Instantiates a new PBRMaterial instance.
  49333. *
  49334. * @param name The material name
  49335. * @param scene The scene the material will be use in.
  49336. */
  49337. constructor(name: string, scene: Scene);
  49338. /**
  49339. * Returns the name of this material class.
  49340. */
  49341. getClassName(): string;
  49342. /**
  49343. * Makes a duplicate of the current material.
  49344. * @param name - name to use for the new material.
  49345. */
  49346. clone(name: string): PBRMaterial;
  49347. /**
  49348. * Serializes this PBR Material.
  49349. * @returns - An object with the serialized material.
  49350. */
  49351. serialize(): any;
  49352. /**
  49353. * Parses a PBR Material from a serialized object.
  49354. * @param source - Serialized object.
  49355. * @param scene - BJS scene instance.
  49356. * @param rootUrl - url for the scene object
  49357. * @returns - PBRMaterial
  49358. */
  49359. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49360. }
  49361. }
  49362. declare module "babylonjs/Misc/dds" {
  49363. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49364. import { Engine } from "babylonjs/Engines/engine";
  49365. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49366. import { Nullable } from "babylonjs/types";
  49367. import { Scene } from "babylonjs/scene";
  49368. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49369. /**
  49370. * Direct draw surface info
  49371. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49372. */
  49373. export interface DDSInfo {
  49374. /**
  49375. * Width of the texture
  49376. */
  49377. width: number;
  49378. /**
  49379. * Width of the texture
  49380. */
  49381. height: number;
  49382. /**
  49383. * Number of Mipmaps for the texture
  49384. * @see https://en.wikipedia.org/wiki/Mipmap
  49385. */
  49386. mipmapCount: number;
  49387. /**
  49388. * If the textures format is a known fourCC format
  49389. * @see https://www.fourcc.org/
  49390. */
  49391. isFourCC: boolean;
  49392. /**
  49393. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49394. */
  49395. isRGB: boolean;
  49396. /**
  49397. * If the texture is a lumincance format
  49398. */
  49399. isLuminance: boolean;
  49400. /**
  49401. * If this is a cube texture
  49402. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49403. */
  49404. isCube: boolean;
  49405. /**
  49406. * If the texture is a compressed format eg. FOURCC_DXT1
  49407. */
  49408. isCompressed: boolean;
  49409. /**
  49410. * The dxgiFormat of the texture
  49411. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49412. */
  49413. dxgiFormat: number;
  49414. /**
  49415. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49416. */
  49417. textureType: number;
  49418. /**
  49419. * Sphericle polynomial created for the dds texture
  49420. */
  49421. sphericalPolynomial?: SphericalPolynomial;
  49422. }
  49423. /**
  49424. * Class used to provide DDS decompression tools
  49425. */
  49426. export class DDSTools {
  49427. /**
  49428. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49429. */
  49430. static StoreLODInAlphaChannel: boolean;
  49431. /**
  49432. * Gets DDS information from an array buffer
  49433. * @param arrayBuffer defines the array buffer to read data from
  49434. * @returns the DDS information
  49435. */
  49436. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49437. private static _FloatView;
  49438. private static _Int32View;
  49439. private static _ToHalfFloat;
  49440. private static _FromHalfFloat;
  49441. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49442. private static _GetHalfFloatRGBAArrayBuffer;
  49443. private static _GetFloatRGBAArrayBuffer;
  49444. private static _GetFloatAsUIntRGBAArrayBuffer;
  49445. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49446. private static _GetRGBAArrayBuffer;
  49447. private static _ExtractLongWordOrder;
  49448. private static _GetRGBArrayBuffer;
  49449. private static _GetLuminanceArrayBuffer;
  49450. /**
  49451. * Uploads DDS Levels to a Babylon Texture
  49452. * @hidden
  49453. */
  49454. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49455. }
  49456. module "babylonjs/Engines/engine" {
  49457. interface Engine {
  49458. /**
  49459. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49460. * @param rootUrl defines the url where the file to load is located
  49461. * @param scene defines the current scene
  49462. * @param lodScale defines scale to apply to the mip map selection
  49463. * @param lodOffset defines offset to apply to the mip map selection
  49464. * @param onLoad defines an optional callback raised when the texture is loaded
  49465. * @param onError defines an optional callback raised if there is an issue to load the texture
  49466. * @param format defines the format of the data
  49467. * @param forcedExtension defines the extension to use to pick the right loader
  49468. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49469. * @returns the cube texture as an InternalTexture
  49470. */
  49471. 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;
  49472. }
  49473. }
  49474. }
  49475. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49476. import { Nullable } from "babylonjs/types";
  49477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49478. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49479. /**
  49480. * Implementation of the DDS Texture Loader.
  49481. * @hidden
  49482. */
  49483. export class _DDSTextureLoader implements IInternalTextureLoader {
  49484. /**
  49485. * Defines wether the loader supports cascade loading the different faces.
  49486. */
  49487. readonly supportCascades: boolean;
  49488. /**
  49489. * This returns if the loader support the current file information.
  49490. * @param extension defines the file extension of the file being loaded
  49491. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49492. * @param fallback defines the fallback internal texture if any
  49493. * @param isBase64 defines whether the texture is encoded as a base64
  49494. * @param isBuffer defines whether the texture data are stored as a buffer
  49495. * @returns true if the loader can load the specified file
  49496. */
  49497. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49498. /**
  49499. * Transform the url before loading if required.
  49500. * @param rootUrl the url of the texture
  49501. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49502. * @returns the transformed texture
  49503. */
  49504. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49505. /**
  49506. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49507. * @param rootUrl the url of the texture
  49508. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49509. * @returns the fallback texture
  49510. */
  49511. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49512. /**
  49513. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49514. * @param data contains the texture data
  49515. * @param texture defines the BabylonJS internal texture
  49516. * @param createPolynomials will be true if polynomials have been requested
  49517. * @param onLoad defines the callback to trigger once the texture is ready
  49518. * @param onError defines the callback to trigger in case of error
  49519. */
  49520. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49521. /**
  49522. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49523. * @param data contains the texture data
  49524. * @param texture defines the BabylonJS internal texture
  49525. * @param callback defines the method to call once ready to upload
  49526. */
  49527. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49528. }
  49529. }
  49530. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49531. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49532. /** @hidden */
  49533. export var rgbdEncodePixelShader: {
  49534. name: string;
  49535. shader: string;
  49536. };
  49537. }
  49538. declare module "babylonjs/Misc/environmentTextureTools" {
  49539. import { Nullable } from "babylonjs/types";
  49540. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49541. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49542. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49543. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49544. import "babylonjs/Shaders/rgbdEncode.fragment";
  49545. import "babylonjs/Shaders/rgbdDecode.fragment";
  49546. /**
  49547. * Raw texture data and descriptor sufficient for WebGL texture upload
  49548. */
  49549. export interface EnvironmentTextureInfo {
  49550. /**
  49551. * Version of the environment map
  49552. */
  49553. version: number;
  49554. /**
  49555. * Width of image
  49556. */
  49557. width: number;
  49558. /**
  49559. * Irradiance information stored in the file.
  49560. */
  49561. irradiance: any;
  49562. /**
  49563. * Specular information stored in the file.
  49564. */
  49565. specular: any;
  49566. }
  49567. /**
  49568. * Sets of helpers addressing the serialization and deserialization of environment texture
  49569. * stored in a BabylonJS env file.
  49570. * Those files are usually stored as .env files.
  49571. */
  49572. export class EnvironmentTextureTools {
  49573. /**
  49574. * Magic number identifying the env file.
  49575. */
  49576. private static _MagicBytes;
  49577. /**
  49578. * Gets the environment info from an env file.
  49579. * @param data The array buffer containing the .env bytes.
  49580. * @returns the environment file info (the json header) if successfully parsed.
  49581. */
  49582. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49583. /**
  49584. * Creates an environment texture from a loaded cube texture.
  49585. * @param texture defines the cube texture to convert in env file
  49586. * @return a promise containing the environment data if succesfull.
  49587. */
  49588. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49589. /**
  49590. * Creates a JSON representation of the spherical data.
  49591. * @param texture defines the texture containing the polynomials
  49592. * @return the JSON representation of the spherical info
  49593. */
  49594. private static _CreateEnvTextureIrradiance;
  49595. /**
  49596. * Uploads the texture info contained in the env file to the GPU.
  49597. * @param texture defines the internal texture to upload to
  49598. * @param arrayBuffer defines the buffer cotaining the data to load
  49599. * @param info defines the texture info retrieved through the GetEnvInfo method
  49600. * @returns a promise
  49601. */
  49602. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49603. /**
  49604. * Uploads the levels of image data to the GPU.
  49605. * @param texture defines the internal texture to upload to
  49606. * @param imageData defines the array buffer views of image data [mipmap][face]
  49607. * @returns a promise
  49608. */
  49609. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49610. /**
  49611. * Uploads spherical polynomials information to the texture.
  49612. * @param texture defines the texture we are trying to upload the information to
  49613. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49614. */
  49615. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49616. /** @hidden */
  49617. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49618. }
  49619. }
  49620. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49621. import { Nullable } from "babylonjs/types";
  49622. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49623. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49624. /**
  49625. * Implementation of the ENV Texture Loader.
  49626. * @hidden
  49627. */
  49628. export class _ENVTextureLoader implements IInternalTextureLoader {
  49629. /**
  49630. * Defines wether the loader supports cascade loading the different faces.
  49631. */
  49632. readonly supportCascades: boolean;
  49633. /**
  49634. * This returns if the loader support the current file information.
  49635. * @param extension defines the file extension of the file being loaded
  49636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49637. * @param fallback defines the fallback internal texture if any
  49638. * @param isBase64 defines whether the texture is encoded as a base64
  49639. * @param isBuffer defines whether the texture data are stored as a buffer
  49640. * @returns true if the loader can load the specified file
  49641. */
  49642. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49643. /**
  49644. * Transform the url before loading if required.
  49645. * @param rootUrl the url of the texture
  49646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49647. * @returns the transformed texture
  49648. */
  49649. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49650. /**
  49651. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49652. * @param rootUrl the url of the texture
  49653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49654. * @returns the fallback texture
  49655. */
  49656. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49657. /**
  49658. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49659. * @param data contains the texture data
  49660. * @param texture defines the BabylonJS internal texture
  49661. * @param createPolynomials will be true if polynomials have been requested
  49662. * @param onLoad defines the callback to trigger once the texture is ready
  49663. * @param onError defines the callback to trigger in case of error
  49664. */
  49665. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49666. /**
  49667. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49668. * @param data contains the texture data
  49669. * @param texture defines the BabylonJS internal texture
  49670. * @param callback defines the method to call once ready to upload
  49671. */
  49672. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49673. }
  49674. }
  49675. declare module "babylonjs/Misc/khronosTextureContainer" {
  49676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49677. /**
  49678. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49679. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49680. */
  49681. export class KhronosTextureContainer {
  49682. /** contents of the KTX container file */
  49683. arrayBuffer: any;
  49684. private static HEADER_LEN;
  49685. private static COMPRESSED_2D;
  49686. private static COMPRESSED_3D;
  49687. private static TEX_2D;
  49688. private static TEX_3D;
  49689. /**
  49690. * Gets the openGL type
  49691. */
  49692. glType: number;
  49693. /**
  49694. * Gets the openGL type size
  49695. */
  49696. glTypeSize: number;
  49697. /**
  49698. * Gets the openGL format
  49699. */
  49700. glFormat: number;
  49701. /**
  49702. * Gets the openGL internal format
  49703. */
  49704. glInternalFormat: number;
  49705. /**
  49706. * Gets the base internal format
  49707. */
  49708. glBaseInternalFormat: number;
  49709. /**
  49710. * Gets image width in pixel
  49711. */
  49712. pixelWidth: number;
  49713. /**
  49714. * Gets image height in pixel
  49715. */
  49716. pixelHeight: number;
  49717. /**
  49718. * Gets image depth in pixels
  49719. */
  49720. pixelDepth: number;
  49721. /**
  49722. * Gets the number of array elements
  49723. */
  49724. numberOfArrayElements: number;
  49725. /**
  49726. * Gets the number of faces
  49727. */
  49728. numberOfFaces: number;
  49729. /**
  49730. * Gets the number of mipmap levels
  49731. */
  49732. numberOfMipmapLevels: number;
  49733. /**
  49734. * Gets the bytes of key value data
  49735. */
  49736. bytesOfKeyValueData: number;
  49737. /**
  49738. * Gets the load type
  49739. */
  49740. loadType: number;
  49741. /**
  49742. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49743. */
  49744. isInvalid: boolean;
  49745. /**
  49746. * Creates a new KhronosTextureContainer
  49747. * @param arrayBuffer contents of the KTX container file
  49748. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49749. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49750. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49751. */
  49752. constructor(
  49753. /** contents of the KTX container file */
  49754. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49755. /**
  49756. * Uploads KTX content to a Babylon Texture.
  49757. * It is assumed that the texture has already been created & is currently bound
  49758. * @hidden
  49759. */
  49760. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49761. private _upload2DCompressedLevels;
  49762. }
  49763. }
  49764. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49765. import { Nullable } from "babylonjs/types";
  49766. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49767. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49768. /**
  49769. * Implementation of the KTX Texture Loader.
  49770. * @hidden
  49771. */
  49772. export class _KTXTextureLoader implements IInternalTextureLoader {
  49773. /**
  49774. * Defines wether the loader supports cascade loading the different faces.
  49775. */
  49776. readonly supportCascades: boolean;
  49777. /**
  49778. * This returns if the loader support the current file information.
  49779. * @param extension defines the file extension of the file being loaded
  49780. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49781. * @param fallback defines the fallback internal texture if any
  49782. * @param isBase64 defines whether the texture is encoded as a base64
  49783. * @param isBuffer defines whether the texture data are stored as a buffer
  49784. * @returns true if the loader can load the specified file
  49785. */
  49786. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49787. /**
  49788. * Transform the url before loading if required.
  49789. * @param rootUrl the url of the texture
  49790. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49791. * @returns the transformed texture
  49792. */
  49793. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49794. /**
  49795. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49796. * @param rootUrl the url of the texture
  49797. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49798. * @returns the fallback texture
  49799. */
  49800. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49801. /**
  49802. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49803. * @param data contains the texture data
  49804. * @param texture defines the BabylonJS internal texture
  49805. * @param createPolynomials will be true if polynomials have been requested
  49806. * @param onLoad defines the callback to trigger once the texture is ready
  49807. * @param onError defines the callback to trigger in case of error
  49808. */
  49809. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49810. /**
  49811. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49812. * @param data contains the texture data
  49813. * @param texture defines the BabylonJS internal texture
  49814. * @param callback defines the method to call once ready to upload
  49815. */
  49816. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49817. }
  49818. }
  49819. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49820. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49821. import { Scene } from "babylonjs/scene";
  49822. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49823. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49824. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49825. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49826. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49827. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49829. /**
  49830. * Options for the default xr helper
  49831. */
  49832. export class WebXRDefaultExperienceOptions {
  49833. /**
  49834. * Floor meshes that should be used for teleporting
  49835. */
  49836. floorMeshes: Array<AbstractMesh>;
  49837. }
  49838. /**
  49839. * Default experience which provides a similar setup to the previous webVRExperience
  49840. */
  49841. export class WebXRDefaultExperience {
  49842. /**
  49843. * Base experience
  49844. */
  49845. baseExperience: WebXRExperienceHelper;
  49846. /**
  49847. * Input experience extension
  49848. */
  49849. input: WebXRInput;
  49850. /**
  49851. * Loads the controller models
  49852. */
  49853. controllerModelLoader: WebXRControllerModelLoader;
  49854. /**
  49855. * Enables laser pointer and selection
  49856. */
  49857. pointerSelection: WebXRControllerPointerSelection;
  49858. /**
  49859. * Enables teleportation
  49860. */
  49861. teleportation: WebXRControllerTeleportation;
  49862. /**
  49863. * Enables ui for enetering/exiting xr
  49864. */
  49865. enterExitUI: WebXREnterExitUI;
  49866. /**
  49867. * Default output canvas xr should render to
  49868. */
  49869. outputCanvas: WebXRManagedOutputCanvas;
  49870. /**
  49871. * Creates the default xr experience
  49872. * @param scene scene
  49873. * @param options options for basic configuration
  49874. * @returns resulting WebXRDefaultExperience
  49875. */
  49876. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49877. private constructor();
  49878. /**
  49879. * DIsposes of the experience helper
  49880. */
  49881. dispose(): void;
  49882. }
  49883. }
  49884. declare module "babylonjs/Helpers/sceneHelpers" {
  49885. import { Nullable } from "babylonjs/types";
  49886. import { Mesh } from "babylonjs/Meshes/mesh";
  49887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49888. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49889. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49890. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49891. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49892. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49893. import "babylonjs/Meshes/Builders/boxBuilder";
  49894. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49895. /** @hidden */
  49896. export var _forceSceneHelpersToBundle: boolean;
  49897. module "babylonjs/scene" {
  49898. interface Scene {
  49899. /**
  49900. * Creates a default light for the scene.
  49901. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49902. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49903. */
  49904. createDefaultLight(replace?: boolean): void;
  49905. /**
  49906. * Creates a default camera for the scene.
  49907. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49908. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49909. * @param replace has default false, when true replaces the active camera in the scene
  49910. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49911. */
  49912. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49913. /**
  49914. * Creates a default camera and a default light.
  49915. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49916. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49917. * @param replace has the default false, when true replaces the active camera/light in the scene
  49918. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49919. */
  49920. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49921. /**
  49922. * Creates a new sky box
  49923. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49924. * @param environmentTexture defines the texture to use as environment texture
  49925. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49926. * @param scale defines the overall scale of the skybox
  49927. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49928. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49929. * @returns a new mesh holding the sky box
  49930. */
  49931. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49932. /**
  49933. * Creates a new environment
  49934. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49935. * @param options defines the options you can use to configure the environment
  49936. * @returns the new EnvironmentHelper
  49937. */
  49938. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49939. /**
  49940. * Creates a new VREXperienceHelper
  49941. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49942. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49943. * @returns a new VREXperienceHelper
  49944. */
  49945. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49946. /**
  49947. * Creates a new WebXRDefaultExperience
  49948. * @see http://doc.babylonjs.com/how_to/webxr
  49949. * @param options experience options
  49950. * @returns a promise for a new WebXRDefaultExperience
  49951. */
  49952. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49953. }
  49954. }
  49955. }
  49956. declare module "babylonjs/Maths/math.vertexFormat" {
  49957. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49958. /**
  49959. * Contains position and normal vectors for a vertex
  49960. */
  49961. export class PositionNormalVertex {
  49962. /** the position of the vertex (defaut: 0,0,0) */
  49963. position: Vector3;
  49964. /** the normal of the vertex (defaut: 0,1,0) */
  49965. normal: Vector3;
  49966. /**
  49967. * Creates a PositionNormalVertex
  49968. * @param position the position of the vertex (defaut: 0,0,0)
  49969. * @param normal the normal of the vertex (defaut: 0,1,0)
  49970. */
  49971. constructor(
  49972. /** the position of the vertex (defaut: 0,0,0) */
  49973. position?: Vector3,
  49974. /** the normal of the vertex (defaut: 0,1,0) */
  49975. normal?: Vector3);
  49976. /**
  49977. * Clones the PositionNormalVertex
  49978. * @returns the cloned PositionNormalVertex
  49979. */
  49980. clone(): PositionNormalVertex;
  49981. }
  49982. /**
  49983. * Contains position, normal and uv vectors for a vertex
  49984. */
  49985. export class PositionNormalTextureVertex {
  49986. /** the position of the vertex (defaut: 0,0,0) */
  49987. position: Vector3;
  49988. /** the normal of the vertex (defaut: 0,1,0) */
  49989. normal: Vector3;
  49990. /** the uv of the vertex (default: 0,0) */
  49991. uv: Vector2;
  49992. /**
  49993. * Creates a PositionNormalTextureVertex
  49994. * @param position the position of the vertex (defaut: 0,0,0)
  49995. * @param normal the normal of the vertex (defaut: 0,1,0)
  49996. * @param uv the uv of the vertex (default: 0,0)
  49997. */
  49998. constructor(
  49999. /** the position of the vertex (defaut: 0,0,0) */
  50000. position?: Vector3,
  50001. /** the normal of the vertex (defaut: 0,1,0) */
  50002. normal?: Vector3,
  50003. /** the uv of the vertex (default: 0,0) */
  50004. uv?: Vector2);
  50005. /**
  50006. * Clones the PositionNormalTextureVertex
  50007. * @returns the cloned PositionNormalTextureVertex
  50008. */
  50009. clone(): PositionNormalTextureVertex;
  50010. }
  50011. }
  50012. declare module "babylonjs/Maths/math" {
  50013. export * from "babylonjs/Maths/math.axis";
  50014. export * from "babylonjs/Maths/math.color";
  50015. export * from "babylonjs/Maths/math.constants";
  50016. export * from "babylonjs/Maths/math.frustum";
  50017. export * from "babylonjs/Maths/math.path";
  50018. export * from "babylonjs/Maths/math.plane";
  50019. export * from "babylonjs/Maths/math.size";
  50020. export * from "babylonjs/Maths/math.vector";
  50021. export * from "babylonjs/Maths/math.vertexFormat";
  50022. export * from "babylonjs/Maths/math.viewport";
  50023. }
  50024. declare module "babylonjs/Helpers/videoDome" {
  50025. import { Scene } from "babylonjs/scene";
  50026. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50027. import { Mesh } from "babylonjs/Meshes/mesh";
  50028. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50029. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50030. import "babylonjs/Meshes/Builders/sphereBuilder";
  50031. /**
  50032. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50033. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50034. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50035. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50036. */
  50037. export class VideoDome extends TransformNode {
  50038. /**
  50039. * Define the video source as a Monoscopic panoramic 360 video.
  50040. */
  50041. static readonly MODE_MONOSCOPIC: number;
  50042. /**
  50043. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50044. */
  50045. static readonly MODE_TOPBOTTOM: number;
  50046. /**
  50047. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50048. */
  50049. static readonly MODE_SIDEBYSIDE: number;
  50050. private _halfDome;
  50051. private _useDirectMapping;
  50052. /**
  50053. * The video texture being displayed on the sphere
  50054. */
  50055. protected _videoTexture: VideoTexture;
  50056. /**
  50057. * Gets the video texture being displayed on the sphere
  50058. */
  50059. readonly videoTexture: VideoTexture;
  50060. /**
  50061. * The skybox material
  50062. */
  50063. protected _material: BackgroundMaterial;
  50064. /**
  50065. * The surface used for the skybox
  50066. */
  50067. protected _mesh: Mesh;
  50068. /**
  50069. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50070. */
  50071. private _halfDomeMask;
  50072. /**
  50073. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50074. * Also see the options.resolution property.
  50075. */
  50076. fovMultiplier: number;
  50077. private _videoMode;
  50078. /**
  50079. * Gets or set the current video mode for the video. It can be:
  50080. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50081. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50082. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50083. */
  50084. videoMode: number;
  50085. /**
  50086. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50087. *
  50088. */
  50089. /**
  50090. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50091. */
  50092. halfDome: boolean;
  50093. /**
  50094. * Oberserver used in Stereoscopic VR Mode.
  50095. */
  50096. private _onBeforeCameraRenderObserver;
  50097. /**
  50098. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50099. * @param name Element's name, child elements will append suffixes for their own names.
  50100. * @param urlsOrVideo defines the url(s) or the video element to use
  50101. * @param options An object containing optional or exposed sub element properties
  50102. */
  50103. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50104. resolution?: number;
  50105. clickToPlay?: boolean;
  50106. autoPlay?: boolean;
  50107. loop?: boolean;
  50108. size?: number;
  50109. poster?: string;
  50110. faceForward?: boolean;
  50111. useDirectMapping?: boolean;
  50112. halfDomeMode?: boolean;
  50113. }, scene: Scene);
  50114. private _changeVideoMode;
  50115. /**
  50116. * Releases resources associated with this node.
  50117. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50118. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50119. */
  50120. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50121. }
  50122. }
  50123. declare module "babylonjs/Helpers/index" {
  50124. export * from "babylonjs/Helpers/environmentHelper";
  50125. export * from "babylonjs/Helpers/photoDome";
  50126. export * from "babylonjs/Helpers/sceneHelpers";
  50127. export * from "babylonjs/Helpers/videoDome";
  50128. }
  50129. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50130. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50131. import { IDisposable } from "babylonjs/scene";
  50132. import { Engine } from "babylonjs/Engines/engine";
  50133. /**
  50134. * This class can be used to get instrumentation data from a Babylon engine
  50135. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50136. */
  50137. export class EngineInstrumentation implements IDisposable {
  50138. /**
  50139. * Define the instrumented engine.
  50140. */
  50141. engine: Engine;
  50142. private _captureGPUFrameTime;
  50143. private _gpuFrameTimeToken;
  50144. private _gpuFrameTime;
  50145. private _captureShaderCompilationTime;
  50146. private _shaderCompilationTime;
  50147. private _onBeginFrameObserver;
  50148. private _onEndFrameObserver;
  50149. private _onBeforeShaderCompilationObserver;
  50150. private _onAfterShaderCompilationObserver;
  50151. /**
  50152. * Gets the perf counter used for GPU frame time
  50153. */
  50154. readonly gpuFrameTimeCounter: PerfCounter;
  50155. /**
  50156. * Gets the GPU frame time capture status
  50157. */
  50158. /**
  50159. * Enable or disable the GPU frame time capture
  50160. */
  50161. captureGPUFrameTime: boolean;
  50162. /**
  50163. * Gets the perf counter used for shader compilation time
  50164. */
  50165. readonly shaderCompilationTimeCounter: PerfCounter;
  50166. /**
  50167. * Gets the shader compilation time capture status
  50168. */
  50169. /**
  50170. * Enable or disable the shader compilation time capture
  50171. */
  50172. captureShaderCompilationTime: boolean;
  50173. /**
  50174. * Instantiates a new engine instrumentation.
  50175. * This class can be used to get instrumentation data from a Babylon engine
  50176. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50177. * @param engine Defines the engine to instrument
  50178. */
  50179. constructor(
  50180. /**
  50181. * Define the instrumented engine.
  50182. */
  50183. engine: Engine);
  50184. /**
  50185. * Dispose and release associated resources.
  50186. */
  50187. dispose(): void;
  50188. }
  50189. }
  50190. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50191. import { Scene, IDisposable } from "babylonjs/scene";
  50192. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50193. /**
  50194. * This class can be used to get instrumentation data from a Babylon engine
  50195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50196. */
  50197. export class SceneInstrumentation implements IDisposable {
  50198. /**
  50199. * Defines the scene to instrument
  50200. */
  50201. scene: Scene;
  50202. private _captureActiveMeshesEvaluationTime;
  50203. private _activeMeshesEvaluationTime;
  50204. private _captureRenderTargetsRenderTime;
  50205. private _renderTargetsRenderTime;
  50206. private _captureFrameTime;
  50207. private _frameTime;
  50208. private _captureRenderTime;
  50209. private _renderTime;
  50210. private _captureInterFrameTime;
  50211. private _interFrameTime;
  50212. private _captureParticlesRenderTime;
  50213. private _particlesRenderTime;
  50214. private _captureSpritesRenderTime;
  50215. private _spritesRenderTime;
  50216. private _capturePhysicsTime;
  50217. private _physicsTime;
  50218. private _captureAnimationsTime;
  50219. private _animationsTime;
  50220. private _captureCameraRenderTime;
  50221. private _cameraRenderTime;
  50222. private _onBeforeActiveMeshesEvaluationObserver;
  50223. private _onAfterActiveMeshesEvaluationObserver;
  50224. private _onBeforeRenderTargetsRenderObserver;
  50225. private _onAfterRenderTargetsRenderObserver;
  50226. private _onAfterRenderObserver;
  50227. private _onBeforeDrawPhaseObserver;
  50228. private _onAfterDrawPhaseObserver;
  50229. private _onBeforeAnimationsObserver;
  50230. private _onBeforeParticlesRenderingObserver;
  50231. private _onAfterParticlesRenderingObserver;
  50232. private _onBeforeSpritesRenderingObserver;
  50233. private _onAfterSpritesRenderingObserver;
  50234. private _onBeforePhysicsObserver;
  50235. private _onAfterPhysicsObserver;
  50236. private _onAfterAnimationsObserver;
  50237. private _onBeforeCameraRenderObserver;
  50238. private _onAfterCameraRenderObserver;
  50239. /**
  50240. * Gets the perf counter used for active meshes evaluation time
  50241. */
  50242. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50243. /**
  50244. * Gets the active meshes evaluation time capture status
  50245. */
  50246. /**
  50247. * Enable or disable the active meshes evaluation time capture
  50248. */
  50249. captureActiveMeshesEvaluationTime: boolean;
  50250. /**
  50251. * Gets the perf counter used for render targets render time
  50252. */
  50253. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50254. /**
  50255. * Gets the render targets render time capture status
  50256. */
  50257. /**
  50258. * Enable or disable the render targets render time capture
  50259. */
  50260. captureRenderTargetsRenderTime: boolean;
  50261. /**
  50262. * Gets the perf counter used for particles render time
  50263. */
  50264. readonly particlesRenderTimeCounter: PerfCounter;
  50265. /**
  50266. * Gets the particles render time capture status
  50267. */
  50268. /**
  50269. * Enable or disable the particles render time capture
  50270. */
  50271. captureParticlesRenderTime: boolean;
  50272. /**
  50273. * Gets the perf counter used for sprites render time
  50274. */
  50275. readonly spritesRenderTimeCounter: PerfCounter;
  50276. /**
  50277. * Gets the sprites render time capture status
  50278. */
  50279. /**
  50280. * Enable or disable the sprites render time capture
  50281. */
  50282. captureSpritesRenderTime: boolean;
  50283. /**
  50284. * Gets the perf counter used for physics time
  50285. */
  50286. readonly physicsTimeCounter: PerfCounter;
  50287. /**
  50288. * Gets the physics time capture status
  50289. */
  50290. /**
  50291. * Enable or disable the physics time capture
  50292. */
  50293. capturePhysicsTime: boolean;
  50294. /**
  50295. * Gets the perf counter used for animations time
  50296. */
  50297. readonly animationsTimeCounter: PerfCounter;
  50298. /**
  50299. * Gets the animations time capture status
  50300. */
  50301. /**
  50302. * Enable or disable the animations time capture
  50303. */
  50304. captureAnimationsTime: boolean;
  50305. /**
  50306. * Gets the perf counter used for frame time capture
  50307. */
  50308. readonly frameTimeCounter: PerfCounter;
  50309. /**
  50310. * Gets the frame time capture status
  50311. */
  50312. /**
  50313. * Enable or disable the frame time capture
  50314. */
  50315. captureFrameTime: boolean;
  50316. /**
  50317. * Gets the perf counter used for inter-frames time capture
  50318. */
  50319. readonly interFrameTimeCounter: PerfCounter;
  50320. /**
  50321. * Gets the inter-frames time capture status
  50322. */
  50323. /**
  50324. * Enable or disable the inter-frames time capture
  50325. */
  50326. captureInterFrameTime: boolean;
  50327. /**
  50328. * Gets the perf counter used for render time capture
  50329. */
  50330. readonly renderTimeCounter: PerfCounter;
  50331. /**
  50332. * Gets the render time capture status
  50333. */
  50334. /**
  50335. * Enable or disable the render time capture
  50336. */
  50337. captureRenderTime: boolean;
  50338. /**
  50339. * Gets the perf counter used for camera render time capture
  50340. */
  50341. readonly cameraRenderTimeCounter: PerfCounter;
  50342. /**
  50343. * Gets the camera render time capture status
  50344. */
  50345. /**
  50346. * Enable or disable the camera render time capture
  50347. */
  50348. captureCameraRenderTime: boolean;
  50349. /**
  50350. * Gets the perf counter used for draw calls
  50351. */
  50352. readonly drawCallsCounter: PerfCounter;
  50353. /**
  50354. * Instantiates a new scene instrumentation.
  50355. * This class can be used to get instrumentation data from a Babylon engine
  50356. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50357. * @param scene Defines the scene to instrument
  50358. */
  50359. constructor(
  50360. /**
  50361. * Defines the scene to instrument
  50362. */
  50363. scene: Scene);
  50364. /**
  50365. * Dispose and release associated resources.
  50366. */
  50367. dispose(): void;
  50368. }
  50369. }
  50370. declare module "babylonjs/Instrumentation/index" {
  50371. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50372. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50373. export * from "babylonjs/Instrumentation/timeToken";
  50374. }
  50375. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50376. /** @hidden */
  50377. export var glowMapGenerationPixelShader: {
  50378. name: string;
  50379. shader: string;
  50380. };
  50381. }
  50382. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50383. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50384. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50385. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50386. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50387. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50388. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50389. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50390. /** @hidden */
  50391. export var glowMapGenerationVertexShader: {
  50392. name: string;
  50393. shader: string;
  50394. };
  50395. }
  50396. declare module "babylonjs/Layers/effectLayer" {
  50397. import { Observable } from "babylonjs/Misc/observable";
  50398. import { Nullable } from "babylonjs/types";
  50399. import { Camera } from "babylonjs/Cameras/camera";
  50400. import { Scene } from "babylonjs/scene";
  50401. import { ISize } from "babylonjs/Maths/math.size";
  50402. import { Color4 } from "babylonjs/Maths/math.color";
  50403. import { Engine } from "babylonjs/Engines/engine";
  50404. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50406. import { Mesh } from "babylonjs/Meshes/mesh";
  50407. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50409. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50410. import { Effect } from "babylonjs/Materials/effect";
  50411. import { Material } from "babylonjs/Materials/material";
  50412. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50413. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50414. /**
  50415. * Effect layer options. This helps customizing the behaviour
  50416. * of the effect layer.
  50417. */
  50418. export interface IEffectLayerOptions {
  50419. /**
  50420. * Multiplication factor apply to the canvas size to compute the render target size
  50421. * used to generated the objects (the smaller the faster).
  50422. */
  50423. mainTextureRatio: number;
  50424. /**
  50425. * Enforces a fixed size texture to ensure effect stability across devices.
  50426. */
  50427. mainTextureFixedSize?: number;
  50428. /**
  50429. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50430. */
  50431. alphaBlendingMode: number;
  50432. /**
  50433. * The camera attached to the layer.
  50434. */
  50435. camera: Nullable<Camera>;
  50436. /**
  50437. * The rendering group to draw the layer in.
  50438. */
  50439. renderingGroupId: number;
  50440. }
  50441. /**
  50442. * The effect layer Helps adding post process effect blended with the main pass.
  50443. *
  50444. * This can be for instance use to generate glow or higlight effects on the scene.
  50445. *
  50446. * The effect layer class can not be used directly and is intented to inherited from to be
  50447. * customized per effects.
  50448. */
  50449. export abstract class EffectLayer {
  50450. private _vertexBuffers;
  50451. private _indexBuffer;
  50452. private _cachedDefines;
  50453. private _effectLayerMapGenerationEffect;
  50454. private _effectLayerOptions;
  50455. private _mergeEffect;
  50456. protected _scene: Scene;
  50457. protected _engine: Engine;
  50458. protected _maxSize: number;
  50459. protected _mainTextureDesiredSize: ISize;
  50460. protected _mainTexture: RenderTargetTexture;
  50461. protected _shouldRender: boolean;
  50462. protected _postProcesses: PostProcess[];
  50463. protected _textures: BaseTexture[];
  50464. protected _emissiveTextureAndColor: {
  50465. texture: Nullable<BaseTexture>;
  50466. color: Color4;
  50467. };
  50468. /**
  50469. * The name of the layer
  50470. */
  50471. name: string;
  50472. /**
  50473. * The clear color of the texture used to generate the glow map.
  50474. */
  50475. neutralColor: Color4;
  50476. /**
  50477. * Specifies wether the highlight layer is enabled or not.
  50478. */
  50479. isEnabled: boolean;
  50480. /**
  50481. * Gets the camera attached to the layer.
  50482. */
  50483. readonly camera: Nullable<Camera>;
  50484. /**
  50485. * Gets the rendering group id the layer should render in.
  50486. */
  50487. renderingGroupId: number;
  50488. /**
  50489. * An event triggered when the effect layer has been disposed.
  50490. */
  50491. onDisposeObservable: Observable<EffectLayer>;
  50492. /**
  50493. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50494. */
  50495. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50496. /**
  50497. * An event triggered when the generated texture is being merged in the scene.
  50498. */
  50499. onBeforeComposeObservable: Observable<EffectLayer>;
  50500. /**
  50501. * An event triggered when the generated texture has been merged in the scene.
  50502. */
  50503. onAfterComposeObservable: Observable<EffectLayer>;
  50504. /**
  50505. * An event triggered when the efffect layer changes its size.
  50506. */
  50507. onSizeChangedObservable: Observable<EffectLayer>;
  50508. /** @hidden */
  50509. static _SceneComponentInitialization: (scene: Scene) => void;
  50510. /**
  50511. * Instantiates a new effect Layer and references it in the scene.
  50512. * @param name The name of the layer
  50513. * @param scene The scene to use the layer in
  50514. */
  50515. constructor(
  50516. /** The Friendly of the effect in the scene */
  50517. name: string, scene: Scene);
  50518. /**
  50519. * Get the effect name of the layer.
  50520. * @return The effect name
  50521. */
  50522. abstract getEffectName(): string;
  50523. /**
  50524. * Checks for the readiness of the element composing the layer.
  50525. * @param subMesh the mesh to check for
  50526. * @param useInstances specify wether or not to use instances to render the mesh
  50527. * @return true if ready otherwise, false
  50528. */
  50529. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50530. /**
  50531. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50532. * @returns true if the effect requires stencil during the main canvas render pass.
  50533. */
  50534. abstract needStencil(): boolean;
  50535. /**
  50536. * Create the merge effect. This is the shader use to blit the information back
  50537. * to the main canvas at the end of the scene rendering.
  50538. * @returns The effect containing the shader used to merge the effect on the main canvas
  50539. */
  50540. protected abstract _createMergeEffect(): Effect;
  50541. /**
  50542. * Creates the render target textures and post processes used in the effect layer.
  50543. */
  50544. protected abstract _createTextureAndPostProcesses(): void;
  50545. /**
  50546. * Implementation specific of rendering the generating effect on the main canvas.
  50547. * @param effect The effect used to render through
  50548. */
  50549. protected abstract _internalRender(effect: Effect): void;
  50550. /**
  50551. * Sets the required values for both the emissive texture and and the main color.
  50552. */
  50553. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50554. /**
  50555. * Free any resources and references associated to a mesh.
  50556. * Internal use
  50557. * @param mesh The mesh to free.
  50558. */
  50559. abstract _disposeMesh(mesh: Mesh): void;
  50560. /**
  50561. * Serializes this layer (Glow or Highlight for example)
  50562. * @returns a serialized layer object
  50563. */
  50564. abstract serialize?(): any;
  50565. /**
  50566. * Initializes the effect layer with the required options.
  50567. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50568. */
  50569. protected _init(options: Partial<IEffectLayerOptions>): void;
  50570. /**
  50571. * Generates the index buffer of the full screen quad blending to the main canvas.
  50572. */
  50573. private _generateIndexBuffer;
  50574. /**
  50575. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50576. */
  50577. private _generateVertexBuffer;
  50578. /**
  50579. * Sets the main texture desired size which is the closest power of two
  50580. * of the engine canvas size.
  50581. */
  50582. private _setMainTextureSize;
  50583. /**
  50584. * Creates the main texture for the effect layer.
  50585. */
  50586. protected _createMainTexture(): void;
  50587. /**
  50588. * Adds specific effects defines.
  50589. * @param defines The defines to add specifics to.
  50590. */
  50591. protected _addCustomEffectDefines(defines: string[]): void;
  50592. /**
  50593. * Checks for the readiness of the element composing the layer.
  50594. * @param subMesh the mesh to check for
  50595. * @param useInstances specify wether or not to use instances to render the mesh
  50596. * @param emissiveTexture the associated emissive texture used to generate the glow
  50597. * @return true if ready otherwise, false
  50598. */
  50599. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50600. /**
  50601. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50602. */
  50603. render(): void;
  50604. /**
  50605. * Determine if a given mesh will be used in the current effect.
  50606. * @param mesh mesh to test
  50607. * @returns true if the mesh will be used
  50608. */
  50609. hasMesh(mesh: AbstractMesh): boolean;
  50610. /**
  50611. * Returns true if the layer contains information to display, otherwise false.
  50612. * @returns true if the glow layer should be rendered
  50613. */
  50614. shouldRender(): boolean;
  50615. /**
  50616. * Returns true if the mesh should render, otherwise false.
  50617. * @param mesh The mesh to render
  50618. * @returns true if it should render otherwise false
  50619. */
  50620. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50621. /**
  50622. * Returns true if the mesh can be rendered, otherwise false.
  50623. * @param mesh The mesh to render
  50624. * @param material The material used on the mesh
  50625. * @returns true if it can be rendered otherwise false
  50626. */
  50627. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50628. /**
  50629. * Returns true if the mesh should render, otherwise false.
  50630. * @param mesh The mesh to render
  50631. * @returns true if it should render otherwise false
  50632. */
  50633. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50634. /**
  50635. * Renders the submesh passed in parameter to the generation map.
  50636. */
  50637. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50638. /**
  50639. * Rebuild the required buffers.
  50640. * @hidden Internal use only.
  50641. */
  50642. _rebuild(): void;
  50643. /**
  50644. * Dispose only the render target textures and post process.
  50645. */
  50646. private _disposeTextureAndPostProcesses;
  50647. /**
  50648. * Dispose the highlight layer and free resources.
  50649. */
  50650. dispose(): void;
  50651. /**
  50652. * Gets the class name of the effect layer
  50653. * @returns the string with the class name of the effect layer
  50654. */
  50655. getClassName(): string;
  50656. /**
  50657. * Creates an effect layer from parsed effect layer data
  50658. * @param parsedEffectLayer defines effect layer data
  50659. * @param scene defines the current scene
  50660. * @param rootUrl defines the root URL containing the effect layer information
  50661. * @returns a parsed effect Layer
  50662. */
  50663. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50664. }
  50665. }
  50666. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50667. import { Scene } from "babylonjs/scene";
  50668. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50669. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50670. import { AbstractScene } from "babylonjs/abstractScene";
  50671. module "babylonjs/abstractScene" {
  50672. interface AbstractScene {
  50673. /**
  50674. * The list of effect layers (highlights/glow) added to the scene
  50675. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50676. * @see http://doc.babylonjs.com/how_to/glow_layer
  50677. */
  50678. effectLayers: Array<EffectLayer>;
  50679. /**
  50680. * Removes the given effect layer from this scene.
  50681. * @param toRemove defines the effect layer to remove
  50682. * @returns the index of the removed effect layer
  50683. */
  50684. removeEffectLayer(toRemove: EffectLayer): number;
  50685. /**
  50686. * Adds the given effect layer to this scene
  50687. * @param newEffectLayer defines the effect layer to add
  50688. */
  50689. addEffectLayer(newEffectLayer: EffectLayer): void;
  50690. }
  50691. }
  50692. /**
  50693. * Defines the layer scene component responsible to manage any effect layers
  50694. * in a given scene.
  50695. */
  50696. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50697. /**
  50698. * The component name helpfull to identify the component in the list of scene components.
  50699. */
  50700. readonly name: string;
  50701. /**
  50702. * The scene the component belongs to.
  50703. */
  50704. scene: Scene;
  50705. private _engine;
  50706. private _renderEffects;
  50707. private _needStencil;
  50708. private _previousStencilState;
  50709. /**
  50710. * Creates a new instance of the component for the given scene
  50711. * @param scene Defines the scene to register the component in
  50712. */
  50713. constructor(scene: Scene);
  50714. /**
  50715. * Registers the component in a given scene
  50716. */
  50717. register(): void;
  50718. /**
  50719. * Rebuilds the elements related to this component in case of
  50720. * context lost for instance.
  50721. */
  50722. rebuild(): void;
  50723. /**
  50724. * Serializes the component data to the specified json object
  50725. * @param serializationObject The object to serialize to
  50726. */
  50727. serialize(serializationObject: any): void;
  50728. /**
  50729. * Adds all the elements from the container to the scene
  50730. * @param container the container holding the elements
  50731. */
  50732. addFromContainer(container: AbstractScene): void;
  50733. /**
  50734. * Removes all the elements in the container from the scene
  50735. * @param container contains the elements to remove
  50736. * @param dispose if the removed element should be disposed (default: false)
  50737. */
  50738. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50739. /**
  50740. * Disposes the component and the associated ressources.
  50741. */
  50742. dispose(): void;
  50743. private _isReadyForMesh;
  50744. private _renderMainTexture;
  50745. private _setStencil;
  50746. private _setStencilBack;
  50747. private _draw;
  50748. private _drawCamera;
  50749. private _drawRenderingGroup;
  50750. }
  50751. }
  50752. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50753. /** @hidden */
  50754. export var glowMapMergePixelShader: {
  50755. name: string;
  50756. shader: string;
  50757. };
  50758. }
  50759. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50760. /** @hidden */
  50761. export var glowMapMergeVertexShader: {
  50762. name: string;
  50763. shader: string;
  50764. };
  50765. }
  50766. declare module "babylonjs/Layers/glowLayer" {
  50767. import { Nullable } from "babylonjs/types";
  50768. import { Camera } from "babylonjs/Cameras/camera";
  50769. import { Scene } from "babylonjs/scene";
  50770. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50772. import { Mesh } from "babylonjs/Meshes/mesh";
  50773. import { Texture } from "babylonjs/Materials/Textures/texture";
  50774. import { Effect } from "babylonjs/Materials/effect";
  50775. import { Material } from "babylonjs/Materials/material";
  50776. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50777. import { Color4 } from "babylonjs/Maths/math.color";
  50778. import "babylonjs/Shaders/glowMapMerge.fragment";
  50779. import "babylonjs/Shaders/glowMapMerge.vertex";
  50780. import "babylonjs/Layers/effectLayerSceneComponent";
  50781. module "babylonjs/abstractScene" {
  50782. interface AbstractScene {
  50783. /**
  50784. * Return a the first highlight layer of the scene with a given name.
  50785. * @param name The name of the highlight layer to look for.
  50786. * @return The highlight layer if found otherwise null.
  50787. */
  50788. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50789. }
  50790. }
  50791. /**
  50792. * Glow layer options. This helps customizing the behaviour
  50793. * of the glow layer.
  50794. */
  50795. export interface IGlowLayerOptions {
  50796. /**
  50797. * Multiplication factor apply to the canvas size to compute the render target size
  50798. * used to generated the glowing objects (the smaller the faster).
  50799. */
  50800. mainTextureRatio: number;
  50801. /**
  50802. * Enforces a fixed size texture to ensure resize independant blur.
  50803. */
  50804. mainTextureFixedSize?: number;
  50805. /**
  50806. * How big is the kernel of the blur texture.
  50807. */
  50808. blurKernelSize: number;
  50809. /**
  50810. * The camera attached to the layer.
  50811. */
  50812. camera: Nullable<Camera>;
  50813. /**
  50814. * Enable MSAA by chosing the number of samples.
  50815. */
  50816. mainTextureSamples?: number;
  50817. /**
  50818. * The rendering group to draw the layer in.
  50819. */
  50820. renderingGroupId: number;
  50821. }
  50822. /**
  50823. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50824. *
  50825. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50826. * glowy meshes to your scene.
  50827. *
  50828. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50829. */
  50830. export class GlowLayer extends EffectLayer {
  50831. /**
  50832. * Effect Name of the layer.
  50833. */
  50834. static readonly EffectName: string;
  50835. /**
  50836. * The default blur kernel size used for the glow.
  50837. */
  50838. static DefaultBlurKernelSize: number;
  50839. /**
  50840. * The default texture size ratio used for the glow.
  50841. */
  50842. static DefaultTextureRatio: number;
  50843. /**
  50844. * Sets the kernel size of the blur.
  50845. */
  50846. /**
  50847. * Gets the kernel size of the blur.
  50848. */
  50849. blurKernelSize: number;
  50850. /**
  50851. * Sets the glow intensity.
  50852. */
  50853. /**
  50854. * Gets the glow intensity.
  50855. */
  50856. intensity: number;
  50857. private _options;
  50858. private _intensity;
  50859. private _horizontalBlurPostprocess1;
  50860. private _verticalBlurPostprocess1;
  50861. private _horizontalBlurPostprocess2;
  50862. private _verticalBlurPostprocess2;
  50863. private _blurTexture1;
  50864. private _blurTexture2;
  50865. private _postProcesses1;
  50866. private _postProcesses2;
  50867. private _includedOnlyMeshes;
  50868. private _excludedMeshes;
  50869. /**
  50870. * Callback used to let the user override the color selection on a per mesh basis
  50871. */
  50872. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50873. /**
  50874. * Callback used to let the user override the texture selection on a per mesh basis
  50875. */
  50876. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50877. /**
  50878. * Instantiates a new glow Layer and references it to the scene.
  50879. * @param name The name of the layer
  50880. * @param scene The scene to use the layer in
  50881. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50882. */
  50883. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50884. /**
  50885. * Get the effect name of the layer.
  50886. * @return The effect name
  50887. */
  50888. getEffectName(): string;
  50889. /**
  50890. * Create the merge effect. This is the shader use to blit the information back
  50891. * to the main canvas at the end of the scene rendering.
  50892. */
  50893. protected _createMergeEffect(): Effect;
  50894. /**
  50895. * Creates the render target textures and post processes used in the glow layer.
  50896. */
  50897. protected _createTextureAndPostProcesses(): void;
  50898. /**
  50899. * Checks for the readiness of the element composing the layer.
  50900. * @param subMesh the mesh to check for
  50901. * @param useInstances specify wether or not to use instances to render the mesh
  50902. * @param emissiveTexture the associated emissive texture used to generate the glow
  50903. * @return true if ready otherwise, false
  50904. */
  50905. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50906. /**
  50907. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50908. */
  50909. needStencil(): boolean;
  50910. /**
  50911. * Returns true if the mesh can be rendered, otherwise false.
  50912. * @param mesh The mesh to render
  50913. * @param material The material used on the mesh
  50914. * @returns true if it can be rendered otherwise false
  50915. */
  50916. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50917. /**
  50918. * Implementation specific of rendering the generating effect on the main canvas.
  50919. * @param effect The effect used to render through
  50920. */
  50921. protected _internalRender(effect: Effect): void;
  50922. /**
  50923. * Sets the required values for both the emissive texture and and the main color.
  50924. */
  50925. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50926. /**
  50927. * Returns true if the mesh should render, otherwise false.
  50928. * @param mesh The mesh to render
  50929. * @returns true if it should render otherwise false
  50930. */
  50931. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50932. /**
  50933. * Adds specific effects defines.
  50934. * @param defines The defines to add specifics to.
  50935. */
  50936. protected _addCustomEffectDefines(defines: string[]): void;
  50937. /**
  50938. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50939. * @param mesh The mesh to exclude from the glow layer
  50940. */
  50941. addExcludedMesh(mesh: Mesh): void;
  50942. /**
  50943. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50944. * @param mesh The mesh to remove
  50945. */
  50946. removeExcludedMesh(mesh: Mesh): void;
  50947. /**
  50948. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50949. * @param mesh The mesh to include in the glow layer
  50950. */
  50951. addIncludedOnlyMesh(mesh: Mesh): void;
  50952. /**
  50953. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50954. * @param mesh The mesh to remove
  50955. */
  50956. removeIncludedOnlyMesh(mesh: Mesh): void;
  50957. /**
  50958. * Determine if a given mesh will be used in the glow layer
  50959. * @param mesh The mesh to test
  50960. * @returns true if the mesh will be highlighted by the current glow layer
  50961. */
  50962. hasMesh(mesh: AbstractMesh): boolean;
  50963. /**
  50964. * Free any resources and references associated to a mesh.
  50965. * Internal use
  50966. * @param mesh The mesh to free.
  50967. * @hidden
  50968. */
  50969. _disposeMesh(mesh: Mesh): void;
  50970. /**
  50971. * Gets the class name of the effect layer
  50972. * @returns the string with the class name of the effect layer
  50973. */
  50974. getClassName(): string;
  50975. /**
  50976. * Serializes this glow layer
  50977. * @returns a serialized glow layer object
  50978. */
  50979. serialize(): any;
  50980. /**
  50981. * Creates a Glow Layer from parsed glow layer data
  50982. * @param parsedGlowLayer defines glow layer data
  50983. * @param scene defines the current scene
  50984. * @param rootUrl defines the root URL containing the glow layer information
  50985. * @returns a parsed Glow Layer
  50986. */
  50987. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50988. }
  50989. }
  50990. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50991. /** @hidden */
  50992. export var glowBlurPostProcessPixelShader: {
  50993. name: string;
  50994. shader: string;
  50995. };
  50996. }
  50997. declare module "babylonjs/Layers/highlightLayer" {
  50998. import { Observable } from "babylonjs/Misc/observable";
  50999. import { Nullable } from "babylonjs/types";
  51000. import { Camera } from "babylonjs/Cameras/camera";
  51001. import { Scene } from "babylonjs/scene";
  51002. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51004. import { Mesh } from "babylonjs/Meshes/mesh";
  51005. import { Effect } from "babylonjs/Materials/effect";
  51006. import { Material } from "babylonjs/Materials/material";
  51007. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51008. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51009. import "babylonjs/Shaders/glowMapMerge.fragment";
  51010. import "babylonjs/Shaders/glowMapMerge.vertex";
  51011. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51012. module "babylonjs/abstractScene" {
  51013. interface AbstractScene {
  51014. /**
  51015. * Return a the first highlight layer of the scene with a given name.
  51016. * @param name The name of the highlight layer to look for.
  51017. * @return The highlight layer if found otherwise null.
  51018. */
  51019. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51020. }
  51021. }
  51022. /**
  51023. * Highlight layer options. This helps customizing the behaviour
  51024. * of the highlight layer.
  51025. */
  51026. export interface IHighlightLayerOptions {
  51027. /**
  51028. * Multiplication factor apply to the canvas size to compute the render target size
  51029. * used to generated the glowing objects (the smaller the faster).
  51030. */
  51031. mainTextureRatio: number;
  51032. /**
  51033. * Enforces a fixed size texture to ensure resize independant blur.
  51034. */
  51035. mainTextureFixedSize?: number;
  51036. /**
  51037. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51038. * of the picture to blur (the smaller the faster).
  51039. */
  51040. blurTextureSizeRatio: number;
  51041. /**
  51042. * How big in texel of the blur texture is the vertical blur.
  51043. */
  51044. blurVerticalSize: number;
  51045. /**
  51046. * How big in texel of the blur texture is the horizontal blur.
  51047. */
  51048. blurHorizontalSize: number;
  51049. /**
  51050. * Alpha blending mode used to apply the blur. Default is combine.
  51051. */
  51052. alphaBlendingMode: number;
  51053. /**
  51054. * The camera attached to the layer.
  51055. */
  51056. camera: Nullable<Camera>;
  51057. /**
  51058. * Should we display highlight as a solid stroke?
  51059. */
  51060. isStroke?: boolean;
  51061. /**
  51062. * The rendering group to draw the layer in.
  51063. */
  51064. renderingGroupId: number;
  51065. }
  51066. /**
  51067. * The highlight layer Helps adding a glow effect around a mesh.
  51068. *
  51069. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51070. * glowy meshes to your scene.
  51071. *
  51072. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51073. */
  51074. export class HighlightLayer extends EffectLayer {
  51075. name: string;
  51076. /**
  51077. * Effect Name of the highlight layer.
  51078. */
  51079. static readonly EffectName: string;
  51080. /**
  51081. * The neutral color used during the preparation of the glow effect.
  51082. * This is black by default as the blend operation is a blend operation.
  51083. */
  51084. static NeutralColor: Color4;
  51085. /**
  51086. * Stencil value used for glowing meshes.
  51087. */
  51088. static GlowingMeshStencilReference: number;
  51089. /**
  51090. * Stencil value used for the other meshes in the scene.
  51091. */
  51092. static NormalMeshStencilReference: number;
  51093. /**
  51094. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51095. */
  51096. innerGlow: boolean;
  51097. /**
  51098. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51099. */
  51100. outerGlow: boolean;
  51101. /**
  51102. * Specifies the horizontal size of the blur.
  51103. */
  51104. /**
  51105. * Gets the horizontal size of the blur.
  51106. */
  51107. blurHorizontalSize: number;
  51108. /**
  51109. * Specifies the vertical size of the blur.
  51110. */
  51111. /**
  51112. * Gets the vertical size of the blur.
  51113. */
  51114. blurVerticalSize: number;
  51115. /**
  51116. * An event triggered when the highlight layer is being blurred.
  51117. */
  51118. onBeforeBlurObservable: Observable<HighlightLayer>;
  51119. /**
  51120. * An event triggered when the highlight layer has been blurred.
  51121. */
  51122. onAfterBlurObservable: Observable<HighlightLayer>;
  51123. private _instanceGlowingMeshStencilReference;
  51124. private _options;
  51125. private _downSamplePostprocess;
  51126. private _horizontalBlurPostprocess;
  51127. private _verticalBlurPostprocess;
  51128. private _blurTexture;
  51129. private _meshes;
  51130. private _excludedMeshes;
  51131. /**
  51132. * Instantiates a new highlight Layer and references it to the scene..
  51133. * @param name The name of the layer
  51134. * @param scene The scene to use the layer in
  51135. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51136. */
  51137. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51138. /**
  51139. * Get the effect name of the layer.
  51140. * @return The effect name
  51141. */
  51142. getEffectName(): string;
  51143. /**
  51144. * Create the merge effect. This is the shader use to blit the information back
  51145. * to the main canvas at the end of the scene rendering.
  51146. */
  51147. protected _createMergeEffect(): Effect;
  51148. /**
  51149. * Creates the render target textures and post processes used in the highlight layer.
  51150. */
  51151. protected _createTextureAndPostProcesses(): void;
  51152. /**
  51153. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51154. */
  51155. needStencil(): boolean;
  51156. /**
  51157. * Checks for the readiness of the element composing the layer.
  51158. * @param subMesh the mesh to check for
  51159. * @param useInstances specify wether or not to use instances to render the mesh
  51160. * @param emissiveTexture the associated emissive texture used to generate the glow
  51161. * @return true if ready otherwise, false
  51162. */
  51163. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51164. /**
  51165. * Implementation specific of rendering the generating effect on the main canvas.
  51166. * @param effect The effect used to render through
  51167. */
  51168. protected _internalRender(effect: Effect): void;
  51169. /**
  51170. * Returns true if the layer contains information to display, otherwise false.
  51171. */
  51172. shouldRender(): boolean;
  51173. /**
  51174. * Returns true if the mesh should render, otherwise false.
  51175. * @param mesh The mesh to render
  51176. * @returns true if it should render otherwise false
  51177. */
  51178. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51179. /**
  51180. * Sets the required values for both the emissive texture and and the main color.
  51181. */
  51182. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51183. /**
  51184. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51185. * @param mesh The mesh to exclude from the highlight layer
  51186. */
  51187. addExcludedMesh(mesh: Mesh): void;
  51188. /**
  51189. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51190. * @param mesh The mesh to highlight
  51191. */
  51192. removeExcludedMesh(mesh: Mesh): void;
  51193. /**
  51194. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51195. * @param mesh mesh to test
  51196. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51197. */
  51198. hasMesh(mesh: AbstractMesh): boolean;
  51199. /**
  51200. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51201. * @param mesh The mesh to highlight
  51202. * @param color The color of the highlight
  51203. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51204. */
  51205. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51206. /**
  51207. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51208. * @param mesh The mesh to highlight
  51209. */
  51210. removeMesh(mesh: Mesh): void;
  51211. /**
  51212. * Force the stencil to the normal expected value for none glowing parts
  51213. */
  51214. private _defaultStencilReference;
  51215. /**
  51216. * Free any resources and references associated to a mesh.
  51217. * Internal use
  51218. * @param mesh The mesh to free.
  51219. * @hidden
  51220. */
  51221. _disposeMesh(mesh: Mesh): void;
  51222. /**
  51223. * Dispose the highlight layer and free resources.
  51224. */
  51225. dispose(): void;
  51226. /**
  51227. * Gets the class name of the effect layer
  51228. * @returns the string with the class name of the effect layer
  51229. */
  51230. getClassName(): string;
  51231. /**
  51232. * Serializes this Highlight layer
  51233. * @returns a serialized Highlight layer object
  51234. */
  51235. serialize(): any;
  51236. /**
  51237. * Creates a Highlight layer from parsed Highlight layer data
  51238. * @param parsedHightlightLayer defines the Highlight layer data
  51239. * @param scene defines the current scene
  51240. * @param rootUrl defines the root URL containing the Highlight layer information
  51241. * @returns a parsed Highlight layer
  51242. */
  51243. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51244. }
  51245. }
  51246. declare module "babylonjs/Layers/layerSceneComponent" {
  51247. import { Scene } from "babylonjs/scene";
  51248. import { ISceneComponent } from "babylonjs/sceneComponent";
  51249. import { Layer } from "babylonjs/Layers/layer";
  51250. import { AbstractScene } from "babylonjs/abstractScene";
  51251. module "babylonjs/abstractScene" {
  51252. interface AbstractScene {
  51253. /**
  51254. * The list of layers (background and foreground) of the scene
  51255. */
  51256. layers: Array<Layer>;
  51257. }
  51258. }
  51259. /**
  51260. * Defines the layer scene component responsible to manage any layers
  51261. * in a given scene.
  51262. */
  51263. export class LayerSceneComponent implements ISceneComponent {
  51264. /**
  51265. * The component name helpfull to identify the component in the list of scene components.
  51266. */
  51267. readonly name: string;
  51268. /**
  51269. * The scene the component belongs to.
  51270. */
  51271. scene: Scene;
  51272. private _engine;
  51273. /**
  51274. * Creates a new instance of the component for the given scene
  51275. * @param scene Defines the scene to register the component in
  51276. */
  51277. constructor(scene: Scene);
  51278. /**
  51279. * Registers the component in a given scene
  51280. */
  51281. register(): void;
  51282. /**
  51283. * Rebuilds the elements related to this component in case of
  51284. * context lost for instance.
  51285. */
  51286. rebuild(): void;
  51287. /**
  51288. * Disposes the component and the associated ressources.
  51289. */
  51290. dispose(): void;
  51291. private _draw;
  51292. private _drawCameraPredicate;
  51293. private _drawCameraBackground;
  51294. private _drawCameraForeground;
  51295. private _drawRenderTargetPredicate;
  51296. private _drawRenderTargetBackground;
  51297. private _drawRenderTargetForeground;
  51298. /**
  51299. * Adds all the elements from the container to the scene
  51300. * @param container the container holding the elements
  51301. */
  51302. addFromContainer(container: AbstractScene): void;
  51303. /**
  51304. * Removes all the elements in the container from the scene
  51305. * @param container contains the elements to remove
  51306. * @param dispose if the removed element should be disposed (default: false)
  51307. */
  51308. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51309. }
  51310. }
  51311. declare module "babylonjs/Shaders/layer.fragment" {
  51312. /** @hidden */
  51313. export var layerPixelShader: {
  51314. name: string;
  51315. shader: string;
  51316. };
  51317. }
  51318. declare module "babylonjs/Shaders/layer.vertex" {
  51319. /** @hidden */
  51320. export var layerVertexShader: {
  51321. name: string;
  51322. shader: string;
  51323. };
  51324. }
  51325. declare module "babylonjs/Layers/layer" {
  51326. import { Observable } from "babylonjs/Misc/observable";
  51327. import { Nullable } from "babylonjs/types";
  51328. import { Scene } from "babylonjs/scene";
  51329. import { Vector2 } from "babylonjs/Maths/math.vector";
  51330. import { Color4 } from "babylonjs/Maths/math.color";
  51331. import { Texture } from "babylonjs/Materials/Textures/texture";
  51332. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51333. import "babylonjs/Shaders/layer.fragment";
  51334. import "babylonjs/Shaders/layer.vertex";
  51335. /**
  51336. * This represents a full screen 2d layer.
  51337. * This can be useful to display a picture in the background of your scene for instance.
  51338. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51339. */
  51340. export class Layer {
  51341. /**
  51342. * Define the name of the layer.
  51343. */
  51344. name: string;
  51345. /**
  51346. * Define the texture the layer should display.
  51347. */
  51348. texture: Nullable<Texture>;
  51349. /**
  51350. * Is the layer in background or foreground.
  51351. */
  51352. isBackground: boolean;
  51353. /**
  51354. * Define the color of the layer (instead of texture).
  51355. */
  51356. color: Color4;
  51357. /**
  51358. * Define the scale of the layer in order to zoom in out of the texture.
  51359. */
  51360. scale: Vector2;
  51361. /**
  51362. * Define an offset for the layer in order to shift the texture.
  51363. */
  51364. offset: Vector2;
  51365. /**
  51366. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51367. */
  51368. alphaBlendingMode: number;
  51369. /**
  51370. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51371. * Alpha test will not mix with the background color in case of transparency.
  51372. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51373. */
  51374. alphaTest: boolean;
  51375. /**
  51376. * Define a mask to restrict the layer to only some of the scene cameras.
  51377. */
  51378. layerMask: number;
  51379. /**
  51380. * Define the list of render target the layer is visible into.
  51381. */
  51382. renderTargetTextures: RenderTargetTexture[];
  51383. /**
  51384. * Define if the layer is only used in renderTarget or if it also
  51385. * renders in the main frame buffer of the canvas.
  51386. */
  51387. renderOnlyInRenderTargetTextures: boolean;
  51388. private _scene;
  51389. private _vertexBuffers;
  51390. private _indexBuffer;
  51391. private _effect;
  51392. private _alphaTestEffect;
  51393. /**
  51394. * An event triggered when the layer is disposed.
  51395. */
  51396. onDisposeObservable: Observable<Layer>;
  51397. private _onDisposeObserver;
  51398. /**
  51399. * Back compatibility with callback before the onDisposeObservable existed.
  51400. * The set callback will be triggered when the layer has been disposed.
  51401. */
  51402. onDispose: () => void;
  51403. /**
  51404. * An event triggered before rendering the scene
  51405. */
  51406. onBeforeRenderObservable: Observable<Layer>;
  51407. private _onBeforeRenderObserver;
  51408. /**
  51409. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51410. * The set callback will be triggered just before rendering the layer.
  51411. */
  51412. onBeforeRender: () => void;
  51413. /**
  51414. * An event triggered after rendering the scene
  51415. */
  51416. onAfterRenderObservable: Observable<Layer>;
  51417. private _onAfterRenderObserver;
  51418. /**
  51419. * Back compatibility with callback before the onAfterRenderObservable existed.
  51420. * The set callback will be triggered just after rendering the layer.
  51421. */
  51422. onAfterRender: () => void;
  51423. /**
  51424. * Instantiates a new layer.
  51425. * This represents a full screen 2d layer.
  51426. * This can be useful to display a picture in the background of your scene for instance.
  51427. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51428. * @param name Define the name of the layer in the scene
  51429. * @param imgUrl Define the url of the texture to display in the layer
  51430. * @param scene Define the scene the layer belongs to
  51431. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51432. * @param color Defines a color for the layer
  51433. */
  51434. constructor(
  51435. /**
  51436. * Define the name of the layer.
  51437. */
  51438. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51439. private _createIndexBuffer;
  51440. /** @hidden */
  51441. _rebuild(): void;
  51442. /**
  51443. * Renders the layer in the scene.
  51444. */
  51445. render(): void;
  51446. /**
  51447. * Disposes and releases the associated ressources.
  51448. */
  51449. dispose(): void;
  51450. }
  51451. }
  51452. declare module "babylonjs/Layers/index" {
  51453. export * from "babylonjs/Layers/effectLayer";
  51454. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51455. export * from "babylonjs/Layers/glowLayer";
  51456. export * from "babylonjs/Layers/highlightLayer";
  51457. export * from "babylonjs/Layers/layer";
  51458. export * from "babylonjs/Layers/layerSceneComponent";
  51459. }
  51460. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51461. /** @hidden */
  51462. export var lensFlarePixelShader: {
  51463. name: string;
  51464. shader: string;
  51465. };
  51466. }
  51467. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51468. /** @hidden */
  51469. export var lensFlareVertexShader: {
  51470. name: string;
  51471. shader: string;
  51472. };
  51473. }
  51474. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51475. import { Scene } from "babylonjs/scene";
  51476. import { Vector3 } from "babylonjs/Maths/math.vector";
  51477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51478. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51479. import "babylonjs/Shaders/lensFlare.fragment";
  51480. import "babylonjs/Shaders/lensFlare.vertex";
  51481. import { Viewport } from "babylonjs/Maths/math.viewport";
  51482. /**
  51483. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51484. * It is usually composed of several `lensFlare`.
  51485. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51486. */
  51487. export class LensFlareSystem {
  51488. /**
  51489. * Define the name of the lens flare system
  51490. */
  51491. name: string;
  51492. /**
  51493. * List of lens flares used in this system.
  51494. */
  51495. lensFlares: LensFlare[];
  51496. /**
  51497. * Define a limit from the border the lens flare can be visible.
  51498. */
  51499. borderLimit: number;
  51500. /**
  51501. * Define a viewport border we do not want to see the lens flare in.
  51502. */
  51503. viewportBorder: number;
  51504. /**
  51505. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51506. */
  51507. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51508. /**
  51509. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51510. */
  51511. layerMask: number;
  51512. /**
  51513. * Define the id of the lens flare system in the scene.
  51514. * (equal to name by default)
  51515. */
  51516. id: string;
  51517. private _scene;
  51518. private _emitter;
  51519. private _vertexBuffers;
  51520. private _indexBuffer;
  51521. private _effect;
  51522. private _positionX;
  51523. private _positionY;
  51524. private _isEnabled;
  51525. /** @hidden */
  51526. static _SceneComponentInitialization: (scene: Scene) => void;
  51527. /**
  51528. * Instantiates a lens flare system.
  51529. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51530. * It is usually composed of several `lensFlare`.
  51531. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51532. * @param name Define the name of the lens flare system in the scene
  51533. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51534. * @param scene Define the scene the lens flare system belongs to
  51535. */
  51536. constructor(
  51537. /**
  51538. * Define the name of the lens flare system
  51539. */
  51540. name: string, emitter: any, scene: Scene);
  51541. /**
  51542. * Define if the lens flare system is enabled.
  51543. */
  51544. isEnabled: boolean;
  51545. /**
  51546. * Get the scene the effects belongs to.
  51547. * @returns the scene holding the lens flare system
  51548. */
  51549. getScene(): Scene;
  51550. /**
  51551. * Get the emitter of the lens flare system.
  51552. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51553. * @returns the emitter of the lens flare system
  51554. */
  51555. getEmitter(): any;
  51556. /**
  51557. * Set the emitter of the lens flare system.
  51558. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51559. * @param newEmitter Define the new emitter of the system
  51560. */
  51561. setEmitter(newEmitter: any): void;
  51562. /**
  51563. * Get the lens flare system emitter position.
  51564. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51565. * @returns the position
  51566. */
  51567. getEmitterPosition(): Vector3;
  51568. /**
  51569. * @hidden
  51570. */
  51571. computeEffectivePosition(globalViewport: Viewport): boolean;
  51572. /** @hidden */
  51573. _isVisible(): boolean;
  51574. /**
  51575. * @hidden
  51576. */
  51577. render(): boolean;
  51578. /**
  51579. * Dispose and release the lens flare with its associated resources.
  51580. */
  51581. dispose(): void;
  51582. /**
  51583. * Parse a lens flare system from a JSON repressentation
  51584. * @param parsedLensFlareSystem Define the JSON to parse
  51585. * @param scene Define the scene the parsed system should be instantiated in
  51586. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51587. * @returns the parsed system
  51588. */
  51589. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51590. /**
  51591. * Serialize the current Lens Flare System into a JSON representation.
  51592. * @returns the serialized JSON
  51593. */
  51594. serialize(): any;
  51595. }
  51596. }
  51597. declare module "babylonjs/LensFlares/lensFlare" {
  51598. import { Nullable } from "babylonjs/types";
  51599. import { Color3 } from "babylonjs/Maths/math.color";
  51600. import { Texture } from "babylonjs/Materials/Textures/texture";
  51601. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51602. /**
  51603. * This represents one of the lens effect in a `lensFlareSystem`.
  51604. * It controls one of the indiviual texture used in the effect.
  51605. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51606. */
  51607. export class LensFlare {
  51608. /**
  51609. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51610. */
  51611. size: number;
  51612. /**
  51613. * 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.
  51614. */
  51615. position: number;
  51616. /**
  51617. * Define the lens color.
  51618. */
  51619. color: Color3;
  51620. /**
  51621. * Define the lens texture.
  51622. */
  51623. texture: Nullable<Texture>;
  51624. /**
  51625. * Define the alpha mode to render this particular lens.
  51626. */
  51627. alphaMode: number;
  51628. private _system;
  51629. /**
  51630. * Creates a new Lens Flare.
  51631. * This represents one of the lens effect in a `lensFlareSystem`.
  51632. * It controls one of the indiviual texture used in the effect.
  51633. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51634. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51635. * @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.
  51636. * @param color Define the lens color
  51637. * @param imgUrl Define the lens texture url
  51638. * @param system Define the `lensFlareSystem` this flare is part of
  51639. * @returns The newly created Lens Flare
  51640. */
  51641. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51642. /**
  51643. * Instantiates a new Lens Flare.
  51644. * This represents one of the lens effect in a `lensFlareSystem`.
  51645. * It controls one of the indiviual texture used in the effect.
  51646. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51647. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51648. * @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.
  51649. * @param color Define the lens color
  51650. * @param imgUrl Define the lens texture url
  51651. * @param system Define the `lensFlareSystem` this flare is part of
  51652. */
  51653. constructor(
  51654. /**
  51655. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51656. */
  51657. size: number,
  51658. /**
  51659. * 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.
  51660. */
  51661. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51662. /**
  51663. * Dispose and release the lens flare with its associated resources.
  51664. */
  51665. dispose(): void;
  51666. }
  51667. }
  51668. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51669. import { Nullable } from "babylonjs/types";
  51670. import { Scene } from "babylonjs/scene";
  51671. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51672. import { AbstractScene } from "babylonjs/abstractScene";
  51673. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51674. module "babylonjs/abstractScene" {
  51675. interface AbstractScene {
  51676. /**
  51677. * The list of lens flare system added to the scene
  51678. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51679. */
  51680. lensFlareSystems: Array<LensFlareSystem>;
  51681. /**
  51682. * Removes the given lens flare system from this scene.
  51683. * @param toRemove The lens flare system to remove
  51684. * @returns The index of the removed lens flare system
  51685. */
  51686. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51687. /**
  51688. * Adds the given lens flare system to this scene
  51689. * @param newLensFlareSystem The lens flare system to add
  51690. */
  51691. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51692. /**
  51693. * Gets a lens flare system using its name
  51694. * @param name defines the name to look for
  51695. * @returns the lens flare system or null if not found
  51696. */
  51697. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51698. /**
  51699. * Gets a lens flare system using its id
  51700. * @param id defines the id to look for
  51701. * @returns the lens flare system or null if not found
  51702. */
  51703. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51704. }
  51705. }
  51706. /**
  51707. * Defines the lens flare scene component responsible to manage any lens flares
  51708. * in a given scene.
  51709. */
  51710. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51711. /**
  51712. * The component name helpfull to identify the component in the list of scene components.
  51713. */
  51714. readonly name: string;
  51715. /**
  51716. * The scene the component belongs to.
  51717. */
  51718. scene: Scene;
  51719. /**
  51720. * Creates a new instance of the component for the given scene
  51721. * @param scene Defines the scene to register the component in
  51722. */
  51723. constructor(scene: Scene);
  51724. /**
  51725. * Registers the component in a given scene
  51726. */
  51727. register(): void;
  51728. /**
  51729. * Rebuilds the elements related to this component in case of
  51730. * context lost for instance.
  51731. */
  51732. rebuild(): void;
  51733. /**
  51734. * Adds all the elements from the container to the scene
  51735. * @param container the container holding the elements
  51736. */
  51737. addFromContainer(container: AbstractScene): void;
  51738. /**
  51739. * Removes all the elements in the container from the scene
  51740. * @param container contains the elements to remove
  51741. * @param dispose if the removed element should be disposed (default: false)
  51742. */
  51743. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51744. /**
  51745. * Serializes the component data to the specified json object
  51746. * @param serializationObject The object to serialize to
  51747. */
  51748. serialize(serializationObject: any): void;
  51749. /**
  51750. * Disposes the component and the associated ressources.
  51751. */
  51752. dispose(): void;
  51753. private _draw;
  51754. }
  51755. }
  51756. declare module "babylonjs/LensFlares/index" {
  51757. export * from "babylonjs/LensFlares/lensFlare";
  51758. export * from "babylonjs/LensFlares/lensFlareSystem";
  51759. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51760. }
  51761. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51762. import { Scene } from "babylonjs/scene";
  51763. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51764. import { AbstractScene } from "babylonjs/abstractScene";
  51765. /**
  51766. * Defines the shadow generator component responsible to manage any shadow generators
  51767. * in a given scene.
  51768. */
  51769. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51770. /**
  51771. * The component name helpfull to identify the component in the list of scene components.
  51772. */
  51773. readonly name: string;
  51774. /**
  51775. * The scene the component belongs to.
  51776. */
  51777. scene: Scene;
  51778. /**
  51779. * Creates a new instance of the component for the given scene
  51780. * @param scene Defines the scene to register the component in
  51781. */
  51782. constructor(scene: Scene);
  51783. /**
  51784. * Registers the component in a given scene
  51785. */
  51786. register(): void;
  51787. /**
  51788. * Rebuilds the elements related to this component in case of
  51789. * context lost for instance.
  51790. */
  51791. rebuild(): void;
  51792. /**
  51793. * Serializes the component data to the specified json object
  51794. * @param serializationObject The object to serialize to
  51795. */
  51796. serialize(serializationObject: any): void;
  51797. /**
  51798. * Adds all the elements from the container to the scene
  51799. * @param container the container holding the elements
  51800. */
  51801. addFromContainer(container: AbstractScene): void;
  51802. /**
  51803. * Removes all the elements in the container from the scene
  51804. * @param container contains the elements to remove
  51805. * @param dispose if the removed element should be disposed (default: false)
  51806. */
  51807. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51808. /**
  51809. * Rebuilds the elements related to this component in case of
  51810. * context lost for instance.
  51811. */
  51812. dispose(): void;
  51813. private _gatherRenderTargets;
  51814. }
  51815. }
  51816. declare module "babylonjs/Lights/Shadows/index" {
  51817. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51818. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51819. }
  51820. declare module "babylonjs/Lights/pointLight" {
  51821. import { Scene } from "babylonjs/scene";
  51822. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51824. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51825. import { Effect } from "babylonjs/Materials/effect";
  51826. /**
  51827. * A point light is a light defined by an unique point in world space.
  51828. * The light is emitted in every direction from this point.
  51829. * A good example of a point light is a standard light bulb.
  51830. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51831. */
  51832. export class PointLight extends ShadowLight {
  51833. private _shadowAngle;
  51834. /**
  51835. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51836. * This specifies what angle the shadow will use to be created.
  51837. *
  51838. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51839. */
  51840. /**
  51841. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51842. * This specifies what angle the shadow will use to be created.
  51843. *
  51844. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51845. */
  51846. shadowAngle: number;
  51847. /**
  51848. * Gets the direction if it has been set.
  51849. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51850. */
  51851. /**
  51852. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51853. */
  51854. direction: Vector3;
  51855. /**
  51856. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51857. * A PointLight emits the light in every direction.
  51858. * It can cast shadows.
  51859. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51860. * ```javascript
  51861. * var pointLight = new PointLight("pl", camera.position, scene);
  51862. * ```
  51863. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51864. * @param name The light friendly name
  51865. * @param position The position of the point light in the scene
  51866. * @param scene The scene the lights belongs to
  51867. */
  51868. constructor(name: string, position: Vector3, scene: Scene);
  51869. /**
  51870. * Returns the string "PointLight"
  51871. * @returns the class name
  51872. */
  51873. getClassName(): string;
  51874. /**
  51875. * Returns the integer 0.
  51876. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51877. */
  51878. getTypeID(): number;
  51879. /**
  51880. * Specifies wether or not the shadowmap should be a cube texture.
  51881. * @returns true if the shadowmap needs to be a cube texture.
  51882. */
  51883. needCube(): boolean;
  51884. /**
  51885. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51886. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51887. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51888. */
  51889. getShadowDirection(faceIndex?: number): Vector3;
  51890. /**
  51891. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51892. * - fov = PI / 2
  51893. * - aspect ratio : 1.0
  51894. * - z-near and far equal to the active camera minZ and maxZ.
  51895. * Returns the PointLight.
  51896. */
  51897. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51898. protected _buildUniformLayout(): void;
  51899. /**
  51900. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51901. * @param effect The effect to update
  51902. * @param lightIndex The index of the light in the effect to update
  51903. * @returns The point light
  51904. */
  51905. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51906. /**
  51907. * Prepares the list of defines specific to the light type.
  51908. * @param defines the list of defines
  51909. * @param lightIndex defines the index of the light for the effect
  51910. */
  51911. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51912. }
  51913. }
  51914. declare module "babylonjs/Lights/index" {
  51915. export * from "babylonjs/Lights/light";
  51916. export * from "babylonjs/Lights/shadowLight";
  51917. export * from "babylonjs/Lights/Shadows/index";
  51918. export * from "babylonjs/Lights/directionalLight";
  51919. export * from "babylonjs/Lights/hemisphericLight";
  51920. export * from "babylonjs/Lights/pointLight";
  51921. export * from "babylonjs/Lights/spotLight";
  51922. }
  51923. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51924. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51925. /**
  51926. * Header information of HDR texture files.
  51927. */
  51928. export interface HDRInfo {
  51929. /**
  51930. * The height of the texture in pixels.
  51931. */
  51932. height: number;
  51933. /**
  51934. * The width of the texture in pixels.
  51935. */
  51936. width: number;
  51937. /**
  51938. * The index of the beginning of the data in the binary file.
  51939. */
  51940. dataPosition: number;
  51941. }
  51942. /**
  51943. * This groups tools to convert HDR texture to native colors array.
  51944. */
  51945. export class HDRTools {
  51946. private static Ldexp;
  51947. private static Rgbe2float;
  51948. private static readStringLine;
  51949. /**
  51950. * Reads header information from an RGBE texture stored in a native array.
  51951. * More information on this format are available here:
  51952. * https://en.wikipedia.org/wiki/RGBE_image_format
  51953. *
  51954. * @param uint8array The binary file stored in native array.
  51955. * @return The header information.
  51956. */
  51957. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51958. /**
  51959. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51960. * This RGBE texture needs to store the information as a panorama.
  51961. *
  51962. * More information on this format are available here:
  51963. * https://en.wikipedia.org/wiki/RGBE_image_format
  51964. *
  51965. * @param buffer The binary file stored in an array buffer.
  51966. * @param size The expected size of the extracted cubemap.
  51967. * @return The Cube Map information.
  51968. */
  51969. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51970. /**
  51971. * Returns the pixels data extracted from an RGBE texture.
  51972. * This pixels will be stored left to right up to down in the R G B order in one array.
  51973. *
  51974. * More information on this format are available here:
  51975. * https://en.wikipedia.org/wiki/RGBE_image_format
  51976. *
  51977. * @param uint8array The binary file stored in an array buffer.
  51978. * @param hdrInfo The header information of the file.
  51979. * @return The pixels data in RGB right to left up to down order.
  51980. */
  51981. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51982. private static RGBE_ReadPixels_RLE;
  51983. }
  51984. }
  51985. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51986. import { Nullable } from "babylonjs/types";
  51987. import { Scene } from "babylonjs/scene";
  51988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51989. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51990. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51991. /**
  51992. * This represents a texture coming from an HDR input.
  51993. *
  51994. * The only supported format is currently panorama picture stored in RGBE format.
  51995. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51996. */
  51997. export class HDRCubeTexture extends BaseTexture {
  51998. private static _facesMapping;
  51999. private _generateHarmonics;
  52000. private _noMipmap;
  52001. private _textureMatrix;
  52002. private _size;
  52003. private _onLoad;
  52004. private _onError;
  52005. /**
  52006. * The texture URL.
  52007. */
  52008. url: string;
  52009. /**
  52010. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52011. */
  52012. coordinatesMode: number;
  52013. protected _isBlocking: boolean;
  52014. /**
  52015. * Sets wether or not the texture is blocking during loading.
  52016. */
  52017. /**
  52018. * Gets wether or not the texture is blocking during loading.
  52019. */
  52020. isBlocking: boolean;
  52021. protected _rotationY: number;
  52022. /**
  52023. * Sets texture matrix rotation angle around Y axis in radians.
  52024. */
  52025. /**
  52026. * Gets texture matrix rotation angle around Y axis radians.
  52027. */
  52028. rotationY: number;
  52029. /**
  52030. * Gets or sets the center of the bounding box associated with the cube texture
  52031. * It must define where the camera used to render the texture was set
  52032. */
  52033. boundingBoxPosition: Vector3;
  52034. private _boundingBoxSize;
  52035. /**
  52036. * Gets or sets the size of the bounding box associated with the cube texture
  52037. * When defined, the cubemap will switch to local mode
  52038. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52039. * @example https://www.babylonjs-playground.com/#RNASML
  52040. */
  52041. boundingBoxSize: Vector3;
  52042. /**
  52043. * Instantiates an HDRTexture from the following parameters.
  52044. *
  52045. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52046. * @param scene The scene the texture will be used in
  52047. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52048. * @param noMipmap Forces to not generate the mipmap if true
  52049. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52050. * @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)
  52051. * @param reserved Reserved flag for internal use.
  52052. */
  52053. 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>);
  52054. /**
  52055. * Get the current class name of the texture useful for serialization or dynamic coding.
  52056. * @returns "HDRCubeTexture"
  52057. */
  52058. getClassName(): string;
  52059. /**
  52060. * Occurs when the file is raw .hdr file.
  52061. */
  52062. private loadTexture;
  52063. clone(): HDRCubeTexture;
  52064. delayLoad(): void;
  52065. /**
  52066. * Get the texture reflection matrix used to rotate/transform the reflection.
  52067. * @returns the reflection matrix
  52068. */
  52069. getReflectionTextureMatrix(): Matrix;
  52070. /**
  52071. * Set the texture reflection matrix used to rotate/transform the reflection.
  52072. * @param value Define the reflection matrix to set
  52073. */
  52074. setReflectionTextureMatrix(value: Matrix): void;
  52075. /**
  52076. * Parses a JSON representation of an HDR Texture in order to create the texture
  52077. * @param parsedTexture Define the JSON representation
  52078. * @param scene Define the scene the texture should be created in
  52079. * @param rootUrl Define the root url in case we need to load relative dependencies
  52080. * @returns the newly created texture after parsing
  52081. */
  52082. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52083. serialize(): any;
  52084. }
  52085. }
  52086. declare module "babylonjs/Physics/physicsEngine" {
  52087. import { Nullable } from "babylonjs/types";
  52088. import { Vector3 } from "babylonjs/Maths/math.vector";
  52089. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52090. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52091. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52092. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52093. /**
  52094. * Class used to control physics engine
  52095. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52096. */
  52097. export class PhysicsEngine implements IPhysicsEngine {
  52098. private _physicsPlugin;
  52099. /**
  52100. * Global value used to control the smallest number supported by the simulation
  52101. */
  52102. static Epsilon: number;
  52103. private _impostors;
  52104. private _joints;
  52105. /**
  52106. * Gets the gravity vector used by the simulation
  52107. */
  52108. gravity: Vector3;
  52109. /**
  52110. * Factory used to create the default physics plugin.
  52111. * @returns The default physics plugin
  52112. */
  52113. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52114. /**
  52115. * Creates a new Physics Engine
  52116. * @param gravity defines the gravity vector used by the simulation
  52117. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52118. */
  52119. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52120. /**
  52121. * Sets the gravity vector used by the simulation
  52122. * @param gravity defines the gravity vector to use
  52123. */
  52124. setGravity(gravity: Vector3): void;
  52125. /**
  52126. * Set the time step of the physics engine.
  52127. * Default is 1/60.
  52128. * To slow it down, enter 1/600 for example.
  52129. * To speed it up, 1/30
  52130. * @param newTimeStep defines the new timestep to apply to this world.
  52131. */
  52132. setTimeStep(newTimeStep?: number): void;
  52133. /**
  52134. * Get the time step of the physics engine.
  52135. * @returns the current time step
  52136. */
  52137. getTimeStep(): number;
  52138. /**
  52139. * Release all resources
  52140. */
  52141. dispose(): void;
  52142. /**
  52143. * Gets the name of the current physics plugin
  52144. * @returns the name of the plugin
  52145. */
  52146. getPhysicsPluginName(): string;
  52147. /**
  52148. * Adding a new impostor for the impostor tracking.
  52149. * This will be done by the impostor itself.
  52150. * @param impostor the impostor to add
  52151. */
  52152. addImpostor(impostor: PhysicsImpostor): void;
  52153. /**
  52154. * Remove an impostor from the engine.
  52155. * This impostor and its mesh will not longer be updated by the physics engine.
  52156. * @param impostor the impostor to remove
  52157. */
  52158. removeImpostor(impostor: PhysicsImpostor): void;
  52159. /**
  52160. * Add a joint to the physics engine
  52161. * @param mainImpostor defines the main impostor to which the joint is added.
  52162. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52163. * @param joint defines the joint that will connect both impostors.
  52164. */
  52165. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52166. /**
  52167. * Removes a joint from the simulation
  52168. * @param mainImpostor defines the impostor used with the joint
  52169. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52170. * @param joint defines the joint to remove
  52171. */
  52172. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52173. /**
  52174. * Called by the scene. No need to call it.
  52175. * @param delta defines the timespam between frames
  52176. */
  52177. _step(delta: number): void;
  52178. /**
  52179. * Gets the current plugin used to run the simulation
  52180. * @returns current plugin
  52181. */
  52182. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52183. /**
  52184. * Gets the list of physic impostors
  52185. * @returns an array of PhysicsImpostor
  52186. */
  52187. getImpostors(): Array<PhysicsImpostor>;
  52188. /**
  52189. * Gets the impostor for a physics enabled object
  52190. * @param object defines the object impersonated by the impostor
  52191. * @returns the PhysicsImpostor or null if not found
  52192. */
  52193. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52194. /**
  52195. * Gets the impostor for a physics body object
  52196. * @param body defines physics body used by the impostor
  52197. * @returns the PhysicsImpostor or null if not found
  52198. */
  52199. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52200. /**
  52201. * Does a raycast in the physics world
  52202. * @param from when should the ray start?
  52203. * @param to when should the ray end?
  52204. * @returns PhysicsRaycastResult
  52205. */
  52206. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52207. }
  52208. }
  52209. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52210. import { Nullable } from "babylonjs/types";
  52211. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52213. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52214. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52215. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52216. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52217. /** @hidden */
  52218. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52219. private _useDeltaForWorldStep;
  52220. world: any;
  52221. name: string;
  52222. private _physicsMaterials;
  52223. private _fixedTimeStep;
  52224. private _cannonRaycastResult;
  52225. private _raycastResult;
  52226. private _physicsBodysToRemoveAfterStep;
  52227. BJSCANNON: any;
  52228. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52229. setGravity(gravity: Vector3): void;
  52230. setTimeStep(timeStep: number): void;
  52231. getTimeStep(): number;
  52232. executeStep(delta: number): void;
  52233. private _removeMarkedPhysicsBodiesFromWorld;
  52234. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52235. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52236. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52237. private _processChildMeshes;
  52238. removePhysicsBody(impostor: PhysicsImpostor): void;
  52239. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52240. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52241. private _addMaterial;
  52242. private _checkWithEpsilon;
  52243. private _createShape;
  52244. private _createHeightmap;
  52245. private _minus90X;
  52246. private _plus90X;
  52247. private _tmpPosition;
  52248. private _tmpDeltaPosition;
  52249. private _tmpUnityRotation;
  52250. private _updatePhysicsBodyTransformation;
  52251. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52252. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52253. isSupported(): boolean;
  52254. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52255. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52256. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52257. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52258. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52259. getBodyMass(impostor: PhysicsImpostor): number;
  52260. getBodyFriction(impostor: PhysicsImpostor): number;
  52261. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52262. getBodyRestitution(impostor: PhysicsImpostor): number;
  52263. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52264. sleepBody(impostor: PhysicsImpostor): void;
  52265. wakeUpBody(impostor: PhysicsImpostor): void;
  52266. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52267. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52268. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52269. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52270. getRadius(impostor: PhysicsImpostor): number;
  52271. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52272. dispose(): void;
  52273. private _extendNamespace;
  52274. /**
  52275. * Does a raycast in the physics world
  52276. * @param from when should the ray start?
  52277. * @param to when should the ray end?
  52278. * @returns PhysicsRaycastResult
  52279. */
  52280. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52281. }
  52282. }
  52283. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52284. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52285. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52286. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52288. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52289. import { Nullable } from "babylonjs/types";
  52290. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52291. /** @hidden */
  52292. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52293. world: any;
  52294. name: string;
  52295. BJSOIMO: any;
  52296. private _raycastResult;
  52297. constructor(iterations?: number, oimoInjection?: any);
  52298. setGravity(gravity: Vector3): void;
  52299. setTimeStep(timeStep: number): void;
  52300. getTimeStep(): number;
  52301. private _tmpImpostorsArray;
  52302. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52303. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52304. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52305. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52306. private _tmpPositionVector;
  52307. removePhysicsBody(impostor: PhysicsImpostor): void;
  52308. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52309. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52310. isSupported(): boolean;
  52311. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52312. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52314. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52315. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52316. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52317. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52318. getBodyMass(impostor: PhysicsImpostor): number;
  52319. getBodyFriction(impostor: PhysicsImpostor): number;
  52320. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52321. getBodyRestitution(impostor: PhysicsImpostor): number;
  52322. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52323. sleepBody(impostor: PhysicsImpostor): void;
  52324. wakeUpBody(impostor: PhysicsImpostor): void;
  52325. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52326. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52327. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52328. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52329. getRadius(impostor: PhysicsImpostor): number;
  52330. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52331. dispose(): void;
  52332. /**
  52333. * Does a raycast in the physics world
  52334. * @param from when should the ray start?
  52335. * @param to when should the ray end?
  52336. * @returns PhysicsRaycastResult
  52337. */
  52338. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52339. }
  52340. }
  52341. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52342. import { Nullable } from "babylonjs/types";
  52343. import { Scene } from "babylonjs/scene";
  52344. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52345. import { Color4 } from "babylonjs/Maths/math.color";
  52346. import { Mesh } from "babylonjs/Meshes/mesh";
  52347. /**
  52348. * Class containing static functions to help procedurally build meshes
  52349. */
  52350. export class RibbonBuilder {
  52351. /**
  52352. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52353. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52354. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52355. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52356. * * 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
  52357. * * 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
  52358. * * 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
  52359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52362. * * 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
  52363. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52364. * * 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
  52365. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52367. * @param name defines the name of the mesh
  52368. * @param options defines the options used to create the mesh
  52369. * @param scene defines the hosting scene
  52370. * @returns the ribbon mesh
  52371. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52372. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52373. */
  52374. static CreateRibbon(name: string, options: {
  52375. pathArray: Vector3[][];
  52376. closeArray?: boolean;
  52377. closePath?: boolean;
  52378. offset?: number;
  52379. updatable?: boolean;
  52380. sideOrientation?: number;
  52381. frontUVs?: Vector4;
  52382. backUVs?: Vector4;
  52383. instance?: Mesh;
  52384. invertUV?: boolean;
  52385. uvs?: Vector2[];
  52386. colors?: Color4[];
  52387. }, scene?: Nullable<Scene>): Mesh;
  52388. }
  52389. }
  52390. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52391. import { Nullable } from "babylonjs/types";
  52392. import { Scene } from "babylonjs/scene";
  52393. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52394. import { Mesh } from "babylonjs/Meshes/mesh";
  52395. /**
  52396. * Class containing static functions to help procedurally build meshes
  52397. */
  52398. export class ShapeBuilder {
  52399. /**
  52400. * 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.
  52401. * * 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.
  52402. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52403. * * 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.
  52404. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52405. * * 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
  52406. * * 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
  52407. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52412. * @param name defines the name of the mesh
  52413. * @param options defines the options used to create the mesh
  52414. * @param scene defines the hosting scene
  52415. * @returns the extruded shape mesh
  52416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52418. */
  52419. static ExtrudeShape(name: string, options: {
  52420. shape: Vector3[];
  52421. path: Vector3[];
  52422. scale?: number;
  52423. rotation?: number;
  52424. cap?: number;
  52425. updatable?: boolean;
  52426. sideOrientation?: number;
  52427. frontUVs?: Vector4;
  52428. backUVs?: Vector4;
  52429. instance?: Mesh;
  52430. invertUV?: boolean;
  52431. }, scene?: Nullable<Scene>): Mesh;
  52432. /**
  52433. * Creates an custom extruded shape mesh.
  52434. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52435. * * 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.
  52436. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52437. * * 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
  52438. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52439. * * 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
  52440. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52441. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52442. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52443. * * 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
  52444. * * 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
  52445. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52448. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52450. * @param name defines the name of the mesh
  52451. * @param options defines the options used to create the mesh
  52452. * @param scene defines the hosting scene
  52453. * @returns the custom extruded shape mesh
  52454. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52455. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52457. */
  52458. static ExtrudeShapeCustom(name: string, options: {
  52459. shape: Vector3[];
  52460. path: Vector3[];
  52461. scaleFunction?: any;
  52462. rotationFunction?: any;
  52463. ribbonCloseArray?: boolean;
  52464. ribbonClosePath?: boolean;
  52465. cap?: number;
  52466. updatable?: boolean;
  52467. sideOrientation?: number;
  52468. frontUVs?: Vector4;
  52469. backUVs?: Vector4;
  52470. instance?: Mesh;
  52471. invertUV?: boolean;
  52472. }, scene?: Nullable<Scene>): Mesh;
  52473. private static _ExtrudeShapeGeneric;
  52474. }
  52475. }
  52476. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52477. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52478. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52479. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52480. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52481. import { Nullable } from "babylonjs/types";
  52482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52483. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52484. /**
  52485. * AmmoJS Physics plugin
  52486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52487. * @see https://github.com/kripken/ammo.js/
  52488. */
  52489. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52490. private _useDeltaForWorldStep;
  52491. /**
  52492. * Reference to the Ammo library
  52493. */
  52494. bjsAMMO: any;
  52495. /**
  52496. * Created ammoJS world which physics bodies are added to
  52497. */
  52498. world: any;
  52499. /**
  52500. * Name of the plugin
  52501. */
  52502. name: string;
  52503. private _timeStep;
  52504. private _fixedTimeStep;
  52505. private _maxSteps;
  52506. private _tmpQuaternion;
  52507. private _tmpAmmoTransform;
  52508. private _tmpAmmoQuaternion;
  52509. private _tmpAmmoConcreteContactResultCallback;
  52510. private _collisionConfiguration;
  52511. private _dispatcher;
  52512. private _overlappingPairCache;
  52513. private _solver;
  52514. private _softBodySolver;
  52515. private _tmpAmmoVectorA;
  52516. private _tmpAmmoVectorB;
  52517. private _tmpAmmoVectorC;
  52518. private _tmpAmmoVectorD;
  52519. private _tmpContactCallbackResult;
  52520. private _tmpAmmoVectorRCA;
  52521. private _tmpAmmoVectorRCB;
  52522. private _raycastResult;
  52523. private static readonly DISABLE_COLLISION_FLAG;
  52524. private static readonly KINEMATIC_FLAG;
  52525. private static readonly DISABLE_DEACTIVATION_FLAG;
  52526. /**
  52527. * Initializes the ammoJS plugin
  52528. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52529. * @param ammoInjection can be used to inject your own ammo reference
  52530. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52531. */
  52532. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52533. /**
  52534. * Sets the gravity of the physics world (m/(s^2))
  52535. * @param gravity Gravity to set
  52536. */
  52537. setGravity(gravity: Vector3): void;
  52538. /**
  52539. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52540. * @param timeStep timestep to use in seconds
  52541. */
  52542. setTimeStep(timeStep: number): void;
  52543. /**
  52544. * 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)
  52545. * @param fixedTimeStep fixedTimeStep to use in seconds
  52546. */
  52547. setFixedTimeStep(fixedTimeStep: number): void;
  52548. /**
  52549. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52550. * @param maxSteps the maximum number of steps by the physics engine per frame
  52551. */
  52552. setMaxSteps(maxSteps: number): void;
  52553. /**
  52554. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52555. * @returns the current timestep in seconds
  52556. */
  52557. getTimeStep(): number;
  52558. private _isImpostorInContact;
  52559. private _isImpostorPairInContact;
  52560. private _stepSimulation;
  52561. /**
  52562. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52563. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52564. * After the step the babylon meshes are set to the position of the physics imposters
  52565. * @param delta amount of time to step forward
  52566. * @param impostors array of imposters to update before/after the step
  52567. */
  52568. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52569. /**
  52570. * Update babylon mesh to match physics world object
  52571. * @param impostor imposter to match
  52572. */
  52573. private _afterSoftStep;
  52574. /**
  52575. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52576. * @param impostor imposter to match
  52577. */
  52578. private _ropeStep;
  52579. /**
  52580. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52581. * @param impostor imposter to match
  52582. */
  52583. private _softbodyOrClothStep;
  52584. private _tmpVector;
  52585. private _tmpMatrix;
  52586. /**
  52587. * Applies an impulse on the imposter
  52588. * @param impostor imposter to apply impulse to
  52589. * @param force amount of force to be applied to the imposter
  52590. * @param contactPoint the location to apply the impulse on the imposter
  52591. */
  52592. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52593. /**
  52594. * Applies a force on the imposter
  52595. * @param impostor imposter to apply force
  52596. * @param force amount of force to be applied to the imposter
  52597. * @param contactPoint the location to apply the force on the imposter
  52598. */
  52599. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52600. /**
  52601. * Creates a physics body using the plugin
  52602. * @param impostor the imposter to create the physics body on
  52603. */
  52604. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52605. /**
  52606. * Removes the physics body from the imposter and disposes of the body's memory
  52607. * @param impostor imposter to remove the physics body from
  52608. */
  52609. removePhysicsBody(impostor: PhysicsImpostor): void;
  52610. /**
  52611. * Generates a joint
  52612. * @param impostorJoint the imposter joint to create the joint with
  52613. */
  52614. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52615. /**
  52616. * Removes a joint
  52617. * @param impostorJoint the imposter joint to remove the joint from
  52618. */
  52619. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52620. private _addMeshVerts;
  52621. /**
  52622. * Initialise the soft body vertices to match its object's (mesh) vertices
  52623. * Softbody vertices (nodes) are in world space and to match this
  52624. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52625. * @param impostor to create the softbody for
  52626. */
  52627. private _softVertexData;
  52628. /**
  52629. * Create an impostor's soft body
  52630. * @param impostor to create the softbody for
  52631. */
  52632. private _createSoftbody;
  52633. /**
  52634. * Create cloth for an impostor
  52635. * @param impostor to create the softbody for
  52636. */
  52637. private _createCloth;
  52638. /**
  52639. * Create rope for an impostor
  52640. * @param impostor to create the softbody for
  52641. */
  52642. private _createRope;
  52643. private _addHullVerts;
  52644. private _createShape;
  52645. /**
  52646. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52647. * @param impostor imposter containing the physics body and babylon object
  52648. */
  52649. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52650. /**
  52651. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52652. * @param impostor imposter containing the physics body and babylon object
  52653. * @param newPosition new position
  52654. * @param newRotation new rotation
  52655. */
  52656. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52657. /**
  52658. * If this plugin is supported
  52659. * @returns true if its supported
  52660. */
  52661. isSupported(): boolean;
  52662. /**
  52663. * Sets the linear velocity of the physics body
  52664. * @param impostor imposter to set the velocity on
  52665. * @param velocity velocity to set
  52666. */
  52667. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52668. /**
  52669. * Sets the angular velocity of the physics body
  52670. * @param impostor imposter to set the velocity on
  52671. * @param velocity velocity to set
  52672. */
  52673. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52674. /**
  52675. * gets the linear velocity
  52676. * @param impostor imposter to get linear velocity from
  52677. * @returns linear velocity
  52678. */
  52679. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52680. /**
  52681. * gets the angular velocity
  52682. * @param impostor imposter to get angular velocity from
  52683. * @returns angular velocity
  52684. */
  52685. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52686. /**
  52687. * Sets the mass of physics body
  52688. * @param impostor imposter to set the mass on
  52689. * @param mass mass to set
  52690. */
  52691. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52692. /**
  52693. * Gets the mass of the physics body
  52694. * @param impostor imposter to get the mass from
  52695. * @returns mass
  52696. */
  52697. getBodyMass(impostor: PhysicsImpostor): number;
  52698. /**
  52699. * Gets friction of the impostor
  52700. * @param impostor impostor to get friction from
  52701. * @returns friction value
  52702. */
  52703. getBodyFriction(impostor: PhysicsImpostor): number;
  52704. /**
  52705. * Sets friction of the impostor
  52706. * @param impostor impostor to set friction on
  52707. * @param friction friction value
  52708. */
  52709. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52710. /**
  52711. * Gets restitution of the impostor
  52712. * @param impostor impostor to get restitution from
  52713. * @returns restitution value
  52714. */
  52715. getBodyRestitution(impostor: PhysicsImpostor): number;
  52716. /**
  52717. * Sets resitution of the impostor
  52718. * @param impostor impostor to set resitution on
  52719. * @param restitution resitution value
  52720. */
  52721. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52722. /**
  52723. * Gets pressure inside the impostor
  52724. * @param impostor impostor to get pressure from
  52725. * @returns pressure value
  52726. */
  52727. getBodyPressure(impostor: PhysicsImpostor): number;
  52728. /**
  52729. * Sets pressure inside a soft body impostor
  52730. * Cloth and rope must remain 0 pressure
  52731. * @param impostor impostor to set pressure on
  52732. * @param pressure pressure value
  52733. */
  52734. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52735. /**
  52736. * Gets stiffness of the impostor
  52737. * @param impostor impostor to get stiffness from
  52738. * @returns pressure value
  52739. */
  52740. getBodyStiffness(impostor: PhysicsImpostor): number;
  52741. /**
  52742. * Sets stiffness of the impostor
  52743. * @param impostor impostor to set stiffness on
  52744. * @param stiffness stiffness value from 0 to 1
  52745. */
  52746. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52747. /**
  52748. * Gets velocityIterations of the impostor
  52749. * @param impostor impostor to get velocity iterations from
  52750. * @returns velocityIterations value
  52751. */
  52752. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52753. /**
  52754. * Sets velocityIterations of the impostor
  52755. * @param impostor impostor to set velocity iterations on
  52756. * @param velocityIterations velocityIterations value
  52757. */
  52758. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52759. /**
  52760. * Gets positionIterations of the impostor
  52761. * @param impostor impostor to get position iterations from
  52762. * @returns positionIterations value
  52763. */
  52764. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52765. /**
  52766. * Sets positionIterations of the impostor
  52767. * @param impostor impostor to set position on
  52768. * @param positionIterations positionIterations value
  52769. */
  52770. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52771. /**
  52772. * Append an anchor to a cloth object
  52773. * @param impostor is the cloth impostor to add anchor to
  52774. * @param otherImpostor is the rigid impostor to anchor to
  52775. * @param width ratio across width from 0 to 1
  52776. * @param height ratio up height from 0 to 1
  52777. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52778. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52779. */
  52780. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52781. /**
  52782. * Append an hook to a rope object
  52783. * @param impostor is the rope impostor to add hook to
  52784. * @param otherImpostor is the rigid impostor to hook to
  52785. * @param length ratio along the rope from 0 to 1
  52786. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52787. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52788. */
  52789. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52790. /**
  52791. * Sleeps the physics body and stops it from being active
  52792. * @param impostor impostor to sleep
  52793. */
  52794. sleepBody(impostor: PhysicsImpostor): void;
  52795. /**
  52796. * Activates the physics body
  52797. * @param impostor impostor to activate
  52798. */
  52799. wakeUpBody(impostor: PhysicsImpostor): void;
  52800. /**
  52801. * Updates the distance parameters of the joint
  52802. * @param joint joint to update
  52803. * @param maxDistance maximum distance of the joint
  52804. * @param minDistance minimum distance of the joint
  52805. */
  52806. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52807. /**
  52808. * Sets a motor on the joint
  52809. * @param joint joint to set motor on
  52810. * @param speed speed of the motor
  52811. * @param maxForce maximum force of the motor
  52812. * @param motorIndex index of the motor
  52813. */
  52814. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52815. /**
  52816. * Sets the motors limit
  52817. * @param joint joint to set limit on
  52818. * @param upperLimit upper limit
  52819. * @param lowerLimit lower limit
  52820. */
  52821. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52822. /**
  52823. * Syncs the position and rotation of a mesh with the impostor
  52824. * @param mesh mesh to sync
  52825. * @param impostor impostor to update the mesh with
  52826. */
  52827. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52828. /**
  52829. * Gets the radius of the impostor
  52830. * @param impostor impostor to get radius from
  52831. * @returns the radius
  52832. */
  52833. getRadius(impostor: PhysicsImpostor): number;
  52834. /**
  52835. * Gets the box size of the impostor
  52836. * @param impostor impostor to get box size from
  52837. * @param result the resulting box size
  52838. */
  52839. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52840. /**
  52841. * Disposes of the impostor
  52842. */
  52843. dispose(): void;
  52844. /**
  52845. * Does a raycast in the physics world
  52846. * @param from when should the ray start?
  52847. * @param to when should the ray end?
  52848. * @returns PhysicsRaycastResult
  52849. */
  52850. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52851. }
  52852. }
  52853. declare module "babylonjs/Probes/reflectionProbe" {
  52854. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52855. import { Vector3 } from "babylonjs/Maths/math.vector";
  52856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52857. import { Nullable } from "babylonjs/types";
  52858. import { Scene } from "babylonjs/scene";
  52859. module "babylonjs/abstractScene" {
  52860. interface AbstractScene {
  52861. /**
  52862. * The list of reflection probes added to the scene
  52863. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52864. */
  52865. reflectionProbes: Array<ReflectionProbe>;
  52866. /**
  52867. * Removes the given reflection probe from this scene.
  52868. * @param toRemove The reflection probe to remove
  52869. * @returns The index of the removed reflection probe
  52870. */
  52871. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52872. /**
  52873. * Adds the given reflection probe to this scene.
  52874. * @param newReflectionProbe The reflection probe to add
  52875. */
  52876. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52877. }
  52878. }
  52879. /**
  52880. * Class used to generate realtime reflection / refraction cube textures
  52881. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52882. */
  52883. export class ReflectionProbe {
  52884. /** defines the name of the probe */
  52885. name: string;
  52886. private _scene;
  52887. private _renderTargetTexture;
  52888. private _projectionMatrix;
  52889. private _viewMatrix;
  52890. private _target;
  52891. private _add;
  52892. private _attachedMesh;
  52893. private _invertYAxis;
  52894. /** Gets or sets probe position (center of the cube map) */
  52895. position: Vector3;
  52896. /**
  52897. * Creates a new reflection probe
  52898. * @param name defines the name of the probe
  52899. * @param size defines the texture resolution (for each face)
  52900. * @param scene defines the hosting scene
  52901. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52902. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52903. */
  52904. constructor(
  52905. /** defines the name of the probe */
  52906. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52907. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52908. samples: number;
  52909. /** Gets or sets the refresh rate to use (on every frame by default) */
  52910. refreshRate: number;
  52911. /**
  52912. * Gets the hosting scene
  52913. * @returns a Scene
  52914. */
  52915. getScene(): Scene;
  52916. /** Gets the internal CubeTexture used to render to */
  52917. readonly cubeTexture: RenderTargetTexture;
  52918. /** Gets the list of meshes to render */
  52919. readonly renderList: Nullable<AbstractMesh[]>;
  52920. /**
  52921. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52922. * @param mesh defines the mesh to attach to
  52923. */
  52924. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52925. /**
  52926. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52927. * @param renderingGroupId The rendering group id corresponding to its index
  52928. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52929. */
  52930. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52931. /**
  52932. * Clean all associated resources
  52933. */
  52934. dispose(): void;
  52935. /**
  52936. * Converts the reflection probe information to a readable string for debug purpose.
  52937. * @param fullDetails Supports for multiple levels of logging within scene loading
  52938. * @returns the human readable reflection probe info
  52939. */
  52940. toString(fullDetails?: boolean): string;
  52941. /**
  52942. * Get the class name of the relfection probe.
  52943. * @returns "ReflectionProbe"
  52944. */
  52945. getClassName(): string;
  52946. /**
  52947. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52948. * @returns The JSON representation of the texture
  52949. */
  52950. serialize(): any;
  52951. /**
  52952. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52953. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52954. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52955. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52956. * @returns The parsed reflection probe if successful
  52957. */
  52958. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52959. }
  52960. }
  52961. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52962. /** @hidden */
  52963. export var _BabylonLoaderRegistered: boolean;
  52964. }
  52965. declare module "babylonjs/Loading/Plugins/index" {
  52966. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52967. }
  52968. declare module "babylonjs/Loading/index" {
  52969. export * from "babylonjs/Loading/loadingScreen";
  52970. export * from "babylonjs/Loading/Plugins/index";
  52971. export * from "babylonjs/Loading/sceneLoader";
  52972. export * from "babylonjs/Loading/sceneLoaderFlags";
  52973. }
  52974. declare module "babylonjs/Materials/Background/index" {
  52975. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52976. }
  52977. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52978. import { Scene } from "babylonjs/scene";
  52979. import { Color3 } from "babylonjs/Maths/math.color";
  52980. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52982. /**
  52983. * The Physically based simple base material of BJS.
  52984. *
  52985. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52986. * It is used as the base class for both the specGloss and metalRough conventions.
  52987. */
  52988. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52989. /**
  52990. * Number of Simultaneous lights allowed on the material.
  52991. */
  52992. maxSimultaneousLights: number;
  52993. /**
  52994. * If sets to true, disables all the lights affecting the material.
  52995. */
  52996. disableLighting: boolean;
  52997. /**
  52998. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52999. */
  53000. environmentTexture: BaseTexture;
  53001. /**
  53002. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53003. */
  53004. invertNormalMapX: boolean;
  53005. /**
  53006. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53007. */
  53008. invertNormalMapY: boolean;
  53009. /**
  53010. * Normal map used in the model.
  53011. */
  53012. normalTexture: BaseTexture;
  53013. /**
  53014. * Emissivie color used to self-illuminate the model.
  53015. */
  53016. emissiveColor: Color3;
  53017. /**
  53018. * Emissivie texture used to self-illuminate the model.
  53019. */
  53020. emissiveTexture: BaseTexture;
  53021. /**
  53022. * Occlusion Channel Strenght.
  53023. */
  53024. occlusionStrength: number;
  53025. /**
  53026. * Occlusion Texture of the material (adding extra occlusion effects).
  53027. */
  53028. occlusionTexture: BaseTexture;
  53029. /**
  53030. * Defines the alpha limits in alpha test mode.
  53031. */
  53032. alphaCutOff: number;
  53033. /**
  53034. * Gets the current double sided mode.
  53035. */
  53036. /**
  53037. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53038. */
  53039. doubleSided: boolean;
  53040. /**
  53041. * Stores the pre-calculated light information of a mesh in a texture.
  53042. */
  53043. lightmapTexture: BaseTexture;
  53044. /**
  53045. * If true, the light map contains occlusion information instead of lighting info.
  53046. */
  53047. useLightmapAsShadowmap: boolean;
  53048. /**
  53049. * Instantiates a new PBRMaterial instance.
  53050. *
  53051. * @param name The material name
  53052. * @param scene The scene the material will be use in.
  53053. */
  53054. constructor(name: string, scene: Scene);
  53055. getClassName(): string;
  53056. }
  53057. }
  53058. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53059. import { Scene } from "babylonjs/scene";
  53060. import { Color3 } from "babylonjs/Maths/math.color";
  53061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53062. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53063. /**
  53064. * The PBR material of BJS following the metal roughness convention.
  53065. *
  53066. * This fits to the PBR convention in the GLTF definition:
  53067. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53068. */
  53069. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53070. /**
  53071. * The base color has two different interpretations depending on the value of metalness.
  53072. * When the material is a metal, the base color is the specific measured reflectance value
  53073. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53074. * of the material.
  53075. */
  53076. baseColor: Color3;
  53077. /**
  53078. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53079. * well as opacity information in the alpha channel.
  53080. */
  53081. baseTexture: BaseTexture;
  53082. /**
  53083. * Specifies the metallic scalar value of the material.
  53084. * Can also be used to scale the metalness values of the metallic texture.
  53085. */
  53086. metallic: number;
  53087. /**
  53088. * Specifies the roughness scalar value of the material.
  53089. * Can also be used to scale the roughness values of the metallic texture.
  53090. */
  53091. roughness: number;
  53092. /**
  53093. * Texture containing both the metallic value in the B channel and the
  53094. * roughness value in the G channel to keep better precision.
  53095. */
  53096. metallicRoughnessTexture: BaseTexture;
  53097. /**
  53098. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53099. *
  53100. * @param name The material name
  53101. * @param scene The scene the material will be use in.
  53102. */
  53103. constructor(name: string, scene: Scene);
  53104. /**
  53105. * Return the currrent class name of the material.
  53106. */
  53107. getClassName(): string;
  53108. /**
  53109. * Makes a duplicate of the current material.
  53110. * @param name - name to use for the new material.
  53111. */
  53112. clone(name: string): PBRMetallicRoughnessMaterial;
  53113. /**
  53114. * Serialize the material to a parsable JSON object.
  53115. */
  53116. serialize(): any;
  53117. /**
  53118. * Parses a JSON object correponding to the serialize function.
  53119. */
  53120. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53121. }
  53122. }
  53123. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53124. import { Scene } from "babylonjs/scene";
  53125. import { Color3 } from "babylonjs/Maths/math.color";
  53126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53127. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53128. /**
  53129. * The PBR material of BJS following the specular glossiness convention.
  53130. *
  53131. * This fits to the PBR convention in the GLTF definition:
  53132. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53133. */
  53134. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53135. /**
  53136. * Specifies the diffuse color of the material.
  53137. */
  53138. diffuseColor: Color3;
  53139. /**
  53140. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53141. * channel.
  53142. */
  53143. diffuseTexture: BaseTexture;
  53144. /**
  53145. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53146. */
  53147. specularColor: Color3;
  53148. /**
  53149. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53150. */
  53151. glossiness: number;
  53152. /**
  53153. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53154. */
  53155. specularGlossinessTexture: BaseTexture;
  53156. /**
  53157. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53158. *
  53159. * @param name The material name
  53160. * @param scene The scene the material will be use in.
  53161. */
  53162. constructor(name: string, scene: Scene);
  53163. /**
  53164. * Return the currrent class name of the material.
  53165. */
  53166. getClassName(): string;
  53167. /**
  53168. * Makes a duplicate of the current material.
  53169. * @param name - name to use for the new material.
  53170. */
  53171. clone(name: string): PBRSpecularGlossinessMaterial;
  53172. /**
  53173. * Serialize the material to a parsable JSON object.
  53174. */
  53175. serialize(): any;
  53176. /**
  53177. * Parses a JSON object correponding to the serialize function.
  53178. */
  53179. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53180. }
  53181. }
  53182. declare module "babylonjs/Materials/PBR/index" {
  53183. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53184. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53185. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53186. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53187. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53188. }
  53189. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53190. import { Nullable } from "babylonjs/types";
  53191. import { Scene } from "babylonjs/scene";
  53192. import { Matrix } from "babylonjs/Maths/math.vector";
  53193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53194. /**
  53195. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53196. * It can help converting any input color in a desired output one. This can then be used to create effects
  53197. * from sepia, black and white to sixties or futuristic rendering...
  53198. *
  53199. * The only supported format is currently 3dl.
  53200. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53201. */
  53202. export class ColorGradingTexture extends BaseTexture {
  53203. /**
  53204. * The current texture matrix. (will always be identity in color grading texture)
  53205. */
  53206. private _textureMatrix;
  53207. /**
  53208. * The texture URL.
  53209. */
  53210. url: string;
  53211. /**
  53212. * Empty line regex stored for GC.
  53213. */
  53214. private static _noneEmptyLineRegex;
  53215. private _engine;
  53216. /**
  53217. * Instantiates a ColorGradingTexture from the following parameters.
  53218. *
  53219. * @param url The location of the color gradind data (currently only supporting 3dl)
  53220. * @param scene The scene the texture will be used in
  53221. */
  53222. constructor(url: string, scene: Scene);
  53223. /**
  53224. * Returns the texture matrix used in most of the material.
  53225. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53226. */
  53227. getTextureMatrix(): Matrix;
  53228. /**
  53229. * Occurs when the file being loaded is a .3dl LUT file.
  53230. */
  53231. private load3dlTexture;
  53232. /**
  53233. * Starts the loading process of the texture.
  53234. */
  53235. private loadTexture;
  53236. /**
  53237. * Clones the color gradind texture.
  53238. */
  53239. clone(): ColorGradingTexture;
  53240. /**
  53241. * Called during delayed load for textures.
  53242. */
  53243. delayLoad(): void;
  53244. /**
  53245. * Parses a color grading texture serialized by Babylon.
  53246. * @param parsedTexture The texture information being parsedTexture
  53247. * @param scene The scene to load the texture in
  53248. * @param rootUrl The root url of the data assets to load
  53249. * @return A color gradind texture
  53250. */
  53251. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53252. /**
  53253. * Serializes the LUT texture to json format.
  53254. */
  53255. serialize(): any;
  53256. }
  53257. }
  53258. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53259. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53260. import { Scene } from "babylonjs/scene";
  53261. import { Nullable } from "babylonjs/types";
  53262. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53263. /**
  53264. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53265. */
  53266. export class EquiRectangularCubeTexture extends BaseTexture {
  53267. /** The six faces of the cube. */
  53268. private static _FacesMapping;
  53269. private _noMipmap;
  53270. private _onLoad;
  53271. private _onError;
  53272. /** The size of the cubemap. */
  53273. private _size;
  53274. /** The buffer of the image. */
  53275. private _buffer;
  53276. /** The width of the input image. */
  53277. private _width;
  53278. /** The height of the input image. */
  53279. private _height;
  53280. /** The URL to the image. */
  53281. url: string;
  53282. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53283. coordinatesMode: number;
  53284. /**
  53285. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53286. * @param url The location of the image
  53287. * @param scene The scene the texture will be used in
  53288. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53289. * @param noMipmap Forces to not generate the mipmap if true
  53290. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53291. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53292. * @param onLoad — defines a callback called when texture is loaded
  53293. * @param onError — defines a callback called if there is an error
  53294. */
  53295. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53296. /**
  53297. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53298. */
  53299. private loadImage;
  53300. /**
  53301. * Convert the image buffer into a cubemap and create a CubeTexture.
  53302. */
  53303. private loadTexture;
  53304. /**
  53305. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53306. * @param buffer The ArrayBuffer that should be converted.
  53307. * @returns The buffer as Float32Array.
  53308. */
  53309. private getFloat32ArrayFromArrayBuffer;
  53310. /**
  53311. * Get the current class name of the texture useful for serialization or dynamic coding.
  53312. * @returns "EquiRectangularCubeTexture"
  53313. */
  53314. getClassName(): string;
  53315. /**
  53316. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53317. * @returns A clone of the current EquiRectangularCubeTexture.
  53318. */
  53319. clone(): EquiRectangularCubeTexture;
  53320. }
  53321. }
  53322. declare module "babylonjs/Misc/tga" {
  53323. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53324. /**
  53325. * Based on jsTGALoader - Javascript loader for TGA file
  53326. * By Vincent Thibault
  53327. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53328. */
  53329. export class TGATools {
  53330. private static _TYPE_INDEXED;
  53331. private static _TYPE_RGB;
  53332. private static _TYPE_GREY;
  53333. private static _TYPE_RLE_INDEXED;
  53334. private static _TYPE_RLE_RGB;
  53335. private static _TYPE_RLE_GREY;
  53336. private static _ORIGIN_MASK;
  53337. private static _ORIGIN_SHIFT;
  53338. private static _ORIGIN_BL;
  53339. private static _ORIGIN_BR;
  53340. private static _ORIGIN_UL;
  53341. private static _ORIGIN_UR;
  53342. /**
  53343. * Gets the header of a TGA file
  53344. * @param data defines the TGA data
  53345. * @returns the header
  53346. */
  53347. static GetTGAHeader(data: Uint8Array): any;
  53348. /**
  53349. * Uploads TGA content to a Babylon Texture
  53350. * @hidden
  53351. */
  53352. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53353. /** @hidden */
  53354. 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;
  53355. /** @hidden */
  53356. 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;
  53357. /** @hidden */
  53358. 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;
  53359. /** @hidden */
  53360. 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;
  53361. /** @hidden */
  53362. 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;
  53363. /** @hidden */
  53364. 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;
  53365. }
  53366. }
  53367. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53368. import { Nullable } from "babylonjs/types";
  53369. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53370. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53371. /**
  53372. * Implementation of the TGA Texture Loader.
  53373. * @hidden
  53374. */
  53375. export class _TGATextureLoader implements IInternalTextureLoader {
  53376. /**
  53377. * Defines wether the loader supports cascade loading the different faces.
  53378. */
  53379. readonly supportCascades: boolean;
  53380. /**
  53381. * This returns if the loader support the current file information.
  53382. * @param extension defines the file extension of the file being loaded
  53383. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53384. * @param fallback defines the fallback internal texture if any
  53385. * @param isBase64 defines whether the texture is encoded as a base64
  53386. * @param isBuffer defines whether the texture data are stored as a buffer
  53387. * @returns true if the loader can load the specified file
  53388. */
  53389. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53390. /**
  53391. * Transform the url before loading if required.
  53392. * @param rootUrl the url of the texture
  53393. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53394. * @returns the transformed texture
  53395. */
  53396. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53397. /**
  53398. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53399. * @param rootUrl the url of the texture
  53400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53401. * @returns the fallback texture
  53402. */
  53403. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53404. /**
  53405. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53406. * @param data contains the texture data
  53407. * @param texture defines the BabylonJS internal texture
  53408. * @param createPolynomials will be true if polynomials have been requested
  53409. * @param onLoad defines the callback to trigger once the texture is ready
  53410. * @param onError defines the callback to trigger in case of error
  53411. */
  53412. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53413. /**
  53414. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53415. * @param data contains the texture data
  53416. * @param texture defines the BabylonJS internal texture
  53417. * @param callback defines the method to call once ready to upload
  53418. */
  53419. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53420. }
  53421. }
  53422. declare module "babylonjs/Misc/basis" {
  53423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53424. /**
  53425. * Info about the .basis files
  53426. */
  53427. class BasisFileInfo {
  53428. /**
  53429. * If the file has alpha
  53430. */
  53431. hasAlpha: boolean;
  53432. /**
  53433. * Info about each image of the basis file
  53434. */
  53435. images: Array<{
  53436. levels: Array<{
  53437. width: number;
  53438. height: number;
  53439. transcodedPixels: ArrayBufferView;
  53440. }>;
  53441. }>;
  53442. }
  53443. /**
  53444. * Result of transcoding a basis file
  53445. */
  53446. class TranscodeResult {
  53447. /**
  53448. * Info about the .basis file
  53449. */
  53450. fileInfo: BasisFileInfo;
  53451. /**
  53452. * Format to use when loading the file
  53453. */
  53454. format: number;
  53455. }
  53456. /**
  53457. * Configuration options for the Basis transcoder
  53458. */
  53459. export class BasisTranscodeConfiguration {
  53460. /**
  53461. * Supported compression formats used to determine the supported output format of the transcoder
  53462. */
  53463. supportedCompressionFormats?: {
  53464. /**
  53465. * etc1 compression format
  53466. */
  53467. etc1?: boolean;
  53468. /**
  53469. * s3tc compression format
  53470. */
  53471. s3tc?: boolean;
  53472. /**
  53473. * pvrtc compression format
  53474. */
  53475. pvrtc?: boolean;
  53476. /**
  53477. * etc2 compression format
  53478. */
  53479. etc2?: boolean;
  53480. };
  53481. /**
  53482. * If mipmap levels should be loaded for transcoded images (Default: true)
  53483. */
  53484. loadMipmapLevels?: boolean;
  53485. /**
  53486. * Index of a single image to load (Default: all images)
  53487. */
  53488. loadSingleImage?: number;
  53489. }
  53490. /**
  53491. * Used to load .Basis files
  53492. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53493. */
  53494. export class BasisTools {
  53495. private static _IgnoreSupportedFormats;
  53496. /**
  53497. * URL to use when loading the basis transcoder
  53498. */
  53499. static JSModuleURL: string;
  53500. /**
  53501. * URL to use when loading the wasm module for the transcoder
  53502. */
  53503. static WasmModuleURL: string;
  53504. /**
  53505. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53506. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53507. * @returns internal format corresponding to the Basis format
  53508. */
  53509. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53510. private static _WorkerPromise;
  53511. private static _Worker;
  53512. private static _actionId;
  53513. private static _CreateWorkerAsync;
  53514. /**
  53515. * Transcodes a loaded image file to compressed pixel data
  53516. * @param imageData image data to transcode
  53517. * @param config configuration options for the transcoding
  53518. * @returns a promise resulting in the transcoded image
  53519. */
  53520. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53521. /**
  53522. * Loads a texture from the transcode result
  53523. * @param texture texture load to
  53524. * @param transcodeResult the result of transcoding the basis file to load from
  53525. */
  53526. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53527. }
  53528. }
  53529. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53530. import { Nullable } from "babylonjs/types";
  53531. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53532. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53533. /**
  53534. * Loader for .basis file format
  53535. */
  53536. export class _BasisTextureLoader implements IInternalTextureLoader {
  53537. /**
  53538. * Defines whether the loader supports cascade loading the different faces.
  53539. */
  53540. readonly supportCascades: boolean;
  53541. /**
  53542. * This returns if the loader support the current file information.
  53543. * @param extension defines the file extension of the file being loaded
  53544. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53545. * @param fallback defines the fallback internal texture if any
  53546. * @param isBase64 defines whether the texture is encoded as a base64
  53547. * @param isBuffer defines whether the texture data are stored as a buffer
  53548. * @returns true if the loader can load the specified file
  53549. */
  53550. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53551. /**
  53552. * Transform the url before loading if required.
  53553. * @param rootUrl the url of the texture
  53554. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53555. * @returns the transformed texture
  53556. */
  53557. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53558. /**
  53559. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53560. * @param rootUrl the url of the texture
  53561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53562. * @returns the fallback texture
  53563. */
  53564. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53565. /**
  53566. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53567. * @param data contains the texture data
  53568. * @param texture defines the BabylonJS internal texture
  53569. * @param createPolynomials will be true if polynomials have been requested
  53570. * @param onLoad defines the callback to trigger once the texture is ready
  53571. * @param onError defines the callback to trigger in case of error
  53572. */
  53573. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53574. /**
  53575. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53576. * @param data contains the texture data
  53577. * @param texture defines the BabylonJS internal texture
  53578. * @param callback defines the method to call once ready to upload
  53579. */
  53580. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53581. }
  53582. }
  53583. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53584. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53585. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53586. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53587. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53588. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53589. }
  53590. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53591. import { Scene } from "babylonjs/scene";
  53592. import { Texture } from "babylonjs/Materials/Textures/texture";
  53593. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53594. /**
  53595. * 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.
  53596. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53597. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53598. */
  53599. export class CustomProceduralTexture extends ProceduralTexture {
  53600. private _animate;
  53601. private _time;
  53602. private _config;
  53603. private _texturePath;
  53604. /**
  53605. * Instantiates a new Custom Procedural Texture.
  53606. * 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.
  53607. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53608. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53609. * @param name Define the name of the texture
  53610. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53611. * @param size Define the size of the texture to create
  53612. * @param scene Define the scene the texture belongs to
  53613. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53614. * @param generateMipMaps Define if the texture should creates mip maps or not
  53615. */
  53616. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53617. private _loadJson;
  53618. /**
  53619. * Is the texture ready to be used ? (rendered at least once)
  53620. * @returns true if ready, otherwise, false.
  53621. */
  53622. isReady(): boolean;
  53623. /**
  53624. * Render the texture to its associated render target.
  53625. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53626. */
  53627. render(useCameraPostProcess?: boolean): void;
  53628. /**
  53629. * Update the list of dependant textures samplers in the shader.
  53630. */
  53631. updateTextures(): void;
  53632. /**
  53633. * Update the uniform values of the procedural texture in the shader.
  53634. */
  53635. updateShaderUniforms(): void;
  53636. /**
  53637. * Define if the texture animates or not.
  53638. */
  53639. animate: boolean;
  53640. }
  53641. }
  53642. declare module "babylonjs/Shaders/noise.fragment" {
  53643. /** @hidden */
  53644. export var noisePixelShader: {
  53645. name: string;
  53646. shader: string;
  53647. };
  53648. }
  53649. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53650. import { Nullable } from "babylonjs/types";
  53651. import { Scene } from "babylonjs/scene";
  53652. import { Texture } from "babylonjs/Materials/Textures/texture";
  53653. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53654. import "babylonjs/Shaders/noise.fragment";
  53655. /**
  53656. * Class used to generate noise procedural textures
  53657. */
  53658. export class NoiseProceduralTexture extends ProceduralTexture {
  53659. private _time;
  53660. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53661. brightness: number;
  53662. /** Defines the number of octaves to process */
  53663. octaves: number;
  53664. /** Defines the level of persistence (0.8 by default) */
  53665. persistence: number;
  53666. /** Gets or sets animation speed factor (default is 1) */
  53667. animationSpeedFactor: number;
  53668. /**
  53669. * Creates a new NoiseProceduralTexture
  53670. * @param name defines the name fo the texture
  53671. * @param size defines the size of the texture (default is 256)
  53672. * @param scene defines the hosting scene
  53673. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53674. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53675. */
  53676. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53677. private _updateShaderUniforms;
  53678. protected _getDefines(): string;
  53679. /** Generate the current state of the procedural texture */
  53680. render(useCameraPostProcess?: boolean): void;
  53681. /**
  53682. * Serializes this noise procedural texture
  53683. * @returns a serialized noise procedural texture object
  53684. */
  53685. serialize(): any;
  53686. /**
  53687. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53688. * @param parsedTexture defines parsed texture data
  53689. * @param scene defines the current scene
  53690. * @param rootUrl defines the root URL containing noise procedural texture information
  53691. * @returns a parsed NoiseProceduralTexture
  53692. */
  53693. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53694. }
  53695. }
  53696. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53697. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53698. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53699. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53700. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53701. }
  53702. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53703. import { Nullable } from "babylonjs/types";
  53704. import { Scene } from "babylonjs/scene";
  53705. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53706. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53707. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53708. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53709. /**
  53710. * Raw cube texture where the raw buffers are passed in
  53711. */
  53712. export class RawCubeTexture extends CubeTexture {
  53713. /**
  53714. * Creates a cube texture where the raw buffers are passed in.
  53715. * @param scene defines the scene the texture is attached to
  53716. * @param data defines the array of data to use to create each face
  53717. * @param size defines the size of the textures
  53718. * @param format defines the format of the data
  53719. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53720. * @param generateMipMaps defines if the engine should generate the mip levels
  53721. * @param invertY defines if data must be stored with Y axis inverted
  53722. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53723. * @param compression defines the compression used (null by default)
  53724. */
  53725. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53726. /**
  53727. * Updates the raw cube texture.
  53728. * @param data defines the data to store
  53729. * @param format defines the data format
  53730. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53731. * @param invertY defines if data must be stored with Y axis inverted
  53732. * @param compression defines the compression used (null by default)
  53733. * @param level defines which level of the texture to update
  53734. */
  53735. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53736. /**
  53737. * Updates a raw cube texture with RGBD encoded data.
  53738. * @param data defines the array of data [mipmap][face] to use to create each face
  53739. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53740. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53741. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53742. * @returns a promsie that resolves when the operation is complete
  53743. */
  53744. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53745. /**
  53746. * Clones the raw cube texture.
  53747. * @return a new cube texture
  53748. */
  53749. clone(): CubeTexture;
  53750. /** @hidden */
  53751. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53752. }
  53753. }
  53754. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53755. import { Scene } from "babylonjs/scene";
  53756. import { Texture } from "babylonjs/Materials/Textures/texture";
  53757. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53758. /**
  53759. * Class used to store 3D textures containing user data
  53760. */
  53761. export class RawTexture3D extends Texture {
  53762. /** Gets or sets the texture format to use */
  53763. format: number;
  53764. private _engine;
  53765. /**
  53766. * Create a new RawTexture3D
  53767. * @param data defines the data of the texture
  53768. * @param width defines the width of the texture
  53769. * @param height defines the height of the texture
  53770. * @param depth defines the depth of the texture
  53771. * @param format defines the texture format to use
  53772. * @param scene defines the hosting scene
  53773. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53774. * @param invertY defines if texture must be stored with Y axis inverted
  53775. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53776. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53777. */
  53778. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53779. /** Gets or sets the texture format to use */
  53780. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53781. /**
  53782. * Update the texture with new data
  53783. * @param data defines the data to store in the texture
  53784. */
  53785. update(data: ArrayBufferView): void;
  53786. }
  53787. }
  53788. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53789. import { Scene } from "babylonjs/scene";
  53790. import { Plane } from "babylonjs/Maths/math.plane";
  53791. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53792. /**
  53793. * Creates a refraction texture used by refraction channel of the standard material.
  53794. * It is like a mirror but to see through a material.
  53795. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53796. */
  53797. export class RefractionTexture extends RenderTargetTexture {
  53798. /**
  53799. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53800. * 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.
  53801. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53802. */
  53803. refractionPlane: Plane;
  53804. /**
  53805. * Define how deep under the surface we should see.
  53806. */
  53807. depth: number;
  53808. /**
  53809. * Creates a refraction texture used by refraction channel of the standard material.
  53810. * It is like a mirror but to see through a material.
  53811. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53812. * @param name Define the texture name
  53813. * @param size Define the size of the underlying texture
  53814. * @param scene Define the scene the refraction belongs to
  53815. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53816. */
  53817. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53818. /**
  53819. * Clone the refraction texture.
  53820. * @returns the cloned texture
  53821. */
  53822. clone(): RefractionTexture;
  53823. /**
  53824. * Serialize the texture to a JSON representation you could use in Parse later on
  53825. * @returns the serialized JSON representation
  53826. */
  53827. serialize(): any;
  53828. }
  53829. }
  53830. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53831. import { Nullable } from "babylonjs/types";
  53832. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53833. import { Matrix } from "babylonjs/Maths/math.vector";
  53834. import { Engine } from "babylonjs/Engines/engine";
  53835. import { Scene } from "babylonjs/scene";
  53836. /**
  53837. * Defines the options related to the creation of an HtmlElementTexture
  53838. */
  53839. export interface IHtmlElementTextureOptions {
  53840. /**
  53841. * Defines wether mip maps should be created or not.
  53842. */
  53843. generateMipMaps?: boolean;
  53844. /**
  53845. * Defines the sampling mode of the texture.
  53846. */
  53847. samplingMode?: number;
  53848. /**
  53849. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53850. */
  53851. engine: Nullable<Engine>;
  53852. /**
  53853. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53854. */
  53855. scene: Nullable<Scene>;
  53856. }
  53857. /**
  53858. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53859. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53860. * is automatically managed.
  53861. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53862. * in your application.
  53863. *
  53864. * As the update is not automatic, you need to call them manually.
  53865. */
  53866. export class HtmlElementTexture extends BaseTexture {
  53867. /**
  53868. * The texture URL.
  53869. */
  53870. element: HTMLVideoElement | HTMLCanvasElement;
  53871. private static readonly DefaultOptions;
  53872. private _textureMatrix;
  53873. private _engine;
  53874. private _isVideo;
  53875. private _generateMipMaps;
  53876. private _samplingMode;
  53877. /**
  53878. * Instantiates a HtmlElementTexture from the following parameters.
  53879. *
  53880. * @param name Defines the name of the texture
  53881. * @param element Defines the video or canvas the texture is filled with
  53882. * @param options Defines the other none mandatory texture creation options
  53883. */
  53884. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53885. private _createInternalTexture;
  53886. /**
  53887. * Returns the texture matrix used in most of the material.
  53888. */
  53889. getTextureMatrix(): Matrix;
  53890. /**
  53891. * Updates the content of the texture.
  53892. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53893. */
  53894. update(invertY?: Nullable<boolean>): void;
  53895. }
  53896. }
  53897. declare module "babylonjs/Materials/Textures/index" {
  53898. export * from "babylonjs/Materials/Textures/baseTexture";
  53899. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53900. export * from "babylonjs/Materials/Textures/cubeTexture";
  53901. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53902. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53903. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53904. export * from "babylonjs/Materials/Textures/internalTexture";
  53905. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53906. export * from "babylonjs/Materials/Textures/Loaders/index";
  53907. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53908. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53909. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53910. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53911. export * from "babylonjs/Materials/Textures/rawTexture";
  53912. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53913. export * from "babylonjs/Materials/Textures/refractionTexture";
  53914. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53915. export * from "babylonjs/Materials/Textures/texture";
  53916. export * from "babylonjs/Materials/Textures/videoTexture";
  53917. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53918. }
  53919. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53920. /**
  53921. * Enum used to define the target of a block
  53922. */
  53923. export enum NodeMaterialBlockTargets {
  53924. /** Vertex shader */
  53925. Vertex = 1,
  53926. /** Fragment shader */
  53927. Fragment = 2,
  53928. /** Neutral */
  53929. Neutral = 4,
  53930. /** Vertex and Fragment */
  53931. VertexAndFragment = 3
  53932. }
  53933. }
  53934. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53935. /**
  53936. * Defines the kind of connection point for node based material
  53937. */
  53938. export enum NodeMaterialBlockConnectionPointTypes {
  53939. /** Float */
  53940. Float = 1,
  53941. /** Int */
  53942. Int = 2,
  53943. /** Vector2 */
  53944. Vector2 = 4,
  53945. /** Vector3 */
  53946. Vector3 = 8,
  53947. /** Vector4 */
  53948. Vector4 = 16,
  53949. /** Color3 */
  53950. Color3 = 32,
  53951. /** Color4 */
  53952. Color4 = 64,
  53953. /** Matrix */
  53954. Matrix = 128,
  53955. /** Detect type based on connection */
  53956. AutoDetect = 1024,
  53957. /** Output type that will be defined by input type */
  53958. BasedOnInput = 2048
  53959. }
  53960. }
  53961. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53963. /**
  53964. * Root class for all node material optimizers
  53965. */
  53966. export class NodeMaterialOptimizer {
  53967. /**
  53968. * Function used to optimize a NodeMaterial graph
  53969. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53970. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53971. */
  53972. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53973. }
  53974. }
  53975. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53979. import { Scene } from "babylonjs/scene";
  53980. /**
  53981. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53982. */
  53983. export class TransformBlock extends NodeMaterialBlock {
  53984. /**
  53985. * Defines the value to use to complement W value to transform it to a Vector4
  53986. */
  53987. complementW: number;
  53988. /**
  53989. * Defines the value to use to complement z value to transform it to a Vector4
  53990. */
  53991. complementZ: number;
  53992. /**
  53993. * Creates a new TransformBlock
  53994. * @param name defines the block name
  53995. */
  53996. constructor(name: string);
  53997. /**
  53998. * Gets the current class name
  53999. * @returns the class name
  54000. */
  54001. getClassName(): string;
  54002. /**
  54003. * Gets the vector input
  54004. */
  54005. readonly vector: NodeMaterialConnectionPoint;
  54006. /**
  54007. * Gets the output component
  54008. */
  54009. readonly output: NodeMaterialConnectionPoint;
  54010. /**
  54011. * Gets the matrix transform input
  54012. */
  54013. readonly transform: NodeMaterialConnectionPoint;
  54014. protected _buildBlock(state: NodeMaterialBuildState): this;
  54015. serialize(): any;
  54016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54017. }
  54018. }
  54019. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54023. /**
  54024. * Block used to output the vertex position
  54025. */
  54026. export class VertexOutputBlock extends NodeMaterialBlock {
  54027. /**
  54028. * Creates a new VertexOutputBlock
  54029. * @param name defines the block name
  54030. */
  54031. constructor(name: string);
  54032. /**
  54033. * Gets the current class name
  54034. * @returns the class name
  54035. */
  54036. getClassName(): string;
  54037. /**
  54038. * Gets the vector input component
  54039. */
  54040. readonly vector: NodeMaterialConnectionPoint;
  54041. protected _buildBlock(state: NodeMaterialBuildState): this;
  54042. }
  54043. }
  54044. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54048. /**
  54049. * Block used to output the final color
  54050. */
  54051. export class FragmentOutputBlock extends NodeMaterialBlock {
  54052. /**
  54053. * Create a new FragmentOutputBlock
  54054. * @param name defines the block name
  54055. */
  54056. constructor(name: string);
  54057. /**
  54058. * Gets the current class name
  54059. * @returns the class name
  54060. */
  54061. getClassName(): string;
  54062. /**
  54063. * Gets the rgba input component
  54064. */
  54065. readonly rgba: NodeMaterialConnectionPoint;
  54066. /**
  54067. * Gets the rgb input component
  54068. */
  54069. readonly rgb: NodeMaterialConnectionPoint;
  54070. /**
  54071. * Gets the a input component
  54072. */
  54073. readonly a: NodeMaterialConnectionPoint;
  54074. protected _buildBlock(state: NodeMaterialBuildState): this;
  54075. }
  54076. }
  54077. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54079. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54080. import { Scene } from "babylonjs/scene";
  54081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54082. import { Matrix } from "babylonjs/Maths/math.vector";
  54083. import { Mesh } from "babylonjs/Meshes/mesh";
  54084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54085. import { Observable } from "babylonjs/Misc/observable";
  54086. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54087. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54088. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54089. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54090. import { Nullable } from "babylonjs/types";
  54091. /**
  54092. * Interface used to configure the node material editor
  54093. */
  54094. export interface INodeMaterialEditorOptions {
  54095. /** Define the URl to load node editor script */
  54096. editorURL?: string;
  54097. }
  54098. /** @hidden */
  54099. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54100. /** BONES */
  54101. NUM_BONE_INFLUENCERS: number;
  54102. BonesPerMesh: number;
  54103. BONETEXTURE: boolean;
  54104. /** MORPH TARGETS */
  54105. MORPHTARGETS: boolean;
  54106. MORPHTARGETS_NORMAL: boolean;
  54107. MORPHTARGETS_TANGENT: boolean;
  54108. MORPHTARGETS_UV: boolean;
  54109. NUM_MORPH_INFLUENCERS: number;
  54110. /** IMAGE PROCESSING */
  54111. IMAGEPROCESSING: boolean;
  54112. VIGNETTE: boolean;
  54113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54114. VIGNETTEBLENDMODEOPAQUE: boolean;
  54115. TONEMAPPING: boolean;
  54116. TONEMAPPING_ACES: boolean;
  54117. CONTRAST: boolean;
  54118. EXPOSURE: boolean;
  54119. COLORCURVES: boolean;
  54120. COLORGRADING: boolean;
  54121. COLORGRADING3D: boolean;
  54122. SAMPLER3DGREENDEPTH: boolean;
  54123. SAMPLER3DBGRMAP: boolean;
  54124. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54125. constructor();
  54126. setValue(name: string, value: boolean): void;
  54127. }
  54128. /**
  54129. * Class used to configure NodeMaterial
  54130. */
  54131. export interface INodeMaterialOptions {
  54132. /**
  54133. * Defines if blocks should emit comments
  54134. */
  54135. emitComments: boolean;
  54136. }
  54137. /**
  54138. * Class used to create a node based material built by assembling shader blocks
  54139. */
  54140. export class NodeMaterial extends PushMaterial {
  54141. private static _BuildIdGenerator;
  54142. private _options;
  54143. private _vertexCompilationState;
  54144. private _fragmentCompilationState;
  54145. private _sharedData;
  54146. private _buildId;
  54147. private _buildWasSuccessful;
  54148. private _cachedWorldViewMatrix;
  54149. private _cachedWorldViewProjectionMatrix;
  54150. private _optimizers;
  54151. /** Define the URl to load node editor script */
  54152. static EditorURL: string;
  54153. private BJSNODEMATERIALEDITOR;
  54154. /** Get the inspector from bundle or global */
  54155. private _getGlobalNodeMaterialEditor;
  54156. /**
  54157. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  54158. */
  54159. ignoreAlpha: boolean;
  54160. /**
  54161. * Defines the maximum number of lights that can be used in the material
  54162. */
  54163. maxSimultaneousLights: number;
  54164. /**
  54165. * Observable raised when the material is built
  54166. */
  54167. onBuildObservable: Observable<NodeMaterial>;
  54168. /**
  54169. * Gets or sets the root nodes of the material vertex shader
  54170. */
  54171. _vertexOutputNodes: NodeMaterialBlock[];
  54172. /**
  54173. * Gets or sets the root nodes of the material fragment (pixel) shader
  54174. */
  54175. _fragmentOutputNodes: NodeMaterialBlock[];
  54176. /** Gets or sets options to control the node material overall behavior */
  54177. options: INodeMaterialOptions;
  54178. /**
  54179. * Default configuration related to image processing available in the standard Material.
  54180. */
  54181. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54182. /**
  54183. * Gets the image processing configuration used either in this material.
  54184. */
  54185. /**
  54186. * Sets the Default image processing configuration used either in the this material.
  54187. *
  54188. * If sets to null, the scene one is in use.
  54189. */
  54190. imageProcessingConfiguration: ImageProcessingConfiguration;
  54191. /**
  54192. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54193. */
  54194. attachedBlocks: NodeMaterialBlock[];
  54195. /**
  54196. * Create a new node based material
  54197. * @param name defines the material name
  54198. * @param scene defines the hosting scene
  54199. * @param options defines creation option
  54200. */
  54201. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54202. /**
  54203. * Gets the current class name of the material e.g. "NodeMaterial"
  54204. * @returns the class name
  54205. */
  54206. getClassName(): string;
  54207. /**
  54208. * Keep track of the image processing observer to allow dispose and replace.
  54209. */
  54210. private _imageProcessingObserver;
  54211. /**
  54212. * Attaches a new image processing configuration to the Standard Material.
  54213. * @param configuration
  54214. */
  54215. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54216. /**
  54217. * Adds a new optimizer to the list of optimizers
  54218. * @param optimizer defines the optimizers to add
  54219. * @returns the current material
  54220. */
  54221. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54222. /**
  54223. * Remove an optimizer from the list of optimizers
  54224. * @param optimizer defines the optimizers to remove
  54225. * @returns the current material
  54226. */
  54227. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54228. /**
  54229. * Add a new block to the list of output nodes
  54230. * @param node defines the node to add
  54231. * @returns the current material
  54232. */
  54233. addOutputNode(node: NodeMaterialBlock): this;
  54234. /**
  54235. * Remove a block from the list of root nodes
  54236. * @param node defines the node to remove
  54237. * @returns the current material
  54238. */
  54239. removeOutputNode(node: NodeMaterialBlock): this;
  54240. private _addVertexOutputNode;
  54241. private _removeVertexOutputNode;
  54242. private _addFragmentOutputNode;
  54243. private _removeFragmentOutputNode;
  54244. /**
  54245. * Specifies if the material will require alpha blending
  54246. * @returns a boolean specifying if alpha blending is needed
  54247. */
  54248. needAlphaBlending(): boolean;
  54249. /**
  54250. * Specifies if this material should be rendered in alpha test mode
  54251. * @returns a boolean specifying if an alpha test is needed.
  54252. */
  54253. needAlphaTesting(): boolean;
  54254. private _initializeBlock;
  54255. private _resetDualBlocks;
  54256. /**
  54257. * Build the material and generates the inner effect
  54258. * @param verbose defines if the build should log activity
  54259. */
  54260. build(verbose?: boolean): void;
  54261. /**
  54262. * Runs an otpimization phase to try to improve the shader code
  54263. */
  54264. optimize(): void;
  54265. private _prepareDefinesForAttributes;
  54266. /**
  54267. * Get if the submesh is ready to be used and all its information available.
  54268. * Child classes can use it to update shaders
  54269. * @param mesh defines the mesh to check
  54270. * @param subMesh defines which submesh to check
  54271. * @param useInstances specifies that instances should be used
  54272. * @returns a boolean indicating that the submesh is ready or not
  54273. */
  54274. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54275. /**
  54276. * Get a string representing the shaders built by the current node graph
  54277. */
  54278. readonly compiledShaders: string;
  54279. /**
  54280. * Binds the world matrix to the material
  54281. * @param world defines the world transformation matrix
  54282. */
  54283. bindOnlyWorldMatrix(world: Matrix): void;
  54284. /**
  54285. * Binds the submesh to this material by preparing the effect and shader to draw
  54286. * @param world defines the world transformation matrix
  54287. * @param mesh defines the mesh containing the submesh
  54288. * @param subMesh defines the submesh to bind the material to
  54289. */
  54290. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54291. /**
  54292. * Gets the active textures from the material
  54293. * @returns an array of textures
  54294. */
  54295. getActiveTextures(): BaseTexture[];
  54296. /**
  54297. * Specifies if the material uses a texture
  54298. * @param texture defines the texture to check against the material
  54299. * @returns a boolean specifying if the material uses the texture
  54300. */
  54301. hasTexture(texture: BaseTexture): boolean;
  54302. /**
  54303. * Disposes the material
  54304. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54305. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54306. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54307. */
  54308. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54309. /** Creates the node editor window. */
  54310. private _createNodeEditor;
  54311. /**
  54312. * Launch the node material editor
  54313. * @param config Define the configuration of the editor
  54314. * @return a promise fulfilled when the node editor is visible
  54315. */
  54316. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54317. /**
  54318. * Clear the current material
  54319. */
  54320. clear(): void;
  54321. /**
  54322. * Clear the current material and set it to a default state
  54323. */
  54324. setToDefault(): void;
  54325. private _gatherBlocks;
  54326. /**
  54327. * Serializes this material in a JSON representation
  54328. * @returns the serialized material object
  54329. */
  54330. serialize(): any;
  54331. /**
  54332. * Clear the current graph and load a new one from a serialization object
  54333. * @param source defines the JSON representation of the material
  54334. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54335. */
  54336. loadFromSerialization(source: any, rootUrl?: string): void;
  54337. /**
  54338. * Creates a node material from parsed material data
  54339. * @param source defines the JSON representation of the material
  54340. * @param scene defines the hosting scene
  54341. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54342. * @returns a new node material
  54343. */
  54344. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54345. }
  54346. }
  54347. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54351. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54353. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54354. import { Effect } from "babylonjs/Materials/effect";
  54355. import { Mesh } from "babylonjs/Meshes/mesh";
  54356. import { Nullable } from "babylonjs/types";
  54357. import { Scene } from "babylonjs/scene";
  54358. /**
  54359. * Block used to read a texture from a sampler
  54360. */
  54361. export class TextureBlock extends NodeMaterialBlock {
  54362. private _defineName;
  54363. private _samplerName;
  54364. private _transformedUVName;
  54365. private _textureTransformName;
  54366. private _textureInfoName;
  54367. private _mainUVName;
  54368. private _mainUVDefineName;
  54369. /**
  54370. * Gets or sets the texture associated with the node
  54371. */
  54372. texture: Nullable<BaseTexture>;
  54373. /**
  54374. * Create a new TextureBlock
  54375. * @param name defines the block name
  54376. */
  54377. constructor(name: string);
  54378. /**
  54379. * Gets the current class name
  54380. * @returns the class name
  54381. */
  54382. getClassName(): string;
  54383. /**
  54384. * Gets the uv input component
  54385. */
  54386. readonly uv: NodeMaterialConnectionPoint;
  54387. /**
  54388. * Gets the rgba output component
  54389. */
  54390. readonly rgba: NodeMaterialConnectionPoint;
  54391. /**
  54392. * Gets the rgb output component
  54393. */
  54394. readonly rgb: NodeMaterialConnectionPoint;
  54395. /**
  54396. * Gets the r output component
  54397. */
  54398. readonly r: NodeMaterialConnectionPoint;
  54399. /**
  54400. * Gets the g output component
  54401. */
  54402. readonly g: NodeMaterialConnectionPoint;
  54403. /**
  54404. * Gets the b output component
  54405. */
  54406. readonly b: NodeMaterialConnectionPoint;
  54407. /**
  54408. * Gets the a output component
  54409. */
  54410. readonly a: NodeMaterialConnectionPoint;
  54411. autoConfigure(): void;
  54412. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54413. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54414. isReady(): boolean;
  54415. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54416. private _injectVertexCode;
  54417. private _writeOutput;
  54418. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54419. serialize(): any;
  54420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54421. }
  54422. }
  54423. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54424. /**
  54425. * Enum used to define well known values e.g. values automatically provided by the system
  54426. */
  54427. export enum NodeMaterialWellKnownValues {
  54428. /** World */
  54429. World = 1,
  54430. /** View */
  54431. View = 2,
  54432. /** Projection */
  54433. Projection = 3,
  54434. /** ViewProjection */
  54435. ViewProjection = 4,
  54436. /** WorldView */
  54437. WorldView = 5,
  54438. /** WorldViewProjection */
  54439. WorldViewProjection = 6,
  54440. /** CameraPosition */
  54441. CameraPosition = 7,
  54442. /** Fog Color */
  54443. FogColor = 8
  54444. }
  54445. }
  54446. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54452. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54453. import { Effect } from "babylonjs/Materials/effect";
  54454. import { Mesh } from "babylonjs/Meshes/mesh";
  54455. import { Nullable } from "babylonjs/types";
  54456. import { Scene } from "babylonjs/scene";
  54457. /**
  54458. * Block used to read a reflection texture from a sampler
  54459. */
  54460. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54461. private _define3DName;
  54462. private _defineCubicName;
  54463. private _defineExplicitName;
  54464. private _defineProjectionName;
  54465. private _defineLocalCubicName;
  54466. private _defineSphericalName;
  54467. private _definePlanarName;
  54468. private _defineEquirectangularName;
  54469. private _defineMirroredEquirectangularFixedName;
  54470. private _defineEquirectangularFixedName;
  54471. private _defineSkyboxName;
  54472. private _cubeSamplerName;
  54473. private _2DSamplerName;
  54474. private _positionUVWName;
  54475. private _directionWName;
  54476. private _reflectionCoordsName;
  54477. private _reflection2DCoordsName;
  54478. private _reflectionColorName;
  54479. private _reflectionMatrixName;
  54480. /**
  54481. * Gets or sets the texture associated with the node
  54482. */
  54483. texture: Nullable<BaseTexture>;
  54484. /**
  54485. * Create a new TextureBlock
  54486. * @param name defines the block name
  54487. */
  54488. constructor(name: string);
  54489. /**
  54490. * Gets the current class name
  54491. * @returns the class name
  54492. */
  54493. getClassName(): string;
  54494. /**
  54495. * Gets the world position input component
  54496. */
  54497. readonly position: NodeMaterialConnectionPoint;
  54498. /**
  54499. * Gets the world position input component
  54500. */
  54501. readonly worldPosition: NodeMaterialConnectionPoint;
  54502. /**
  54503. * Gets the world normal input component
  54504. */
  54505. readonly worldNormal: NodeMaterialConnectionPoint;
  54506. /**
  54507. * Gets the world input component
  54508. */
  54509. readonly world: NodeMaterialConnectionPoint;
  54510. /**
  54511. * Gets the camera (or eye) position component
  54512. */
  54513. readonly cameraPosition: NodeMaterialConnectionPoint;
  54514. /**
  54515. * Gets the view input component
  54516. */
  54517. readonly view: NodeMaterialConnectionPoint;
  54518. /**
  54519. * Gets the rgb output component
  54520. */
  54521. readonly rgb: NodeMaterialConnectionPoint;
  54522. /**
  54523. * Gets the r output component
  54524. */
  54525. readonly r: NodeMaterialConnectionPoint;
  54526. /**
  54527. * Gets the g output component
  54528. */
  54529. readonly g: NodeMaterialConnectionPoint;
  54530. /**
  54531. * Gets the b output component
  54532. */
  54533. readonly b: NodeMaterialConnectionPoint;
  54534. autoConfigure(): void;
  54535. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54536. isReady(): boolean;
  54537. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54538. private _injectVertexCode;
  54539. private _writeOutput;
  54540. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54541. serialize(): any;
  54542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54543. }
  54544. }
  54545. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54548. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54549. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54550. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54551. /**
  54552. * Class used to store shared data between 2 NodeMaterialBuildState
  54553. */
  54554. export class NodeMaterialBuildStateSharedData {
  54555. /**
  54556. * Gets the list of emitted varyings
  54557. */
  54558. varyings: string[];
  54559. /**
  54560. * Gets the varying declaration string
  54561. */
  54562. varyingDeclaration: string;
  54563. /**
  54564. * Input blocks
  54565. */
  54566. inputBlocks: InputBlock[];
  54567. /**
  54568. * Input blocks
  54569. */
  54570. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  54571. /**
  54572. * Bindable blocks (Blocks that need to set data to the effect)
  54573. */
  54574. bindableBlocks: NodeMaterialBlock[];
  54575. /**
  54576. * List of blocks that can provide a compilation fallback
  54577. */
  54578. blocksWithFallbacks: NodeMaterialBlock[];
  54579. /**
  54580. * List of blocks that can provide a define update
  54581. */
  54582. blocksWithDefines: NodeMaterialBlock[];
  54583. /**
  54584. * List of blocks that can provide a repeatable content
  54585. */
  54586. repeatableContentBlocks: NodeMaterialBlock[];
  54587. /**
  54588. * List of blocks that can provide a dynamic list of uniforms
  54589. */
  54590. dynamicUniformBlocks: NodeMaterialBlock[];
  54591. /**
  54592. * List of blocks that can block the isReady function for the material
  54593. */
  54594. blockingBlocks: NodeMaterialBlock[];
  54595. /**
  54596. * Build Id used to avoid multiple recompilations
  54597. */
  54598. buildId: number;
  54599. /** List of emitted variables */
  54600. variableNames: {
  54601. [key: string]: number;
  54602. };
  54603. /** List of emitted defines */
  54604. defineNames: {
  54605. [key: string]: number;
  54606. };
  54607. /** Should emit comments? */
  54608. emitComments: boolean;
  54609. /** Emit build activity */
  54610. verbose: boolean;
  54611. /**
  54612. * Gets the compilation hints emitted at compilation time
  54613. */
  54614. hints: {
  54615. needWorldViewMatrix: boolean;
  54616. needWorldViewProjectionMatrix: boolean;
  54617. needAlphaBlending: boolean;
  54618. needAlphaTesting: boolean;
  54619. };
  54620. /**
  54621. * List of compilation checks
  54622. */
  54623. checks: {
  54624. emitVertex: boolean;
  54625. emitFragment: boolean;
  54626. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54627. };
  54628. /** Creates a new shared data */
  54629. constructor();
  54630. /**
  54631. * Emits console errors and exceptions if there is a failing check
  54632. */
  54633. emitErrors(): void;
  54634. }
  54635. }
  54636. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54637. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54638. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54639. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54640. /**
  54641. * Class used to store node based material build state
  54642. */
  54643. export class NodeMaterialBuildState {
  54644. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54645. supportUniformBuffers: boolean;
  54646. /**
  54647. * Gets the list of emitted attributes
  54648. */
  54649. attributes: string[];
  54650. /**
  54651. * Gets the list of emitted uniforms
  54652. */
  54653. uniforms: string[];
  54654. /**
  54655. * Gets the list of emitted uniform buffers
  54656. */
  54657. uniformBuffers: string[];
  54658. /**
  54659. * Gets the list of emitted samplers
  54660. */
  54661. samplers: string[];
  54662. /**
  54663. * Gets the list of emitted functions
  54664. */
  54665. functions: {
  54666. [key: string]: string;
  54667. };
  54668. /**
  54669. * Gets the target of the compilation state
  54670. */
  54671. target: NodeMaterialBlockTargets;
  54672. /**
  54673. * Gets the list of emitted counters
  54674. */
  54675. counters: {
  54676. [key: string]: number;
  54677. };
  54678. /**
  54679. * Shared data between multiple NodeMaterialBuildState instances
  54680. */
  54681. sharedData: NodeMaterialBuildStateSharedData;
  54682. /** @hidden */
  54683. _vertexState: NodeMaterialBuildState;
  54684. /** @hidden */
  54685. _attributeDeclaration: string;
  54686. /** @hidden */
  54687. _uniformDeclaration: string;
  54688. /** @hidden */
  54689. _samplerDeclaration: string;
  54690. /** @hidden */
  54691. _varyingTransfer: string;
  54692. private _repeatableContentAnchorIndex;
  54693. /** @hidden */
  54694. _builtCompilationString: string;
  54695. /**
  54696. * Gets the emitted compilation strings
  54697. */
  54698. compilationString: string;
  54699. /**
  54700. * Finalize the compilation strings
  54701. * @param state defines the current compilation state
  54702. */
  54703. finalize(state: NodeMaterialBuildState): void;
  54704. /** @hidden */
  54705. readonly _repeatableContentAnchor: string;
  54706. /** @hidden */
  54707. _getFreeVariableName(prefix: string): string;
  54708. /** @hidden */
  54709. _getFreeDefineName(prefix: string): string;
  54710. /** @hidden */
  54711. _excludeVariableName(name: string): void;
  54712. /** @hidden */
  54713. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54714. /** @hidden */
  54715. _emitFunction(name: string, code: string, comments: string): void;
  54716. /** @hidden */
  54717. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54718. replaceStrings?: {
  54719. search: RegExp;
  54720. replace: string;
  54721. }[];
  54722. repeatKey?: string;
  54723. }): string;
  54724. /** @hidden */
  54725. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54726. repeatKey?: string;
  54727. removeAttributes?: boolean;
  54728. removeUniforms?: boolean;
  54729. removeVaryings?: boolean;
  54730. removeIfDef?: boolean;
  54731. replaceStrings?: {
  54732. search: RegExp;
  54733. replace: string;
  54734. }[];
  54735. }, storeKey?: string): void;
  54736. /** @hidden */
  54737. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54738. /** @hidden */
  54739. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54740. }
  54741. }
  54742. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54743. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54745. import { Nullable } from "babylonjs/types";
  54746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54747. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54748. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54750. import { Mesh } from "babylonjs/Meshes/mesh";
  54751. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54752. import { Scene } from "babylonjs/scene";
  54753. /**
  54754. * Defines a block that can be used inside a node based material
  54755. */
  54756. export class NodeMaterialBlock {
  54757. private _buildId;
  54758. private _buildTarget;
  54759. private _target;
  54760. private _isFinalMerger;
  54761. private _isInput;
  54762. /** @hidden */
  54763. _inputs: NodeMaterialConnectionPoint[];
  54764. /** @hidden */
  54765. _outputs: NodeMaterialConnectionPoint[];
  54766. /**
  54767. * Gets or sets the name of the block
  54768. */
  54769. name: string;
  54770. /**
  54771. * Gets or sets the unique id of the node
  54772. */
  54773. uniqueId: number;
  54774. /**
  54775. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54776. */
  54777. readonly isFinalMerger: boolean;
  54778. /**
  54779. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54780. */
  54781. readonly isInput: boolean;
  54782. /**
  54783. * Gets or sets the build Id
  54784. */
  54785. buildId: number;
  54786. /**
  54787. * Gets or sets the target of the block
  54788. */
  54789. target: NodeMaterialBlockTargets;
  54790. /**
  54791. * Gets the list of input points
  54792. */
  54793. readonly inputs: NodeMaterialConnectionPoint[];
  54794. /** Gets the list of output points */
  54795. readonly outputs: NodeMaterialConnectionPoint[];
  54796. /**
  54797. * Find an input by its name
  54798. * @param name defines the name of the input to look for
  54799. * @returns the input or null if not found
  54800. */
  54801. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54802. /**
  54803. * Find an output by its name
  54804. * @param name defines the name of the outputto look for
  54805. * @returns the output or null if not found
  54806. */
  54807. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54808. /**
  54809. * Creates a new NodeMaterialBlock
  54810. * @param name defines the block name
  54811. * @param target defines the target of that block (Vertex by default)
  54812. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54813. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54814. */
  54815. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54816. /**
  54817. * Initialize the block and prepare the context for build
  54818. * @param state defines the state that will be used for the build
  54819. */
  54820. initialize(state: NodeMaterialBuildState): void;
  54821. /**
  54822. * Bind data to effect. Will only be called for blocks with isBindable === true
  54823. * @param effect defines the effect to bind data to
  54824. * @param nodeMaterial defines the hosting NodeMaterial
  54825. * @param mesh defines the mesh that will be rendered
  54826. */
  54827. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54828. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54829. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54830. protected _writeFloat(value: number): string;
  54831. /**
  54832. * Gets the current class name e.g. "NodeMaterialBlock"
  54833. * @returns the class name
  54834. */
  54835. getClassName(): string;
  54836. /**
  54837. * Register a new input. Must be called inside a block constructor
  54838. * @param name defines the connection point name
  54839. * @param type defines the connection point type
  54840. * @param isOptional defines a boolean indicating that this input can be omitted
  54841. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54842. * @returns the current block
  54843. */
  54844. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54845. /**
  54846. * Register a new output. Must be called inside a block constructor
  54847. * @param name defines the connection point name
  54848. * @param type defines the connection point type
  54849. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54850. * @returns the current block
  54851. */
  54852. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54853. /**
  54854. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54855. * @param forOutput defines an optional connection point to check compatibility with
  54856. * @returns the first available input or null
  54857. */
  54858. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54859. /**
  54860. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54861. * @param forBlock defines an optional block to check compatibility with
  54862. * @returns the first available input or null
  54863. */
  54864. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54865. /**
  54866. * Gets the sibling of the given output
  54867. * @param current defines the current output
  54868. * @returns the next output in the list or null
  54869. */
  54870. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54871. /**
  54872. * Connect current block with another block
  54873. * @param other defines the block to connect with
  54874. * @param options define the various options to help pick the right connections
  54875. * @returns the current block
  54876. */
  54877. connectTo(other: NodeMaterialBlock, options?: {
  54878. input?: string;
  54879. output?: string;
  54880. outputSwizzle?: string;
  54881. }): this | undefined;
  54882. protected _buildBlock(state: NodeMaterialBuildState): void;
  54883. /**
  54884. * Add uniforms, samplers and uniform buffers at compilation time
  54885. * @param state defines the state to update
  54886. * @param nodeMaterial defines the node material requesting the update
  54887. * @param defines defines the material defines to update
  54888. */
  54889. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54890. /**
  54891. * Add potential fallbacks if shader compilation fails
  54892. * @param mesh defines the mesh to be rendered
  54893. * @param fallbacks defines the current prioritized list of fallbacks
  54894. */
  54895. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54896. /**
  54897. * Update defines for shader compilation
  54898. * @param mesh defines the mesh to be rendered
  54899. * @param nodeMaterial defines the node material requesting the update
  54900. * @param defines defines the material defines to update
  54901. * @param useInstances specifies that instances should be used
  54902. */
  54903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54904. /**
  54905. * Initialize defines for shader compilation
  54906. * @param mesh defines the mesh to be rendered
  54907. * @param nodeMaterial defines the node material requesting the update
  54908. * @param defines defines the material defines to be prepared
  54909. * @param useInstances specifies that instances should be used
  54910. */
  54911. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54912. /**
  54913. * Lets the block try to connect some inputs automatically
  54914. */
  54915. autoConfigure(): void;
  54916. /**
  54917. * Function called when a block is declared as repeatable content generator
  54918. * @param vertexShaderState defines the current compilation state for the vertex shader
  54919. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54920. * @param mesh defines the mesh to be rendered
  54921. * @param defines defines the material defines to update
  54922. */
  54923. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54924. /**
  54925. * Checks if the block is ready
  54926. * @param mesh defines the mesh to be rendered
  54927. * @param nodeMaterial defines the node material requesting the update
  54928. * @param defines defines the material defines to update
  54929. * @param useInstances specifies that instances should be used
  54930. * @returns true if the block is ready
  54931. */
  54932. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54933. private _processBuild;
  54934. /**
  54935. * Compile the current node and generate the shader code
  54936. * @param state defines the current compilation state (uniforms, samplers, current string)
  54937. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54938. * @returns true if already built
  54939. */
  54940. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54941. /**
  54942. * Clone the current block to a new identical block
  54943. * @param scene defines the hosting scene
  54944. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54945. * @returns a copy of the current block
  54946. */
  54947. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54948. /**
  54949. * Serializes this block in a JSON representation
  54950. * @returns the serialized block object
  54951. */
  54952. serialize(): any;
  54953. /** @hidden */
  54954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54955. }
  54956. }
  54957. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54958. /**
  54959. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54960. */
  54961. export enum NodeMaterialBlockConnectionPointMode {
  54962. /** Value is an uniform */
  54963. Uniform = 0,
  54964. /** Value is a mesh attribute */
  54965. Attribute = 1,
  54966. /** Value is a varying between vertex and fragment shaders */
  54967. Varying = 2,
  54968. /** Mode is undefined */
  54969. Undefined = 3
  54970. }
  54971. }
  54972. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54974. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54975. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54976. import { Nullable } from "babylonjs/types";
  54977. import { Effect } from "babylonjs/Materials/effect";
  54978. import { Matrix } from "babylonjs/Maths/math.vector";
  54979. import { Scene } from "babylonjs/scene";
  54980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54982. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54983. /**
  54984. * Block used to expose an input value
  54985. */
  54986. export class InputBlock extends NodeMaterialBlock {
  54987. private _mode;
  54988. private _associatedVariableName;
  54989. private _storedValue;
  54990. private _valueCallback;
  54991. private _type;
  54992. /** @hidden */
  54993. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54994. /**
  54995. * Gets or sets the connection point type (default is float)
  54996. */
  54997. readonly type: NodeMaterialBlockConnectionPointTypes;
  54998. /**
  54999. * Creates a new InputBlock
  55000. * @param name defines the block name
  55001. * @param target defines the target of that block (Vertex by default)
  55002. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55003. */
  55004. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55005. /**
  55006. * Gets the output component
  55007. */
  55008. readonly output: NodeMaterialConnectionPoint;
  55009. /**
  55010. * Set the source of this connection point to a vertex attribute
  55011. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55012. * @returns the current connection point
  55013. */
  55014. setAsAttribute(attributeName?: string): InputBlock;
  55015. /**
  55016. * Set the source of this connection point to a well known value
  55017. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  55018. * @returns the current connection point
  55019. */
  55020. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  55021. /**
  55022. * Gets or sets the value of that point.
  55023. * Please note that this value will be ignored if valueCallback is defined
  55024. */
  55025. value: any;
  55026. /**
  55027. * Gets or sets a callback used to get the value of that point.
  55028. * Please note that setting this value will force the connection point to ignore the value property
  55029. */
  55030. valueCallback: () => any;
  55031. /**
  55032. * Gets or sets the associated variable name in the shader
  55033. */
  55034. associatedVariableName: string;
  55035. /**
  55036. * Gets a boolean indicating that this connection point not defined yet
  55037. */
  55038. readonly isUndefined: boolean;
  55039. /**
  55040. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55041. * In this case the connection point name must be the name of the uniform to use.
  55042. * Can only be set on inputs
  55043. */
  55044. isUniform: boolean;
  55045. /**
  55046. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55047. * In this case the connection point name must be the name of the attribute to use
  55048. * Can only be set on inputs
  55049. */
  55050. isAttribute: boolean;
  55051. /**
  55052. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55053. * Can only be set on exit points
  55054. */
  55055. isVarying: boolean;
  55056. /**
  55057. * Gets a boolean indicating that the current connection point is a well known value
  55058. */
  55059. readonly isWellKnownValue: boolean;
  55060. /**
  55061. * Gets or sets the current well known value or null if not defined as well know value
  55062. */
  55063. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55064. /**
  55065. * Gets the current class name
  55066. * @returns the class name
  55067. */
  55068. getClassName(): string;
  55069. private _emitDefine;
  55070. /**
  55071. * Set the input block to its default value (based on its type)
  55072. */
  55073. setDefaultValue(): void;
  55074. private _emit;
  55075. /** @hidden */
  55076. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55077. /** @hidden */
  55078. _transmit(effect: Effect, scene: Scene): void;
  55079. protected _buildBlock(state: NodeMaterialBuildState): void;
  55080. serialize(): any;
  55081. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55082. }
  55083. }
  55084. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55085. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55086. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55087. import { Nullable } from "babylonjs/types";
  55088. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55090. /**
  55091. * Defines a connection point for a block
  55092. */
  55093. export class NodeMaterialConnectionPoint {
  55094. /** @hidden */
  55095. _ownerBlock: NodeMaterialBlock;
  55096. /** @hidden */
  55097. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55098. private _endpoints;
  55099. private _associatedVariableName;
  55100. /** @hidden */
  55101. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55102. private _type;
  55103. /** @hidden */
  55104. _enforceAssociatedVariableName: boolean;
  55105. /**
  55106. * Gets or sets the additional types supported byt this connection point
  55107. */
  55108. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55109. /**
  55110. * Gets or sets the associated variable name in the shader
  55111. */
  55112. associatedVariableName: string;
  55113. /**
  55114. * Gets or sets the connection point type (default is float)
  55115. */
  55116. type: NodeMaterialBlockConnectionPointTypes;
  55117. /**
  55118. * Gets or sets the connection point name
  55119. */
  55120. name: string;
  55121. /**
  55122. * Gets or sets a boolean indicating that this connection point can be omitted
  55123. */
  55124. isOptional: boolean;
  55125. /**
  55126. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55127. */
  55128. define: string;
  55129. /** Gets or sets the target of that connection point */
  55130. target: NodeMaterialBlockTargets;
  55131. /**
  55132. * Gets a boolean indicating that the current point is connected
  55133. */
  55134. readonly isConnected: boolean;
  55135. /**
  55136. * Gets a boolean indicating that the current point is connected to an input block
  55137. */
  55138. readonly isConnectedToInput: boolean;
  55139. /**
  55140. * Gets a the connected input block (if any)
  55141. */
  55142. readonly connectInputBlock: Nullable<InputBlock>;
  55143. /** Get the other side of the connection (if any) */
  55144. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55145. /** Get the block that owns this connection point */
  55146. readonly ownerBlock: NodeMaterialBlock;
  55147. /** Get the block connected on the other side of this connection (if any) */
  55148. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55149. /** Get the block connected on the endpoints of this connection (if any) */
  55150. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55151. /** Gets the list of connected endpoints */
  55152. readonly endpoints: NodeMaterialConnectionPoint[];
  55153. /**
  55154. * Creates a new connection point
  55155. * @param name defines the connection point name
  55156. * @param ownerBlock defines the block hosting this connection point
  55157. */
  55158. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55159. /**
  55160. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55161. * @returns the class name
  55162. */
  55163. getClassName(): string;
  55164. /**
  55165. * Gets an boolean indicating if the current point can be connected to another point
  55166. * @param connectionPoint defines the other connection point
  55167. * @returns true if the connection is possible
  55168. */
  55169. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55170. /**
  55171. * Connect this point to another connection point
  55172. * @param connectionPoint defines the other connection point
  55173. * @returns the current connection point
  55174. */
  55175. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55176. /**
  55177. * Disconnect this point from one of his endpoint
  55178. * @param endpoint defines the other connection point
  55179. * @returns the current connection point
  55180. */
  55181. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55182. /**
  55183. * Serializes this point in a JSON representation
  55184. * @returns the serialized point object
  55185. */
  55186. serialize(): any;
  55187. }
  55188. }
  55189. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55193. import { Mesh } from "babylonjs/Meshes/mesh";
  55194. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55196. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55197. /**
  55198. * Block used to add support for vertex skinning (bones)
  55199. */
  55200. export class BonesBlock extends NodeMaterialBlock {
  55201. /**
  55202. * Creates a new BonesBlock
  55203. * @param name defines the block name
  55204. */
  55205. constructor(name: string);
  55206. /**
  55207. * Initialize the block and prepare the context for build
  55208. * @param state defines the state that will be used for the build
  55209. */
  55210. initialize(state: NodeMaterialBuildState): void;
  55211. /**
  55212. * Gets the current class name
  55213. * @returns the class name
  55214. */
  55215. getClassName(): string;
  55216. /**
  55217. * Gets the matrix indices input component
  55218. */
  55219. readonly matricesIndices: NodeMaterialConnectionPoint;
  55220. /**
  55221. * Gets the matrix weights input component
  55222. */
  55223. readonly matricesWeights: NodeMaterialConnectionPoint;
  55224. /**
  55225. * Gets the extra matrix indices input component
  55226. */
  55227. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55228. /**
  55229. * Gets the extra matrix weights input component
  55230. */
  55231. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55232. /**
  55233. * Gets the world input component
  55234. */
  55235. readonly world: NodeMaterialConnectionPoint;
  55236. /**
  55237. * Gets the output component
  55238. */
  55239. readonly output: NodeMaterialConnectionPoint;
  55240. autoConfigure(): void;
  55241. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55242. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55243. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55244. protected _buildBlock(state: NodeMaterialBuildState): this;
  55245. }
  55246. }
  55247. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55248. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55250. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55252. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55253. /**
  55254. * Block used to add support for instances
  55255. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55256. */
  55257. export class InstancesBlock extends NodeMaterialBlock {
  55258. /**
  55259. * Creates a new InstancesBlock
  55260. * @param name defines the block name
  55261. */
  55262. constructor(name: string);
  55263. /**
  55264. * Gets the current class name
  55265. * @returns the class name
  55266. */
  55267. getClassName(): string;
  55268. /**
  55269. * Gets the first world row input component
  55270. */
  55271. readonly world0: NodeMaterialConnectionPoint;
  55272. /**
  55273. * Gets the second world row input component
  55274. */
  55275. readonly world1: NodeMaterialConnectionPoint;
  55276. /**
  55277. * Gets the third world row input component
  55278. */
  55279. readonly world2: NodeMaterialConnectionPoint;
  55280. /**
  55281. * Gets the forth world row input component
  55282. */
  55283. readonly world3: NodeMaterialConnectionPoint;
  55284. /**
  55285. * Gets the world input component
  55286. */
  55287. readonly world: NodeMaterialConnectionPoint;
  55288. /**
  55289. * Gets the output component
  55290. */
  55291. readonly output: NodeMaterialConnectionPoint;
  55292. autoConfigure(): void;
  55293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55294. protected _buildBlock(state: NodeMaterialBuildState): this;
  55295. }
  55296. }
  55297. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55298. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55299. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55300. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55302. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55303. import { Effect } from "babylonjs/Materials/effect";
  55304. import { Mesh } from "babylonjs/Meshes/mesh";
  55305. /**
  55306. * Block used to add morph targets support to vertex shader
  55307. */
  55308. export class MorphTargetsBlock extends NodeMaterialBlock {
  55309. private _repeatableContentAnchor;
  55310. private _repeatebleContentGenerated;
  55311. /**
  55312. * Create a new MorphTargetsBlock
  55313. * @param name defines the block name
  55314. */
  55315. constructor(name: string);
  55316. /**
  55317. * Gets the current class name
  55318. * @returns the class name
  55319. */
  55320. getClassName(): string;
  55321. /**
  55322. * Gets the position input component
  55323. */
  55324. readonly position: NodeMaterialConnectionPoint;
  55325. /**
  55326. * Gets the normal input component
  55327. */
  55328. readonly normal: NodeMaterialConnectionPoint;
  55329. /**
  55330. * Gets the tangent input component
  55331. */
  55332. readonly tangent: NodeMaterialConnectionPoint;
  55333. /**
  55334. * Gets the tangent input component
  55335. */
  55336. readonly uv: NodeMaterialConnectionPoint;
  55337. /**
  55338. * Gets the position output component
  55339. */
  55340. readonly positionOutput: NodeMaterialConnectionPoint;
  55341. /**
  55342. * Gets the normal output component
  55343. */
  55344. readonly normalOutput: NodeMaterialConnectionPoint;
  55345. /**
  55346. * Gets the tangent output component
  55347. */
  55348. readonly tangentOutput: NodeMaterialConnectionPoint;
  55349. /**
  55350. * Gets the tangent output component
  55351. */
  55352. readonly uvOutput: NodeMaterialConnectionPoint;
  55353. initialize(state: NodeMaterialBuildState): void;
  55354. autoConfigure(): void;
  55355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55356. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55357. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55358. protected _buildBlock(state: NodeMaterialBuildState): this;
  55359. }
  55360. }
  55361. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55362. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55363. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55364. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55365. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55366. }
  55367. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55371. /**
  55372. * Block used to add an alpha test in the fragment shader
  55373. */
  55374. export class AlphaTestBlock extends NodeMaterialBlock {
  55375. /**
  55376. * Gets or sets the alpha value where alpha testing happens
  55377. */
  55378. alphaCutOff: number;
  55379. /**
  55380. * Create a new AlphaTestBlock
  55381. * @param name defines the block name
  55382. */
  55383. constructor(name: string);
  55384. /**
  55385. * Gets the current class name
  55386. * @returns the class name
  55387. */
  55388. getClassName(): string;
  55389. /**
  55390. * Gets the color input component
  55391. */
  55392. readonly color: NodeMaterialConnectionPoint;
  55393. /**
  55394. * Gets the alpha input component
  55395. */
  55396. readonly alpha: NodeMaterialConnectionPoint;
  55397. protected _buildBlock(state: NodeMaterialBuildState): this;
  55398. }
  55399. }
  55400. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  55401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55404. /**
  55405. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55406. */
  55407. export class ColorMergerBlock extends NodeMaterialBlock {
  55408. /**
  55409. * Create a new ColorMergerBlock
  55410. * @param name defines the block name
  55411. */
  55412. constructor(name: string);
  55413. /**
  55414. * Gets the current class name
  55415. * @returns the class name
  55416. */
  55417. getClassName(): string;
  55418. /**
  55419. * Gets the r component (input)
  55420. */
  55421. readonly r: NodeMaterialConnectionPoint;
  55422. /**
  55423. * Gets the g component (input)
  55424. */
  55425. readonly g: NodeMaterialConnectionPoint;
  55426. /**
  55427. * Gets the b component (input)
  55428. */
  55429. readonly b: NodeMaterialConnectionPoint;
  55430. /**
  55431. * Gets the a component (input)
  55432. */
  55433. readonly a: NodeMaterialConnectionPoint;
  55434. /**
  55435. * Gets the rgba component (output)
  55436. */
  55437. readonly rgba: NodeMaterialConnectionPoint;
  55438. /**
  55439. * Gets the rgb component (output)
  55440. */
  55441. readonly rgb: NodeMaterialConnectionPoint;
  55442. protected _buildBlock(state: NodeMaterialBuildState): this;
  55443. }
  55444. }
  55445. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  55446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55449. /**
  55450. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55451. */
  55452. export class VectorMergerBlock extends NodeMaterialBlock {
  55453. /**
  55454. * Create a new VectorMergerBlock
  55455. * @param name defines the block name
  55456. */
  55457. constructor(name: string);
  55458. /**
  55459. * Gets the current class name
  55460. * @returns the class name
  55461. */
  55462. getClassName(): string;
  55463. /**
  55464. * Gets the x component (input)
  55465. */
  55466. readonly x: NodeMaterialConnectionPoint;
  55467. /**
  55468. * Gets the y component (input)
  55469. */
  55470. readonly y: NodeMaterialConnectionPoint;
  55471. /**
  55472. * Gets the z component (input)
  55473. */
  55474. readonly z: NodeMaterialConnectionPoint;
  55475. /**
  55476. * Gets the w component (input)
  55477. */
  55478. readonly w: NodeMaterialConnectionPoint;
  55479. /**
  55480. * Gets the xyzw component (output)
  55481. */
  55482. readonly xyzw: NodeMaterialConnectionPoint;
  55483. /**
  55484. * Gets the xyz component (output)
  55485. */
  55486. readonly xyz: NodeMaterialConnectionPoint;
  55487. /**
  55488. * Gets the xy component (output)
  55489. */
  55490. readonly xy: NodeMaterialConnectionPoint;
  55491. protected _buildBlock(state: NodeMaterialBuildState): this;
  55492. }
  55493. }
  55494. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  55495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55498. /**
  55499. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55500. */
  55501. export class ColorSplitterBlock extends NodeMaterialBlock {
  55502. /**
  55503. * Create a new ColorSplitterBlock
  55504. * @param name defines the block name
  55505. */
  55506. constructor(name: string);
  55507. /**
  55508. * Gets the current class name
  55509. * @returns the class name
  55510. */
  55511. getClassName(): string;
  55512. /**
  55513. * Gets the rgba component (input)
  55514. */
  55515. readonly rgba: NodeMaterialConnectionPoint;
  55516. /**
  55517. * Gets the rgb component (input)
  55518. */
  55519. readonly rgbIn: NodeMaterialConnectionPoint;
  55520. /**
  55521. * Gets the rgb component (output)
  55522. */
  55523. readonly rgbOut: NodeMaterialConnectionPoint;
  55524. /**
  55525. * Gets the r component (output)
  55526. */
  55527. readonly r: NodeMaterialConnectionPoint;
  55528. /**
  55529. * Gets the g component (output)
  55530. */
  55531. readonly g: NodeMaterialConnectionPoint;
  55532. /**
  55533. * Gets the b component (output)
  55534. */
  55535. readonly b: NodeMaterialConnectionPoint;
  55536. /**
  55537. * Gets the a component (output)
  55538. */
  55539. readonly a: NodeMaterialConnectionPoint;
  55540. protected _buildBlock(state: NodeMaterialBuildState): this;
  55541. }
  55542. }
  55543. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  55544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55547. /**
  55548. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55549. */
  55550. export class VectorSplitterBlock extends NodeMaterialBlock {
  55551. /**
  55552. * Create a new VectorSplitterBlock
  55553. * @param name defines the block name
  55554. */
  55555. constructor(name: string);
  55556. /**
  55557. * Gets the current class name
  55558. * @returns the class name
  55559. */
  55560. getClassName(): string;
  55561. /**
  55562. * Gets the xyzw component (input)
  55563. */
  55564. readonly xyzw: NodeMaterialConnectionPoint;
  55565. /**
  55566. * Gets the xyz component (input)
  55567. */
  55568. readonly xyzIn: NodeMaterialConnectionPoint;
  55569. /**
  55570. * Gets the xyz component (output)
  55571. */
  55572. readonly xyzOut: NodeMaterialConnectionPoint;
  55573. /**
  55574. * Gets the xy component (output)
  55575. */
  55576. readonly xy: NodeMaterialConnectionPoint;
  55577. /**
  55578. * Gets the x component (output)
  55579. */
  55580. readonly x: NodeMaterialConnectionPoint;
  55581. /**
  55582. * Gets the y component (output)
  55583. */
  55584. readonly y: NodeMaterialConnectionPoint;
  55585. /**
  55586. * Gets the z component (output)
  55587. */
  55588. readonly z: NodeMaterialConnectionPoint;
  55589. /**
  55590. * Gets the w component (output)
  55591. */
  55592. readonly w: NodeMaterialConnectionPoint;
  55593. protected _buildBlock(state: NodeMaterialBuildState): this;
  55594. }
  55595. }
  55596. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55598. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55599. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55601. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55602. import { Effect } from "babylonjs/Materials/effect";
  55603. import { Mesh } from "babylonjs/Meshes/mesh";
  55604. /**
  55605. * Block used to add image processing support to fragment shader
  55606. */
  55607. export class ImageProcessingBlock extends NodeMaterialBlock {
  55608. /**
  55609. * Create a new ImageProcessingBlock
  55610. * @param name defines the block name
  55611. */
  55612. constructor(name: string);
  55613. /**
  55614. * Gets the current class name
  55615. * @returns the class name
  55616. */
  55617. getClassName(): string;
  55618. /**
  55619. * Gets the color input component
  55620. */
  55621. readonly color: NodeMaterialConnectionPoint;
  55622. /**
  55623. * Gets the output component
  55624. */
  55625. readonly output: NodeMaterialConnectionPoint;
  55626. /**
  55627. * Initialize the block and prepare the context for build
  55628. * @param state defines the state that will be used for the build
  55629. */
  55630. initialize(state: NodeMaterialBuildState): void;
  55631. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55633. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55634. protected _buildBlock(state: NodeMaterialBuildState): this;
  55635. }
  55636. }
  55637. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55638. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55639. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55640. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  55641. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  55642. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  55643. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  55644. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55645. }
  55646. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55649. import { Mesh } from "babylonjs/Meshes/mesh";
  55650. import { Effect } from "babylonjs/Materials/effect";
  55651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55653. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55654. /**
  55655. * Block used to add support for scene fog
  55656. */
  55657. export class FogBlock extends NodeMaterialBlock {
  55658. private _fogDistanceName;
  55659. private _fogParameters;
  55660. /**
  55661. * Create a new FogBlock
  55662. * @param name defines the block name
  55663. */
  55664. constructor(name: string);
  55665. /**
  55666. * Gets the current class name
  55667. * @returns the class name
  55668. */
  55669. getClassName(): string;
  55670. /**
  55671. * Gets the world position input component
  55672. */
  55673. readonly worldPosition: NodeMaterialConnectionPoint;
  55674. /**
  55675. * Gets the view input component
  55676. */
  55677. readonly view: NodeMaterialConnectionPoint;
  55678. /**
  55679. * Gets the color input component
  55680. */
  55681. readonly color: NodeMaterialConnectionPoint;
  55682. /**
  55683. * Gets the fog color input component
  55684. */
  55685. readonly fogColor: NodeMaterialConnectionPoint;
  55686. /**
  55687. * Gets the output component
  55688. */
  55689. readonly output: NodeMaterialConnectionPoint;
  55690. autoConfigure(): void;
  55691. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55692. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55693. protected _buildBlock(state: NodeMaterialBuildState): this;
  55694. }
  55695. }
  55696. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55701. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55702. import { Effect } from "babylonjs/Materials/effect";
  55703. import { Mesh } from "babylonjs/Meshes/mesh";
  55704. import { Light } from "babylonjs/Lights/light";
  55705. import { Nullable } from "babylonjs/types";
  55706. import { Scene } from "babylonjs/scene";
  55707. /**
  55708. * Block used to add light in the fragment shader
  55709. */
  55710. export class LightBlock extends NodeMaterialBlock {
  55711. private _lightId;
  55712. /**
  55713. * Gets or sets the light associated with this block
  55714. */
  55715. light: Nullable<Light>;
  55716. /**
  55717. * Create a new LightBlock
  55718. * @param name defines the block name
  55719. */
  55720. constructor(name: string);
  55721. /**
  55722. * Gets the current class name
  55723. * @returns the class name
  55724. */
  55725. getClassName(): string;
  55726. /**
  55727. * Gets the world position input component
  55728. */
  55729. readonly worldPosition: NodeMaterialConnectionPoint;
  55730. /**
  55731. * Gets the world normal input component
  55732. */
  55733. readonly worldNormal: NodeMaterialConnectionPoint;
  55734. /**
  55735. * Gets the camera (or eye) position component
  55736. */
  55737. readonly cameraPosition: NodeMaterialConnectionPoint;
  55738. /**
  55739. * Gets the diffuse output component
  55740. */
  55741. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55742. /**
  55743. * Gets the specular output component
  55744. */
  55745. readonly specularOutput: NodeMaterialConnectionPoint;
  55746. autoConfigure(): void;
  55747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55748. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55749. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55750. private _injectVertexCode;
  55751. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55752. serialize(): any;
  55753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55754. }
  55755. }
  55756. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55757. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55758. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55759. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55760. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55761. }
  55762. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55763. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55764. }
  55765. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55769. /**
  55770. * Block used to multiply 2 values
  55771. */
  55772. export class MultiplyBlock extends NodeMaterialBlock {
  55773. /**
  55774. * Creates a new MultiplyBlock
  55775. * @param name defines the block name
  55776. */
  55777. constructor(name: string);
  55778. /**
  55779. * Gets the current class name
  55780. * @returns the class name
  55781. */
  55782. getClassName(): string;
  55783. /**
  55784. * Gets the left operand input component
  55785. */
  55786. readonly left: NodeMaterialConnectionPoint;
  55787. /**
  55788. * Gets the right operand input component
  55789. */
  55790. readonly right: NodeMaterialConnectionPoint;
  55791. /**
  55792. * Gets the output component
  55793. */
  55794. readonly output: NodeMaterialConnectionPoint;
  55795. protected _buildBlock(state: NodeMaterialBuildState): this;
  55796. }
  55797. }
  55798. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55802. /**
  55803. * Block used to add 2 vectors
  55804. */
  55805. export class AddBlock extends NodeMaterialBlock {
  55806. /**
  55807. * Creates a new AddBlock
  55808. * @param name defines the block name
  55809. */
  55810. constructor(name: string);
  55811. /**
  55812. * Gets the current class name
  55813. * @returns the class name
  55814. */
  55815. getClassName(): string;
  55816. /**
  55817. * Gets the left operand input component
  55818. */
  55819. readonly left: NodeMaterialConnectionPoint;
  55820. /**
  55821. * Gets the right operand input component
  55822. */
  55823. readonly right: NodeMaterialConnectionPoint;
  55824. /**
  55825. * Gets the output component
  55826. */
  55827. readonly output: NodeMaterialConnectionPoint;
  55828. protected _buildBlock(state: NodeMaterialBuildState): this;
  55829. }
  55830. }
  55831. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55835. /**
  55836. * Block used to clamp a float
  55837. */
  55838. export class ClampBlock extends NodeMaterialBlock {
  55839. /** Gets or sets the minimum range */
  55840. minimum: number;
  55841. /** Gets or sets the maximum range */
  55842. maximum: number;
  55843. /**
  55844. * Creates a new ClampBlock
  55845. * @param name defines the block name
  55846. */
  55847. constructor(name: string);
  55848. /**
  55849. * Gets the current class name
  55850. * @returns the class name
  55851. */
  55852. getClassName(): string;
  55853. /**
  55854. * Gets the value input component
  55855. */
  55856. readonly value: NodeMaterialConnectionPoint;
  55857. /**
  55858. * Gets the output component
  55859. */
  55860. readonly output: NodeMaterialConnectionPoint;
  55861. protected _buildBlock(state: NodeMaterialBuildState): this;
  55862. }
  55863. }
  55864. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55868. /**
  55869. * Block used to apply a cross product between 2 vectors
  55870. */
  55871. export class CrossBlock extends NodeMaterialBlock {
  55872. /**
  55873. * Creates a new CrossBlock
  55874. * @param name defines the block name
  55875. */
  55876. constructor(name: string);
  55877. /**
  55878. * Gets the current class name
  55879. * @returns the class name
  55880. */
  55881. getClassName(): string;
  55882. /**
  55883. * Gets the left operand input component
  55884. */
  55885. readonly left: NodeMaterialConnectionPoint;
  55886. /**
  55887. * Gets the right operand input component
  55888. */
  55889. readonly right: NodeMaterialConnectionPoint;
  55890. /**
  55891. * Gets the output component
  55892. */
  55893. readonly output: NodeMaterialConnectionPoint;
  55894. protected _buildBlock(state: NodeMaterialBuildState): this;
  55895. }
  55896. }
  55897. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55901. /**
  55902. * Block used to apply a dot product between 2 vectors
  55903. */
  55904. export class DotBlock extends NodeMaterialBlock {
  55905. /**
  55906. * Creates a new DotBlock
  55907. * @param name defines the block name
  55908. */
  55909. constructor(name: string);
  55910. /**
  55911. * Gets the current class name
  55912. * @returns the class name
  55913. */
  55914. getClassName(): string;
  55915. /**
  55916. * Gets the left operand input component
  55917. */
  55918. readonly left: NodeMaterialConnectionPoint;
  55919. /**
  55920. * Gets the right operand input component
  55921. */
  55922. readonly right: NodeMaterialConnectionPoint;
  55923. /**
  55924. * Gets the output component
  55925. */
  55926. readonly output: NodeMaterialConnectionPoint;
  55927. protected _buildBlock(state: NodeMaterialBuildState): this;
  55928. }
  55929. }
  55930. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  55931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55934. import { Vector2 } from "babylonjs/Maths/math.vector";
  55935. /**
  55936. * Block used to remap a float from a range to a new one
  55937. */
  55938. export class RemapBlock extends NodeMaterialBlock {
  55939. /**
  55940. * Gets or sets the source range
  55941. */
  55942. sourceRange: Vector2;
  55943. /**
  55944. * Gets or sets the target range
  55945. */
  55946. targetRange: Vector2;
  55947. /**
  55948. * Creates a new RemapBlock
  55949. * @param name defines the block name
  55950. */
  55951. constructor(name: string);
  55952. /**
  55953. * Gets the current class name
  55954. * @returns the class name
  55955. */
  55956. getClassName(): string;
  55957. /**
  55958. * Gets the input component
  55959. */
  55960. readonly input: NodeMaterialConnectionPoint;
  55961. /**
  55962. * Gets the output component
  55963. */
  55964. readonly output: NodeMaterialConnectionPoint;
  55965. protected _buildBlock(state: NodeMaterialBuildState): this;
  55966. }
  55967. }
  55968. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  55969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55972. /**
  55973. * Block used to normalize a vector
  55974. */
  55975. export class NormalizeBlock extends NodeMaterialBlock {
  55976. /**
  55977. * Creates a new NormalizeBlock
  55978. * @param name defines the block name
  55979. */
  55980. constructor(name: string);
  55981. /**
  55982. * Gets the current class name
  55983. * @returns the class name
  55984. */
  55985. getClassName(): string;
  55986. /**
  55987. * Gets the input component
  55988. */
  55989. readonly input: NodeMaterialConnectionPoint;
  55990. /**
  55991. * Gets the output component
  55992. */
  55993. readonly output: NodeMaterialConnectionPoint;
  55994. protected _buildBlock(state: NodeMaterialBuildState): this;
  55995. }
  55996. }
  55997. declare module "babylonjs/Materials/Node/Blocks/index" {
  55998. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  55999. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  56000. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  56001. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  56002. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  56003. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  56004. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  56005. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  56006. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  56007. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  56008. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  56009. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  56010. }
  56011. declare module "babylonjs/Materials/Node/Optimizers/index" {
  56012. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56013. }
  56014. declare module "babylonjs/Materials/Node/index" {
  56015. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  56016. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  56017. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56018. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  56019. export * from "babylonjs/Materials/Node/nodeMaterial";
  56020. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  56021. export * from "babylonjs/Materials/Node/Blocks/index";
  56022. export * from "babylonjs/Materials/Node/Optimizers/index";
  56023. }
  56024. declare module "babylonjs/Materials/effectRenderer" {
  56025. import { Nullable } from "babylonjs/types";
  56026. import { Texture } from "babylonjs/Materials/Textures/texture";
  56027. import { Engine } from "babylonjs/Engines/engine";
  56028. import { Viewport } from "babylonjs/Maths/math.viewport";
  56029. import { Observable } from "babylonjs/Misc/observable";
  56030. import { Effect } from "babylonjs/Materials/effect";
  56031. import "babylonjs/Shaders/postprocess.vertex";
  56032. /**
  56033. * Effect Render Options
  56034. */
  56035. export interface IEffectRendererOptions {
  56036. /**
  56037. * Defines the vertices positions.
  56038. */
  56039. positions?: number[];
  56040. /**
  56041. * Defines the indices.
  56042. */
  56043. indices?: number[];
  56044. }
  56045. /**
  56046. * Helper class to render one or more effects
  56047. */
  56048. export class EffectRenderer {
  56049. private engine;
  56050. private static _DefaultOptions;
  56051. private _vertexBuffers;
  56052. private _indexBuffer;
  56053. private _ringBufferIndex;
  56054. private _ringScreenBuffer;
  56055. private _fullscreenViewport;
  56056. private _getNextFrameBuffer;
  56057. /**
  56058. * Creates an effect renderer
  56059. * @param engine the engine to use for rendering
  56060. * @param options defines the options of the effect renderer
  56061. */
  56062. constructor(engine: Engine, options?: IEffectRendererOptions);
  56063. /**
  56064. * Sets the current viewport in normalized coordinates 0-1
  56065. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56066. */
  56067. setViewport(viewport?: Viewport): void;
  56068. /**
  56069. * Sets the current effect wrapper to use during draw.
  56070. * The effect needs to be ready before calling this api.
  56071. * This also sets the default full screen position attribute.
  56072. * @param effectWrapper Defines the effect to draw with
  56073. */
  56074. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56075. /**
  56076. * Draws a full screen quad.
  56077. */
  56078. draw(): void;
  56079. /**
  56080. * renders one or more effects to a specified texture
  56081. * @param effectWrappers list of effects to renderer
  56082. * @param outputTexture texture to draw to, if null it will render to the screen
  56083. */
  56084. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56085. /**
  56086. * Disposes of the effect renderer
  56087. */
  56088. dispose(): void;
  56089. }
  56090. /**
  56091. * Options to create an EffectWrapper
  56092. */
  56093. interface EffectWrapperCreationOptions {
  56094. /**
  56095. * Engine to use to create the effect
  56096. */
  56097. engine: Engine;
  56098. /**
  56099. * Fragment shader for the effect
  56100. */
  56101. fragmentShader: string;
  56102. /**
  56103. * Vertex shader for the effect
  56104. */
  56105. vertexShader?: string;
  56106. /**
  56107. * Attributes to use in the shader
  56108. */
  56109. attributeNames?: Array<string>;
  56110. /**
  56111. * Uniforms to use in the shader
  56112. */
  56113. uniformNames?: Array<string>;
  56114. /**
  56115. * Texture sampler names to use in the shader
  56116. */
  56117. samplerNames?: Array<string>;
  56118. /**
  56119. * The friendly name of the effect displayed in Spector.
  56120. */
  56121. name?: string;
  56122. }
  56123. /**
  56124. * Wraps an effect to be used for rendering
  56125. */
  56126. export class EffectWrapper {
  56127. /**
  56128. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56129. */
  56130. onApplyObservable: Observable<{}>;
  56131. /**
  56132. * The underlying effect
  56133. */
  56134. effect: Effect;
  56135. /**
  56136. * Creates an effect to be renderer
  56137. * @param creationOptions options to create the effect
  56138. */
  56139. constructor(creationOptions: EffectWrapperCreationOptions);
  56140. /**
  56141. * Disposes of the effect wrapper
  56142. */
  56143. dispose(): void;
  56144. }
  56145. }
  56146. declare module "babylonjs/Materials/index" {
  56147. export * from "babylonjs/Materials/Background/index";
  56148. export * from "babylonjs/Materials/colorCurves";
  56149. export * from "babylonjs/Materials/effect";
  56150. export * from "babylonjs/Materials/fresnelParameters";
  56151. export * from "babylonjs/Materials/imageProcessingConfiguration";
  56152. export * from "babylonjs/Materials/material";
  56153. export * from "babylonjs/Materials/materialDefines";
  56154. export * from "babylonjs/Materials/materialHelper";
  56155. export * from "babylonjs/Materials/multiMaterial";
  56156. export * from "babylonjs/Materials/PBR/index";
  56157. export * from "babylonjs/Materials/pushMaterial";
  56158. export * from "babylonjs/Materials/shaderMaterial";
  56159. export * from "babylonjs/Materials/standardMaterial";
  56160. export * from "babylonjs/Materials/Textures/index";
  56161. export * from "babylonjs/Materials/uniformBuffer";
  56162. export * from "babylonjs/Materials/materialFlags";
  56163. export * from "babylonjs/Materials/Node/index";
  56164. export * from "babylonjs/Materials/effectRenderer";
  56165. }
  56166. declare module "babylonjs/Maths/index" {
  56167. export * from "babylonjs/Maths/math.scalar";
  56168. export * from "babylonjs/Maths/math";
  56169. export * from "babylonjs/Maths/sphericalPolynomial";
  56170. }
  56171. declare module "babylonjs/Misc/workerPool" {
  56172. import { IDisposable } from "babylonjs/scene";
  56173. /**
  56174. * Helper class to push actions to a pool of workers.
  56175. */
  56176. export class WorkerPool implements IDisposable {
  56177. private _workerInfos;
  56178. private _pendingActions;
  56179. /**
  56180. * Constructor
  56181. * @param workers Array of workers to use for actions
  56182. */
  56183. constructor(workers: Array<Worker>);
  56184. /**
  56185. * Terminates all workers and clears any pending actions.
  56186. */
  56187. dispose(): void;
  56188. /**
  56189. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56190. * pended until a worker has completed its action.
  56191. * @param action The action to perform. Call onComplete when the action is complete.
  56192. */
  56193. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56194. private _execute;
  56195. }
  56196. }
  56197. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  56198. import { IDisposable } from "babylonjs/scene";
  56199. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56200. /**
  56201. * Configuration for Draco compression
  56202. */
  56203. export interface IDracoCompressionConfiguration {
  56204. /**
  56205. * Configuration for the decoder.
  56206. */
  56207. decoder: {
  56208. /**
  56209. * The url to the WebAssembly module.
  56210. */
  56211. wasmUrl?: string;
  56212. /**
  56213. * The url to the WebAssembly binary.
  56214. */
  56215. wasmBinaryUrl?: string;
  56216. /**
  56217. * The url to the fallback JavaScript module.
  56218. */
  56219. fallbackUrl?: string;
  56220. };
  56221. }
  56222. /**
  56223. * Draco compression (https://google.github.io/draco/)
  56224. *
  56225. * This class wraps the Draco module.
  56226. *
  56227. * **Encoder**
  56228. *
  56229. * The encoder is not currently implemented.
  56230. *
  56231. * **Decoder**
  56232. *
  56233. * 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.
  56234. *
  56235. * To update the configuration, use the following code:
  56236. * ```javascript
  56237. * DracoCompression.Configuration = {
  56238. * decoder: {
  56239. * wasmUrl: "<url to the WebAssembly library>",
  56240. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56241. * fallbackUrl: "<url to the fallback JavaScript library>",
  56242. * }
  56243. * };
  56244. * ```
  56245. *
  56246. * 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.
  56247. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56248. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56249. *
  56250. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56251. * ```javascript
  56252. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56253. * ```
  56254. *
  56255. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56256. */
  56257. export class DracoCompression implements IDisposable {
  56258. private _workerPoolPromise?;
  56259. private _decoderModulePromise?;
  56260. /**
  56261. * The configuration. Defaults to the following urls:
  56262. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56263. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56264. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56265. */
  56266. static Configuration: IDracoCompressionConfiguration;
  56267. /**
  56268. * Returns true if the decoder configuration is available.
  56269. */
  56270. static readonly DecoderAvailable: boolean;
  56271. /**
  56272. * Default number of workers to create when creating the draco compression object.
  56273. */
  56274. static DefaultNumWorkers: number;
  56275. private static GetDefaultNumWorkers;
  56276. private static _Default;
  56277. /**
  56278. * Default instance for the draco compression object.
  56279. */
  56280. static readonly Default: DracoCompression;
  56281. /**
  56282. * Constructor
  56283. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56284. */
  56285. constructor(numWorkers?: number);
  56286. /**
  56287. * Stop all async operations and release resources.
  56288. */
  56289. dispose(): void;
  56290. /**
  56291. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56292. * @returns a promise that resolves when ready
  56293. */
  56294. whenReadyAsync(): Promise<void>;
  56295. /**
  56296. * Decode Draco compressed mesh data to vertex data.
  56297. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56298. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56299. * @returns A promise that resolves with the decoded vertex data
  56300. */
  56301. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56302. [kind: string]: number;
  56303. }): Promise<VertexData>;
  56304. }
  56305. }
  56306. declare module "babylonjs/Meshes/Compression/index" {
  56307. export * from "babylonjs/Meshes/Compression/dracoCompression";
  56308. }
  56309. declare module "babylonjs/Meshes/csg" {
  56310. import { Nullable } from "babylonjs/types";
  56311. import { Scene } from "babylonjs/scene";
  56312. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56313. import { Mesh } from "babylonjs/Meshes/mesh";
  56314. import { Material } from "babylonjs/Materials/material";
  56315. /**
  56316. * Class for building Constructive Solid Geometry
  56317. */
  56318. export class CSG {
  56319. private polygons;
  56320. /**
  56321. * The world matrix
  56322. */
  56323. matrix: Matrix;
  56324. /**
  56325. * Stores the position
  56326. */
  56327. position: Vector3;
  56328. /**
  56329. * Stores the rotation
  56330. */
  56331. rotation: Vector3;
  56332. /**
  56333. * Stores the rotation quaternion
  56334. */
  56335. rotationQuaternion: Nullable<Quaternion>;
  56336. /**
  56337. * Stores the scaling vector
  56338. */
  56339. scaling: Vector3;
  56340. /**
  56341. * Convert the Mesh to CSG
  56342. * @param mesh The Mesh to convert to CSG
  56343. * @returns A new CSG from the Mesh
  56344. */
  56345. static FromMesh(mesh: Mesh): CSG;
  56346. /**
  56347. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56348. * @param polygons Polygons used to construct a CSG solid
  56349. */
  56350. private static FromPolygons;
  56351. /**
  56352. * Clones, or makes a deep copy, of the CSG
  56353. * @returns A new CSG
  56354. */
  56355. clone(): CSG;
  56356. /**
  56357. * Unions this CSG with another CSG
  56358. * @param csg The CSG to union against this CSG
  56359. * @returns The unioned CSG
  56360. */
  56361. union(csg: CSG): CSG;
  56362. /**
  56363. * Unions this CSG with another CSG in place
  56364. * @param csg The CSG to union against this CSG
  56365. */
  56366. unionInPlace(csg: CSG): void;
  56367. /**
  56368. * Subtracts this CSG with another CSG
  56369. * @param csg The CSG to subtract against this CSG
  56370. * @returns A new CSG
  56371. */
  56372. subtract(csg: CSG): CSG;
  56373. /**
  56374. * Subtracts this CSG with another CSG in place
  56375. * @param csg The CSG to subtact against this CSG
  56376. */
  56377. subtractInPlace(csg: CSG): void;
  56378. /**
  56379. * Intersect this CSG with another CSG
  56380. * @param csg The CSG to intersect against this CSG
  56381. * @returns A new CSG
  56382. */
  56383. intersect(csg: CSG): CSG;
  56384. /**
  56385. * Intersects this CSG with another CSG in place
  56386. * @param csg The CSG to intersect against this CSG
  56387. */
  56388. intersectInPlace(csg: CSG): void;
  56389. /**
  56390. * Return a new CSG solid with solid and empty space switched. This solid is
  56391. * not modified.
  56392. * @returns A new CSG solid with solid and empty space switched
  56393. */
  56394. inverse(): CSG;
  56395. /**
  56396. * Inverses the CSG in place
  56397. */
  56398. inverseInPlace(): void;
  56399. /**
  56400. * This is used to keep meshes transformations so they can be restored
  56401. * when we build back a Babylon Mesh
  56402. * NB : All CSG operations are performed in world coordinates
  56403. * @param csg The CSG to copy the transform attributes from
  56404. * @returns This CSG
  56405. */
  56406. copyTransformAttributes(csg: CSG): CSG;
  56407. /**
  56408. * Build Raw mesh from CSG
  56409. * Coordinates here are in world space
  56410. * @param name The name of the mesh geometry
  56411. * @param scene The Scene
  56412. * @param keepSubMeshes Specifies if the submeshes should be kept
  56413. * @returns A new Mesh
  56414. */
  56415. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  56416. /**
  56417. * Build Mesh from CSG taking material and transforms into account
  56418. * @param name The name of the Mesh
  56419. * @param material The material of the Mesh
  56420. * @param scene The Scene
  56421. * @param keepSubMeshes Specifies if submeshes should be kept
  56422. * @returns The new Mesh
  56423. */
  56424. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  56425. }
  56426. }
  56427. declare module "babylonjs/Meshes/trailMesh" {
  56428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56429. import { Mesh } from "babylonjs/Meshes/mesh";
  56430. import { Scene } from "babylonjs/scene";
  56431. /**
  56432. * Class used to create a trail following a mesh
  56433. */
  56434. export class TrailMesh extends Mesh {
  56435. private _generator;
  56436. private _autoStart;
  56437. private _running;
  56438. private _diameter;
  56439. private _length;
  56440. private _sectionPolygonPointsCount;
  56441. private _sectionVectors;
  56442. private _sectionNormalVectors;
  56443. private _beforeRenderObserver;
  56444. /**
  56445. * @constructor
  56446. * @param name The value used by scene.getMeshByName() to do a lookup.
  56447. * @param generator The mesh to generate a trail.
  56448. * @param scene The scene to add this mesh to.
  56449. * @param diameter Diameter of trailing mesh. Default is 1.
  56450. * @param length Length of trailing mesh. Default is 60.
  56451. * @param autoStart Automatically start trailing mesh. Default true.
  56452. */
  56453. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56454. /**
  56455. * "TrailMesh"
  56456. * @returns "TrailMesh"
  56457. */
  56458. getClassName(): string;
  56459. private _createMesh;
  56460. /**
  56461. * Start trailing mesh.
  56462. */
  56463. start(): void;
  56464. /**
  56465. * Stop trailing mesh.
  56466. */
  56467. stop(): void;
  56468. /**
  56469. * Update trailing mesh geometry.
  56470. */
  56471. update(): void;
  56472. /**
  56473. * Returns a new TrailMesh object.
  56474. * @param name is a string, the name given to the new mesh
  56475. * @param newGenerator use new generator object for cloned trail mesh
  56476. * @returns a new mesh
  56477. */
  56478. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56479. /**
  56480. * Serializes this trail mesh
  56481. * @param serializationObject object to write serialization to
  56482. */
  56483. serialize(serializationObject: any): void;
  56484. /**
  56485. * Parses a serialized trail mesh
  56486. * @param parsedMesh the serialized mesh
  56487. * @param scene the scene to create the trail mesh in
  56488. * @returns the created trail mesh
  56489. */
  56490. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56491. }
  56492. }
  56493. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56494. import { Nullable } from "babylonjs/types";
  56495. import { Scene } from "babylonjs/scene";
  56496. import { Vector4 } from "babylonjs/Maths/math.vector";
  56497. import { Color4 } from "babylonjs/Maths/math.color";
  56498. import { Mesh } from "babylonjs/Meshes/mesh";
  56499. /**
  56500. * Class containing static functions to help procedurally build meshes
  56501. */
  56502. export class TiledBoxBuilder {
  56503. /**
  56504. * Creates a box mesh
  56505. * 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)
  56506. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56510. * @param name defines the name of the mesh
  56511. * @param options defines the options used to create the mesh
  56512. * @param scene defines the hosting scene
  56513. * @returns the box mesh
  56514. */
  56515. static CreateTiledBox(name: string, options: {
  56516. pattern?: number;
  56517. width?: number;
  56518. height?: number;
  56519. depth?: number;
  56520. tileSize?: number;
  56521. tileWidth?: number;
  56522. tileHeight?: number;
  56523. alignHorizontal?: number;
  56524. alignVertical?: number;
  56525. faceUV?: Vector4[];
  56526. faceColors?: Color4[];
  56527. sideOrientation?: number;
  56528. updatable?: boolean;
  56529. }, scene?: Nullable<Scene>): Mesh;
  56530. }
  56531. }
  56532. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  56533. import { Vector4 } from "babylonjs/Maths/math.vector";
  56534. import { Mesh } from "babylonjs/Meshes/mesh";
  56535. /**
  56536. * Class containing static functions to help procedurally build meshes
  56537. */
  56538. export class TorusKnotBuilder {
  56539. /**
  56540. * Creates a torus knot mesh
  56541. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56542. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56543. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56544. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56548. * @param name defines the name of the mesh
  56549. * @param options defines the options used to create the mesh
  56550. * @param scene defines the hosting scene
  56551. * @returns the torus knot mesh
  56552. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56553. */
  56554. static CreateTorusKnot(name: string, options: {
  56555. radius?: number;
  56556. tube?: number;
  56557. radialSegments?: number;
  56558. tubularSegments?: number;
  56559. p?: number;
  56560. q?: number;
  56561. updatable?: boolean;
  56562. sideOrientation?: number;
  56563. frontUVs?: Vector4;
  56564. backUVs?: Vector4;
  56565. }, scene: any): Mesh;
  56566. }
  56567. }
  56568. declare module "babylonjs/Meshes/polygonMesh" {
  56569. import { Scene } from "babylonjs/scene";
  56570. import { Vector2 } from "babylonjs/Maths/math.vector";
  56571. import { Mesh } from "babylonjs/Meshes/mesh";
  56572. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56573. import { Path2 } from "babylonjs/Maths/math.path";
  56574. /**
  56575. * Polygon
  56576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56577. */
  56578. export class Polygon {
  56579. /**
  56580. * Creates a rectangle
  56581. * @param xmin bottom X coord
  56582. * @param ymin bottom Y coord
  56583. * @param xmax top X coord
  56584. * @param ymax top Y coord
  56585. * @returns points that make the resulting rectation
  56586. */
  56587. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56588. /**
  56589. * Creates a circle
  56590. * @param radius radius of circle
  56591. * @param cx scale in x
  56592. * @param cy scale in y
  56593. * @param numberOfSides number of sides that make up the circle
  56594. * @returns points that make the resulting circle
  56595. */
  56596. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56597. /**
  56598. * Creates a polygon from input string
  56599. * @param input Input polygon data
  56600. * @returns the parsed points
  56601. */
  56602. static Parse(input: string): Vector2[];
  56603. /**
  56604. * Starts building a polygon from x and y coordinates
  56605. * @param x x coordinate
  56606. * @param y y coordinate
  56607. * @returns the started path2
  56608. */
  56609. static StartingAt(x: number, y: number): Path2;
  56610. }
  56611. /**
  56612. * Builds a polygon
  56613. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56614. */
  56615. export class PolygonMeshBuilder {
  56616. private _points;
  56617. private _outlinepoints;
  56618. private _holes;
  56619. private _name;
  56620. private _scene;
  56621. private _epoints;
  56622. private _eholes;
  56623. private _addToepoint;
  56624. /**
  56625. * Babylon reference to the earcut plugin.
  56626. */
  56627. bjsEarcut: any;
  56628. /**
  56629. * Creates a PolygonMeshBuilder
  56630. * @param name name of the builder
  56631. * @param contours Path of the polygon
  56632. * @param scene scene to add to when creating the mesh
  56633. * @param earcutInjection can be used to inject your own earcut reference
  56634. */
  56635. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56636. /**
  56637. * Adds a whole within the polygon
  56638. * @param hole Array of points defining the hole
  56639. * @returns this
  56640. */
  56641. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56642. /**
  56643. * Creates the polygon
  56644. * @param updatable If the mesh should be updatable
  56645. * @param depth The depth of the mesh created
  56646. * @returns the created mesh
  56647. */
  56648. build(updatable?: boolean, depth?: number): Mesh;
  56649. /**
  56650. * Creates the polygon
  56651. * @param depth The depth of the mesh created
  56652. * @returns the created VertexData
  56653. */
  56654. buildVertexData(depth?: number): VertexData;
  56655. /**
  56656. * Adds a side to the polygon
  56657. * @param positions points that make the polygon
  56658. * @param normals normals of the polygon
  56659. * @param uvs uvs of the polygon
  56660. * @param indices indices of the polygon
  56661. * @param bounds bounds of the polygon
  56662. * @param points points of the polygon
  56663. * @param depth depth of the polygon
  56664. * @param flip flip of the polygon
  56665. */
  56666. private addSide;
  56667. }
  56668. }
  56669. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56670. import { Scene } from "babylonjs/scene";
  56671. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56672. import { Color4 } from "babylonjs/Maths/math.color";
  56673. import { Mesh } from "babylonjs/Meshes/mesh";
  56674. import { Nullable } from "babylonjs/types";
  56675. /**
  56676. * Class containing static functions to help procedurally build meshes
  56677. */
  56678. export class PolygonBuilder {
  56679. /**
  56680. * Creates a polygon mesh
  56681. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56682. * * 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
  56683. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56686. * * Remember you can only change the shape positions, not their number when updating a polygon
  56687. * @param name defines the name of the mesh
  56688. * @param options defines the options used to create the mesh
  56689. * @param scene defines the hosting scene
  56690. * @param earcutInjection can be used to inject your own earcut reference
  56691. * @returns the polygon mesh
  56692. */
  56693. static CreatePolygon(name: string, options: {
  56694. shape: Vector3[];
  56695. holes?: Vector3[][];
  56696. depth?: number;
  56697. faceUV?: Vector4[];
  56698. faceColors?: Color4[];
  56699. updatable?: boolean;
  56700. sideOrientation?: number;
  56701. frontUVs?: Vector4;
  56702. backUVs?: Vector4;
  56703. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56704. /**
  56705. * Creates an extruded polygon mesh, with depth in the Y direction.
  56706. * * 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)
  56707. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56708. * @param name defines the name of the mesh
  56709. * @param options defines the options used to create the mesh
  56710. * @param scene defines the hosting scene
  56711. * @param earcutInjection can be used to inject your own earcut reference
  56712. * @returns the polygon mesh
  56713. */
  56714. static ExtrudePolygon(name: string, options: {
  56715. shape: Vector3[];
  56716. holes?: Vector3[][];
  56717. depth?: number;
  56718. faceUV?: Vector4[];
  56719. faceColors?: Color4[];
  56720. updatable?: boolean;
  56721. sideOrientation?: number;
  56722. frontUVs?: Vector4;
  56723. backUVs?: Vector4;
  56724. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56725. }
  56726. }
  56727. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56728. import { Scene } from "babylonjs/scene";
  56729. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56730. import { Mesh } from "babylonjs/Meshes/mesh";
  56731. import { Nullable } from "babylonjs/types";
  56732. /**
  56733. * Class containing static functions to help procedurally build meshes
  56734. */
  56735. export class LatheBuilder {
  56736. /**
  56737. * Creates lathe mesh.
  56738. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56739. * * 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
  56740. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56741. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56742. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56743. * * 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
  56744. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56745. * * 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
  56746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56748. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56750. * @param name defines the name of the mesh
  56751. * @param options defines the options used to create the mesh
  56752. * @param scene defines the hosting scene
  56753. * @returns the lathe mesh
  56754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56755. */
  56756. static CreateLathe(name: string, options: {
  56757. shape: Vector3[];
  56758. radius?: number;
  56759. tessellation?: number;
  56760. clip?: number;
  56761. arc?: number;
  56762. closed?: boolean;
  56763. updatable?: boolean;
  56764. sideOrientation?: number;
  56765. frontUVs?: Vector4;
  56766. backUVs?: Vector4;
  56767. cap?: number;
  56768. invertUV?: boolean;
  56769. }, scene?: Nullable<Scene>): Mesh;
  56770. }
  56771. }
  56772. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56773. import { Nullable } from "babylonjs/types";
  56774. import { Scene } from "babylonjs/scene";
  56775. import { Vector4 } from "babylonjs/Maths/math.vector";
  56776. import { Mesh } from "babylonjs/Meshes/mesh";
  56777. /**
  56778. * Class containing static functions to help procedurally build meshes
  56779. */
  56780. export class TiledPlaneBuilder {
  56781. /**
  56782. * Creates a tiled plane mesh
  56783. * * The parameter `pattern` will, depending on value, do nothing or
  56784. * * * flip (reflect about central vertical) alternate tiles across and up
  56785. * * * flip every tile on alternate rows
  56786. * * * rotate (180 degs) alternate tiles across and up
  56787. * * * rotate every tile on alternate rows
  56788. * * * flip and rotate alternate tiles across and up
  56789. * * * flip and rotate every tile on alternate rows
  56790. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56791. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56793. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56794. * * 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)
  56795. * * 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)
  56796. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56797. * @param name defines the name of the mesh
  56798. * @param options defines the options used to create the mesh
  56799. * @param scene defines the hosting scene
  56800. * @returns the box mesh
  56801. */
  56802. static CreateTiledPlane(name: string, options: {
  56803. pattern?: number;
  56804. tileSize?: number;
  56805. tileWidth?: number;
  56806. tileHeight?: number;
  56807. size?: number;
  56808. width?: number;
  56809. height?: number;
  56810. alignHorizontal?: number;
  56811. alignVertical?: number;
  56812. sideOrientation?: number;
  56813. frontUVs?: Vector4;
  56814. backUVs?: Vector4;
  56815. updatable?: boolean;
  56816. }, scene?: Nullable<Scene>): Mesh;
  56817. }
  56818. }
  56819. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56820. import { Nullable } from "babylonjs/types";
  56821. import { Scene } from "babylonjs/scene";
  56822. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56823. import { Mesh } from "babylonjs/Meshes/mesh";
  56824. /**
  56825. * Class containing static functions to help procedurally build meshes
  56826. */
  56827. export class TubeBuilder {
  56828. /**
  56829. * Creates a tube mesh.
  56830. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56831. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56832. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56833. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56834. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56835. * * 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)
  56836. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56837. * * 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
  56838. * * 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
  56839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56841. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56843. * @param name defines the name of the mesh
  56844. * @param options defines the options used to create the mesh
  56845. * @param scene defines the hosting scene
  56846. * @returns the tube mesh
  56847. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56848. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56849. */
  56850. static CreateTube(name: string, options: {
  56851. path: Vector3[];
  56852. radius?: number;
  56853. tessellation?: number;
  56854. radiusFunction?: {
  56855. (i: number, distance: number): number;
  56856. };
  56857. cap?: number;
  56858. arc?: number;
  56859. updatable?: boolean;
  56860. sideOrientation?: number;
  56861. frontUVs?: Vector4;
  56862. backUVs?: Vector4;
  56863. instance?: Mesh;
  56864. invertUV?: boolean;
  56865. }, scene?: Nullable<Scene>): Mesh;
  56866. }
  56867. }
  56868. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56869. import { Scene } from "babylonjs/scene";
  56870. import { Vector4 } from "babylonjs/Maths/math.vector";
  56871. import { Mesh } from "babylonjs/Meshes/mesh";
  56872. import { Nullable } from "babylonjs/types";
  56873. /**
  56874. * Class containing static functions to help procedurally build meshes
  56875. */
  56876. export class IcoSphereBuilder {
  56877. /**
  56878. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56879. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56880. * * 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`)
  56881. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56882. * * 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
  56883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56886. * @param name defines the name of the mesh
  56887. * @param options defines the options used to create the mesh
  56888. * @param scene defines the hosting scene
  56889. * @returns the icosahedron mesh
  56890. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56891. */
  56892. static CreateIcoSphere(name: string, options: {
  56893. radius?: number;
  56894. radiusX?: number;
  56895. radiusY?: number;
  56896. radiusZ?: number;
  56897. flat?: boolean;
  56898. subdivisions?: number;
  56899. sideOrientation?: number;
  56900. frontUVs?: Vector4;
  56901. backUVs?: Vector4;
  56902. updatable?: boolean;
  56903. }, scene?: Nullable<Scene>): Mesh;
  56904. }
  56905. }
  56906. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  56907. import { Vector3 } from "babylonjs/Maths/math.vector";
  56908. import { Mesh } from "babylonjs/Meshes/mesh";
  56909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56910. /**
  56911. * Class containing static functions to help procedurally build meshes
  56912. */
  56913. export class DecalBuilder {
  56914. /**
  56915. * Creates a decal mesh.
  56916. * 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
  56917. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56918. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56919. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56920. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56921. * @param name defines the name of the mesh
  56922. * @param sourceMesh defines the mesh where the decal must be applied
  56923. * @param options defines the options used to create the mesh
  56924. * @param scene defines the hosting scene
  56925. * @returns the decal mesh
  56926. * @see https://doc.babylonjs.com/how_to/decals
  56927. */
  56928. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56929. position?: Vector3;
  56930. normal?: Vector3;
  56931. size?: Vector3;
  56932. angle?: number;
  56933. }): Mesh;
  56934. }
  56935. }
  56936. declare module "babylonjs/Meshes/meshBuilder" {
  56937. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  56938. import { Nullable } from "babylonjs/types";
  56939. import { Scene } from "babylonjs/scene";
  56940. import { Mesh } from "babylonjs/Meshes/mesh";
  56941. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56942. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  56943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56944. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56945. import { Plane } from "babylonjs/Maths/math.plane";
  56946. /**
  56947. * Class containing static functions to help procedurally build meshes
  56948. */
  56949. export class MeshBuilder {
  56950. /**
  56951. * Creates a box mesh
  56952. * * The parameter `size` sets the size (float) of each box side (default 1)
  56953. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56954. * * 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)
  56955. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56959. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56960. * @param name defines the name of the mesh
  56961. * @param options defines the options used to create the mesh
  56962. * @param scene defines the hosting scene
  56963. * @returns the box mesh
  56964. */
  56965. static CreateBox(name: string, options: {
  56966. size?: number;
  56967. width?: number;
  56968. height?: number;
  56969. depth?: number;
  56970. faceUV?: Vector4[];
  56971. faceColors?: Color4[];
  56972. sideOrientation?: number;
  56973. frontUVs?: Vector4;
  56974. backUVs?: Vector4;
  56975. updatable?: boolean;
  56976. }, scene?: Nullable<Scene>): Mesh;
  56977. /**
  56978. * Creates a tiled box mesh
  56979. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56981. * @param name defines the name of the mesh
  56982. * @param options defines the options used to create the mesh
  56983. * @param scene defines the hosting scene
  56984. * @returns the tiled box mesh
  56985. */
  56986. static CreateTiledBox(name: string, options: {
  56987. pattern?: number;
  56988. size?: number;
  56989. width?: number;
  56990. height?: number;
  56991. depth: number;
  56992. tileSize?: number;
  56993. tileWidth?: number;
  56994. tileHeight?: number;
  56995. faceUV?: Vector4[];
  56996. faceColors?: Color4[];
  56997. alignHorizontal?: number;
  56998. alignVertical?: number;
  56999. sideOrientation?: number;
  57000. updatable?: boolean;
  57001. }, scene?: Nullable<Scene>): Mesh;
  57002. /**
  57003. * Creates a sphere mesh
  57004. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57005. * * 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`)
  57006. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57007. * * 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
  57008. * * 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)
  57009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57012. * @param name defines the name of the mesh
  57013. * @param options defines the options used to create the mesh
  57014. * @param scene defines the hosting scene
  57015. * @returns the sphere mesh
  57016. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57017. */
  57018. static CreateSphere(name: string, options: {
  57019. segments?: number;
  57020. diameter?: number;
  57021. diameterX?: number;
  57022. diameterY?: number;
  57023. diameterZ?: number;
  57024. arc?: number;
  57025. slice?: number;
  57026. sideOrientation?: number;
  57027. frontUVs?: Vector4;
  57028. backUVs?: Vector4;
  57029. updatable?: boolean;
  57030. }, scene?: Nullable<Scene>): Mesh;
  57031. /**
  57032. * Creates a plane polygonal mesh. By default, this is a disc
  57033. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57034. * * 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
  57035. * * 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
  57036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57039. * @param name defines the name of the mesh
  57040. * @param options defines the options used to create the mesh
  57041. * @param scene defines the hosting scene
  57042. * @returns the plane polygonal mesh
  57043. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57044. */
  57045. static CreateDisc(name: string, options: {
  57046. radius?: number;
  57047. tessellation?: number;
  57048. arc?: number;
  57049. updatable?: boolean;
  57050. sideOrientation?: number;
  57051. frontUVs?: Vector4;
  57052. backUVs?: Vector4;
  57053. }, scene?: Nullable<Scene>): Mesh;
  57054. /**
  57055. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57056. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57057. * * 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`)
  57058. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57059. * * 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
  57060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57063. * @param name defines the name of the mesh
  57064. * @param options defines the options used to create the mesh
  57065. * @param scene defines the hosting scene
  57066. * @returns the icosahedron mesh
  57067. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57068. */
  57069. static CreateIcoSphere(name: string, options: {
  57070. radius?: number;
  57071. radiusX?: number;
  57072. radiusY?: number;
  57073. radiusZ?: number;
  57074. flat?: boolean;
  57075. subdivisions?: number;
  57076. sideOrientation?: number;
  57077. frontUVs?: Vector4;
  57078. backUVs?: Vector4;
  57079. updatable?: boolean;
  57080. }, scene?: Nullable<Scene>): Mesh;
  57081. /**
  57082. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57083. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57084. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57085. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57086. * * 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
  57087. * * 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
  57088. * * 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
  57089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57091. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57092. * * 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
  57093. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57094. * * 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
  57095. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57097. * @param name defines the name of the mesh
  57098. * @param options defines the options used to create the mesh
  57099. * @param scene defines the hosting scene
  57100. * @returns the ribbon mesh
  57101. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57102. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57103. */
  57104. static CreateRibbon(name: string, options: {
  57105. pathArray: Vector3[][];
  57106. closeArray?: boolean;
  57107. closePath?: boolean;
  57108. offset?: number;
  57109. updatable?: boolean;
  57110. sideOrientation?: number;
  57111. frontUVs?: Vector4;
  57112. backUVs?: Vector4;
  57113. instance?: Mesh;
  57114. invertUV?: boolean;
  57115. uvs?: Vector2[];
  57116. colors?: Color4[];
  57117. }, scene?: Nullable<Scene>): Mesh;
  57118. /**
  57119. * Creates a cylinder or a cone mesh
  57120. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57121. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57122. * * 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.
  57123. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57124. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57125. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57126. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57127. * * 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).
  57128. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57129. * * 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).
  57130. * * 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
  57131. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57132. * * 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
  57133. * * 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.
  57134. * * If `enclose` is false, a ring surface is one element.
  57135. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57136. * * 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
  57137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57140. * @param name defines the name of the mesh
  57141. * @param options defines the options used to create the mesh
  57142. * @param scene defines the hosting scene
  57143. * @returns the cylinder mesh
  57144. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57145. */
  57146. static CreateCylinder(name: string, options: {
  57147. height?: number;
  57148. diameterTop?: number;
  57149. diameterBottom?: number;
  57150. diameter?: number;
  57151. tessellation?: number;
  57152. subdivisions?: number;
  57153. arc?: number;
  57154. faceColors?: Color4[];
  57155. faceUV?: Vector4[];
  57156. updatable?: boolean;
  57157. hasRings?: boolean;
  57158. enclose?: boolean;
  57159. cap?: number;
  57160. sideOrientation?: number;
  57161. frontUVs?: Vector4;
  57162. backUVs?: Vector4;
  57163. }, scene?: Nullable<Scene>): Mesh;
  57164. /**
  57165. * Creates a torus mesh
  57166. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57167. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57168. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57172. * @param name defines the name of the mesh
  57173. * @param options defines the options used to create the mesh
  57174. * @param scene defines the hosting scene
  57175. * @returns the torus mesh
  57176. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57177. */
  57178. static CreateTorus(name: string, options: {
  57179. diameter?: number;
  57180. thickness?: number;
  57181. tessellation?: number;
  57182. updatable?: boolean;
  57183. sideOrientation?: number;
  57184. frontUVs?: Vector4;
  57185. backUVs?: Vector4;
  57186. }, scene?: Nullable<Scene>): Mesh;
  57187. /**
  57188. * Creates a torus knot mesh
  57189. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57190. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57191. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57192. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57196. * @param name defines the name of the mesh
  57197. * @param options defines the options used to create the mesh
  57198. * @param scene defines the hosting scene
  57199. * @returns the torus knot mesh
  57200. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57201. */
  57202. static CreateTorusKnot(name: string, options: {
  57203. radius?: number;
  57204. tube?: number;
  57205. radialSegments?: number;
  57206. tubularSegments?: number;
  57207. p?: number;
  57208. q?: number;
  57209. updatable?: boolean;
  57210. sideOrientation?: number;
  57211. frontUVs?: Vector4;
  57212. backUVs?: Vector4;
  57213. }, scene?: Nullable<Scene>): Mesh;
  57214. /**
  57215. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57216. * * 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
  57217. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57218. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57219. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57220. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57221. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57222. * * 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
  57223. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57226. * @param name defines the name of the new line system
  57227. * @param options defines the options used to create the line system
  57228. * @param scene defines the hosting scene
  57229. * @returns a new line system mesh
  57230. */
  57231. static CreateLineSystem(name: string, options: {
  57232. lines: Vector3[][];
  57233. updatable?: boolean;
  57234. instance?: Nullable<LinesMesh>;
  57235. colors?: Nullable<Color4[][]>;
  57236. useVertexAlpha?: boolean;
  57237. }, scene: Nullable<Scene>): LinesMesh;
  57238. /**
  57239. * Creates a line mesh
  57240. * 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
  57241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57242. * * The parameter `points` is an array successive Vector3
  57243. * * 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
  57244. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57245. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57246. * * When updating an instance, remember that only point positions can change, not the number of points
  57247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57249. * @param name defines the name of the new line system
  57250. * @param options defines the options used to create the line system
  57251. * @param scene defines the hosting scene
  57252. * @returns a new line mesh
  57253. */
  57254. static CreateLines(name: string, options: {
  57255. points: Vector3[];
  57256. updatable?: boolean;
  57257. instance?: Nullable<LinesMesh>;
  57258. colors?: Color4[];
  57259. useVertexAlpha?: boolean;
  57260. }, scene?: Nullable<Scene>): LinesMesh;
  57261. /**
  57262. * Creates a dashed line mesh
  57263. * * 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
  57264. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57265. * * The parameter `points` is an array successive Vector3
  57266. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57267. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57268. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57269. * * 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
  57270. * * When updating an instance, remember that only point positions can change, not the number of points
  57271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57272. * @param name defines the name of the mesh
  57273. * @param options defines the options used to create the mesh
  57274. * @param scene defines the hosting scene
  57275. * @returns the dashed line mesh
  57276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57277. */
  57278. static CreateDashedLines(name: string, options: {
  57279. points: Vector3[];
  57280. dashSize?: number;
  57281. gapSize?: number;
  57282. dashNb?: number;
  57283. updatable?: boolean;
  57284. instance?: LinesMesh;
  57285. }, scene?: Nullable<Scene>): LinesMesh;
  57286. /**
  57287. * 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.
  57288. * * 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.
  57289. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57290. * * 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.
  57291. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57292. * * 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
  57293. * * 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
  57294. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57297. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57299. * @param name defines the name of the mesh
  57300. * @param options defines the options used to create the mesh
  57301. * @param scene defines the hosting scene
  57302. * @returns the extruded shape mesh
  57303. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57305. */
  57306. static ExtrudeShape(name: string, options: {
  57307. shape: Vector3[];
  57308. path: Vector3[];
  57309. scale?: number;
  57310. rotation?: number;
  57311. cap?: number;
  57312. updatable?: boolean;
  57313. sideOrientation?: number;
  57314. frontUVs?: Vector4;
  57315. backUVs?: Vector4;
  57316. instance?: Mesh;
  57317. invertUV?: boolean;
  57318. }, scene?: Nullable<Scene>): Mesh;
  57319. /**
  57320. * Creates an custom extruded shape mesh.
  57321. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57322. * * 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.
  57323. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57324. * * 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
  57325. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57326. * * 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
  57327. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57328. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57329. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57330. * * 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
  57331. * * 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
  57332. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57337. * @param name defines the name of the mesh
  57338. * @param options defines the options used to create the mesh
  57339. * @param scene defines the hosting scene
  57340. * @returns the custom extruded shape mesh
  57341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57342. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57344. */
  57345. static ExtrudeShapeCustom(name: string, options: {
  57346. shape: Vector3[];
  57347. path: Vector3[];
  57348. scaleFunction?: any;
  57349. rotationFunction?: any;
  57350. ribbonCloseArray?: boolean;
  57351. ribbonClosePath?: boolean;
  57352. cap?: number;
  57353. updatable?: boolean;
  57354. sideOrientation?: number;
  57355. frontUVs?: Vector4;
  57356. backUVs?: Vector4;
  57357. instance?: Mesh;
  57358. invertUV?: boolean;
  57359. }, scene?: Nullable<Scene>): Mesh;
  57360. /**
  57361. * Creates lathe mesh.
  57362. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57363. * * 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
  57364. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57365. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57366. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57367. * * 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
  57368. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57369. * * 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
  57370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57374. * @param name defines the name of the mesh
  57375. * @param options defines the options used to create the mesh
  57376. * @param scene defines the hosting scene
  57377. * @returns the lathe mesh
  57378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57379. */
  57380. static CreateLathe(name: string, options: {
  57381. shape: Vector3[];
  57382. radius?: number;
  57383. tessellation?: number;
  57384. clip?: number;
  57385. arc?: number;
  57386. closed?: boolean;
  57387. updatable?: boolean;
  57388. sideOrientation?: number;
  57389. frontUVs?: Vector4;
  57390. backUVs?: Vector4;
  57391. cap?: number;
  57392. invertUV?: boolean;
  57393. }, scene?: Nullable<Scene>): Mesh;
  57394. /**
  57395. * Creates a tiled plane mesh
  57396. * * You can set a limited pattern arrangement with the tiles
  57397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57400. * @param name defines the name of the mesh
  57401. * @param options defines the options used to create the mesh
  57402. * @param scene defines the hosting scene
  57403. * @returns the plane mesh
  57404. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57405. */
  57406. static CreateTiledPlane(name: string, options: {
  57407. pattern?: number;
  57408. tileSize?: number;
  57409. tileWidth?: number;
  57410. tileHeight?: number;
  57411. size?: number;
  57412. width?: number;
  57413. height?: number;
  57414. alignHorizontal?: number;
  57415. alignVertical?: number;
  57416. sideOrientation?: number;
  57417. frontUVs?: Vector4;
  57418. backUVs?: Vector4;
  57419. updatable?: boolean;
  57420. }, scene?: Nullable<Scene>): Mesh;
  57421. /**
  57422. * Creates a plane mesh
  57423. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57424. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57425. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57429. * @param name defines the name of the mesh
  57430. * @param options defines the options used to create the mesh
  57431. * @param scene defines the hosting scene
  57432. * @returns the plane mesh
  57433. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57434. */
  57435. static CreatePlane(name: string, options: {
  57436. size?: number;
  57437. width?: number;
  57438. height?: number;
  57439. sideOrientation?: number;
  57440. frontUVs?: Vector4;
  57441. backUVs?: Vector4;
  57442. updatable?: boolean;
  57443. sourcePlane?: Plane;
  57444. }, scene?: Nullable<Scene>): Mesh;
  57445. /**
  57446. * Creates a ground mesh
  57447. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57448. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57450. * @param name defines the name of the mesh
  57451. * @param options defines the options used to create the mesh
  57452. * @param scene defines the hosting scene
  57453. * @returns the ground mesh
  57454. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57455. */
  57456. static CreateGround(name: string, options: {
  57457. width?: number;
  57458. height?: number;
  57459. subdivisions?: number;
  57460. subdivisionsX?: number;
  57461. subdivisionsY?: number;
  57462. updatable?: boolean;
  57463. }, scene?: Nullable<Scene>): Mesh;
  57464. /**
  57465. * Creates a tiled ground mesh
  57466. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57467. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57468. * * 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
  57469. * * 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
  57470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57471. * @param name defines the name of the mesh
  57472. * @param options defines the options used to create the mesh
  57473. * @param scene defines the hosting scene
  57474. * @returns the tiled ground mesh
  57475. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57476. */
  57477. static CreateTiledGround(name: string, options: {
  57478. xmin: number;
  57479. zmin: number;
  57480. xmax: number;
  57481. zmax: number;
  57482. subdivisions?: {
  57483. w: number;
  57484. h: number;
  57485. };
  57486. precision?: {
  57487. w: number;
  57488. h: number;
  57489. };
  57490. updatable?: boolean;
  57491. }, scene?: Nullable<Scene>): Mesh;
  57492. /**
  57493. * Creates a ground mesh from a height map
  57494. * * The parameter `url` sets the URL of the height map image resource.
  57495. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57496. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57497. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57498. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57499. * * 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.
  57500. * * 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).
  57501. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57503. * @param name defines the name of the mesh
  57504. * @param url defines the url to the height map
  57505. * @param options defines the options used to create the mesh
  57506. * @param scene defines the hosting scene
  57507. * @returns the ground mesh
  57508. * @see https://doc.babylonjs.com/babylon101/height_map
  57509. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57510. */
  57511. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57512. width?: number;
  57513. height?: number;
  57514. subdivisions?: number;
  57515. minHeight?: number;
  57516. maxHeight?: number;
  57517. colorFilter?: Color3;
  57518. alphaFilter?: number;
  57519. updatable?: boolean;
  57520. onReady?: (mesh: GroundMesh) => void;
  57521. }, scene?: Nullable<Scene>): GroundMesh;
  57522. /**
  57523. * Creates a polygon mesh
  57524. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57525. * * 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
  57526. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57529. * * Remember you can only change the shape positions, not their number when updating a polygon
  57530. * @param name defines the name of the mesh
  57531. * @param options defines the options used to create the mesh
  57532. * @param scene defines the hosting scene
  57533. * @param earcutInjection can be used to inject your own earcut reference
  57534. * @returns the polygon mesh
  57535. */
  57536. static CreatePolygon(name: string, options: {
  57537. shape: Vector3[];
  57538. holes?: Vector3[][];
  57539. depth?: number;
  57540. faceUV?: Vector4[];
  57541. faceColors?: Color4[];
  57542. updatable?: boolean;
  57543. sideOrientation?: number;
  57544. frontUVs?: Vector4;
  57545. backUVs?: Vector4;
  57546. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57547. /**
  57548. * Creates an extruded polygon mesh, with depth in the Y direction.
  57549. * * 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)
  57550. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57551. * @param name defines the name of the mesh
  57552. * @param options defines the options used to create the mesh
  57553. * @param scene defines the hosting scene
  57554. * @param earcutInjection can be used to inject your own earcut reference
  57555. * @returns the polygon mesh
  57556. */
  57557. static ExtrudePolygon(name: string, options: {
  57558. shape: Vector3[];
  57559. holes?: Vector3[][];
  57560. depth?: number;
  57561. faceUV?: Vector4[];
  57562. faceColors?: Color4[];
  57563. updatable?: boolean;
  57564. sideOrientation?: number;
  57565. frontUVs?: Vector4;
  57566. backUVs?: Vector4;
  57567. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57568. /**
  57569. * Creates a tube mesh.
  57570. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57571. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57572. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57573. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57574. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57575. * * 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)
  57576. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57577. * * 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
  57578. * * 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
  57579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57583. * @param name defines the name of the mesh
  57584. * @param options defines the options used to create the mesh
  57585. * @param scene defines the hosting scene
  57586. * @returns the tube mesh
  57587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57588. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57589. */
  57590. static CreateTube(name: string, options: {
  57591. path: Vector3[];
  57592. radius?: number;
  57593. tessellation?: number;
  57594. radiusFunction?: {
  57595. (i: number, distance: number): number;
  57596. };
  57597. cap?: number;
  57598. arc?: number;
  57599. updatable?: boolean;
  57600. sideOrientation?: number;
  57601. frontUVs?: Vector4;
  57602. backUVs?: Vector4;
  57603. instance?: Mesh;
  57604. invertUV?: boolean;
  57605. }, scene?: Nullable<Scene>): Mesh;
  57606. /**
  57607. * Creates a polyhedron mesh
  57608. * * 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
  57609. * * The parameter `size` (positive float, default 1) sets the polygon size
  57610. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57611. * * 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`
  57612. * * 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
  57613. * * 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)`)
  57614. * * 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
  57615. * * 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
  57616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57619. * @param name defines the name of the mesh
  57620. * @param options defines the options used to create the mesh
  57621. * @param scene defines the hosting scene
  57622. * @returns the polyhedron mesh
  57623. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57624. */
  57625. static CreatePolyhedron(name: string, options: {
  57626. type?: number;
  57627. size?: number;
  57628. sizeX?: number;
  57629. sizeY?: number;
  57630. sizeZ?: number;
  57631. custom?: any;
  57632. faceUV?: Vector4[];
  57633. faceColors?: Color4[];
  57634. flat?: boolean;
  57635. updatable?: boolean;
  57636. sideOrientation?: number;
  57637. frontUVs?: Vector4;
  57638. backUVs?: Vector4;
  57639. }, scene?: Nullable<Scene>): Mesh;
  57640. /**
  57641. * Creates a decal mesh.
  57642. * 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
  57643. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57644. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57645. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57646. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57647. * @param name defines the name of the mesh
  57648. * @param sourceMesh defines the mesh where the decal must be applied
  57649. * @param options defines the options used to create the mesh
  57650. * @param scene defines the hosting scene
  57651. * @returns the decal mesh
  57652. * @see https://doc.babylonjs.com/how_to/decals
  57653. */
  57654. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57655. position?: Vector3;
  57656. normal?: Vector3;
  57657. size?: Vector3;
  57658. angle?: number;
  57659. }): Mesh;
  57660. }
  57661. }
  57662. declare module "babylonjs/Meshes/meshSimplification" {
  57663. import { Mesh } from "babylonjs/Meshes/mesh";
  57664. /**
  57665. * A simplifier interface for future simplification implementations
  57666. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57667. */
  57668. export interface ISimplifier {
  57669. /**
  57670. * Simplification of a given mesh according to the given settings.
  57671. * Since this requires computation, it is assumed that the function runs async.
  57672. * @param settings The settings of the simplification, including quality and distance
  57673. * @param successCallback A callback that will be called after the mesh was simplified.
  57674. * @param errorCallback in case of an error, this callback will be called. optional.
  57675. */
  57676. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57677. }
  57678. /**
  57679. * Expected simplification settings.
  57680. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57681. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57682. */
  57683. export interface ISimplificationSettings {
  57684. /**
  57685. * Gets or sets the expected quality
  57686. */
  57687. quality: number;
  57688. /**
  57689. * Gets or sets the distance when this optimized version should be used
  57690. */
  57691. distance: number;
  57692. /**
  57693. * Gets an already optimized mesh
  57694. */
  57695. optimizeMesh?: boolean;
  57696. }
  57697. /**
  57698. * Class used to specify simplification options
  57699. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57700. */
  57701. export class SimplificationSettings implements ISimplificationSettings {
  57702. /** expected quality */
  57703. quality: number;
  57704. /** distance when this optimized version should be used */
  57705. distance: number;
  57706. /** already optimized mesh */
  57707. optimizeMesh?: boolean | undefined;
  57708. /**
  57709. * Creates a SimplificationSettings
  57710. * @param quality expected quality
  57711. * @param distance distance when this optimized version should be used
  57712. * @param optimizeMesh already optimized mesh
  57713. */
  57714. constructor(
  57715. /** expected quality */
  57716. quality: number,
  57717. /** distance when this optimized version should be used */
  57718. distance: number,
  57719. /** already optimized mesh */
  57720. optimizeMesh?: boolean | undefined);
  57721. }
  57722. /**
  57723. * Interface used to define a simplification task
  57724. */
  57725. export interface ISimplificationTask {
  57726. /**
  57727. * Array of settings
  57728. */
  57729. settings: Array<ISimplificationSettings>;
  57730. /**
  57731. * Simplification type
  57732. */
  57733. simplificationType: SimplificationType;
  57734. /**
  57735. * Mesh to simplify
  57736. */
  57737. mesh: Mesh;
  57738. /**
  57739. * Callback called on success
  57740. */
  57741. successCallback?: () => void;
  57742. /**
  57743. * Defines if parallel processing can be used
  57744. */
  57745. parallelProcessing: boolean;
  57746. }
  57747. /**
  57748. * Queue used to order the simplification tasks
  57749. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57750. */
  57751. export class SimplificationQueue {
  57752. private _simplificationArray;
  57753. /**
  57754. * Gets a boolean indicating that the process is still running
  57755. */
  57756. running: boolean;
  57757. /**
  57758. * Creates a new queue
  57759. */
  57760. constructor();
  57761. /**
  57762. * Adds a new simplification task
  57763. * @param task defines a task to add
  57764. */
  57765. addTask(task: ISimplificationTask): void;
  57766. /**
  57767. * Execute next task
  57768. */
  57769. executeNext(): void;
  57770. /**
  57771. * Execute a simplification task
  57772. * @param task defines the task to run
  57773. */
  57774. runSimplification(task: ISimplificationTask): void;
  57775. private getSimplifier;
  57776. }
  57777. /**
  57778. * The implemented types of simplification
  57779. * At the moment only Quadratic Error Decimation is implemented
  57780. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57781. */
  57782. export enum SimplificationType {
  57783. /** Quadratic error decimation */
  57784. QUADRATIC = 0
  57785. }
  57786. }
  57787. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57788. import { Scene } from "babylonjs/scene";
  57789. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57790. import { ISceneComponent } from "babylonjs/sceneComponent";
  57791. module "babylonjs/scene" {
  57792. interface Scene {
  57793. /** @hidden (Backing field) */
  57794. _simplificationQueue: SimplificationQueue;
  57795. /**
  57796. * Gets or sets the simplification queue attached to the scene
  57797. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57798. */
  57799. simplificationQueue: SimplificationQueue;
  57800. }
  57801. }
  57802. module "babylonjs/Meshes/mesh" {
  57803. interface Mesh {
  57804. /**
  57805. * Simplify the mesh according to the given array of settings.
  57806. * Function will return immediately and will simplify async
  57807. * @param settings a collection of simplification settings
  57808. * @param parallelProcessing should all levels calculate parallel or one after the other
  57809. * @param simplificationType the type of simplification to run
  57810. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57811. * @returns the current mesh
  57812. */
  57813. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57814. }
  57815. }
  57816. /**
  57817. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57818. * created in a scene
  57819. */
  57820. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57821. /**
  57822. * The component name helpfull to identify the component in the list of scene components.
  57823. */
  57824. readonly name: string;
  57825. /**
  57826. * The scene the component belongs to.
  57827. */
  57828. scene: Scene;
  57829. /**
  57830. * Creates a new instance of the component for the given scene
  57831. * @param scene Defines the scene to register the component in
  57832. */
  57833. constructor(scene: Scene);
  57834. /**
  57835. * Registers the component in a given scene
  57836. */
  57837. register(): void;
  57838. /**
  57839. * Rebuilds the elements related to this component in case of
  57840. * context lost for instance.
  57841. */
  57842. rebuild(): void;
  57843. /**
  57844. * Disposes the component and the associated ressources
  57845. */
  57846. dispose(): void;
  57847. private _beforeCameraUpdate;
  57848. }
  57849. }
  57850. declare module "babylonjs/Meshes/Builders/index" {
  57851. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57852. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57853. export * from "babylonjs/Meshes/Builders/discBuilder";
  57854. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57855. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57856. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57857. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57858. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57859. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57860. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57861. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57862. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57863. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57864. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57865. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57866. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57867. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57868. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57869. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57870. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57871. }
  57872. declare module "babylonjs/Meshes/index" {
  57873. export * from "babylonjs/Meshes/abstractMesh";
  57874. export * from "babylonjs/Meshes/buffer";
  57875. export * from "babylonjs/Meshes/Compression/index";
  57876. export * from "babylonjs/Meshes/csg";
  57877. export * from "babylonjs/Meshes/geometry";
  57878. export * from "babylonjs/Meshes/groundMesh";
  57879. export * from "babylonjs/Meshes/trailMesh";
  57880. export * from "babylonjs/Meshes/instancedMesh";
  57881. export * from "babylonjs/Meshes/linesMesh";
  57882. export * from "babylonjs/Meshes/mesh";
  57883. export * from "babylonjs/Meshes/mesh.vertexData";
  57884. export * from "babylonjs/Meshes/meshBuilder";
  57885. export * from "babylonjs/Meshes/meshSimplification";
  57886. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  57887. export * from "babylonjs/Meshes/polygonMesh";
  57888. export * from "babylonjs/Meshes/subMesh";
  57889. export * from "babylonjs/Meshes/meshLODLevel";
  57890. export * from "babylonjs/Meshes/transformNode";
  57891. export * from "babylonjs/Meshes/Builders/index";
  57892. export * from "babylonjs/Meshes/dataBuffer";
  57893. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  57894. }
  57895. declare module "babylonjs/Morph/index" {
  57896. export * from "babylonjs/Morph/morphTarget";
  57897. export * from "babylonjs/Morph/morphTargetManager";
  57898. }
  57899. declare module "babylonjs/Navigation/INavigationEngine" {
  57900. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57901. import { Vector3 } from "babylonjs/Maths/math";
  57902. import { Mesh } from "babylonjs/Meshes/mesh";
  57903. import { Scene } from "babylonjs/scene";
  57904. /**
  57905. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57906. */
  57907. export interface INavigationEnginePlugin {
  57908. /**
  57909. * plugin name
  57910. */
  57911. name: string;
  57912. /**
  57913. * Creates a navigation mesh
  57914. * @param meshes array of all the geometry used to compute the navigatio mesh
  57915. * @param parameters bunch of parameters used to filter geometry
  57916. */
  57917. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57918. /**
  57919. * Create a navigation mesh debug mesh
  57920. * @param scene is where the mesh will be added
  57921. * @returns debug display mesh
  57922. */
  57923. createDebugNavMesh(scene: Scene): Mesh;
  57924. /**
  57925. * Get a navigation mesh constrained position, closest to the parameter position
  57926. * @param position world position
  57927. * @returns the closest point to position constrained by the navigation mesh
  57928. */
  57929. getClosestPoint(position: Vector3): Vector3;
  57930. /**
  57931. * Get a navigation mesh constrained position, within a particular radius
  57932. * @param position world position
  57933. * @param maxRadius the maximum distance to the constrained world position
  57934. * @returns the closest point to position constrained by the navigation mesh
  57935. */
  57936. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57937. /**
  57938. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57939. * @param start world position
  57940. * @param end world position
  57941. * @returns array containing world position composing the path
  57942. */
  57943. computePath(start: Vector3, end: Vector3): Vector3[];
  57944. /**
  57945. * If this plugin is supported
  57946. * @returns true if plugin is supported
  57947. */
  57948. isSupported(): boolean;
  57949. /**
  57950. * Create a new Crowd so you can add agents
  57951. * @param maxAgents the maximum agent count in the crowd
  57952. * @param maxAgentRadius the maximum radius an agent can have
  57953. * @param scene to attach the crowd to
  57954. * @returns the crowd you can add agents to
  57955. */
  57956. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57957. /**
  57958. * Release all resources
  57959. */
  57960. dispose(): void;
  57961. }
  57962. /**
  57963. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57964. */
  57965. export interface ICrowd {
  57966. /**
  57967. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57968. * You can attach anything to that node. The node position is updated in the scene update tick.
  57969. * @param pos world position that will be constrained by the navigation mesh
  57970. * @param parameters agent parameters
  57971. * @param transform hooked to the agent that will be update by the scene
  57972. * @returns agent index
  57973. */
  57974. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57975. /**
  57976. * Returns the agent position in world space
  57977. * @param index agent index returned by addAgent
  57978. * @returns world space position
  57979. */
  57980. getAgentPosition(index: number): Vector3;
  57981. /**
  57982. * Gets the agent velocity in world space
  57983. * @param index agent index returned by addAgent
  57984. * @returns world space velocity
  57985. */
  57986. getAgentVelocity(index: number): Vector3;
  57987. /**
  57988. * remove a particular agent previously created
  57989. * @param index agent index returned by addAgent
  57990. */
  57991. removeAgent(index: number): void;
  57992. /**
  57993. * get the list of all agents attached to this crowd
  57994. * @returns list of agent indices
  57995. */
  57996. getAgents(): number[];
  57997. /**
  57998. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57999. * @param deltaTime in seconds
  58000. */
  58001. update(deltaTime: number): void;
  58002. /**
  58003. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58004. * @param index agent index returned by addAgent
  58005. * @param destination targeted world position
  58006. */
  58007. agentGoto(index: number, destination: Vector3): void;
  58008. /**
  58009. * Release all resources
  58010. */
  58011. dispose(): void;
  58012. }
  58013. /**
  58014. * Configures an agent
  58015. */
  58016. export interface IAgentParameters {
  58017. /**
  58018. * Agent radius. [Limit: >= 0]
  58019. */
  58020. radius: number;
  58021. /**
  58022. * Agent height. [Limit: > 0]
  58023. */
  58024. height: number;
  58025. /**
  58026. * Maximum allowed acceleration. [Limit: >= 0]
  58027. */
  58028. maxAcceleration: number;
  58029. /**
  58030. * Maximum allowed speed. [Limit: >= 0]
  58031. */
  58032. maxSpeed: number;
  58033. /**
  58034. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58035. */
  58036. collisionQueryRange: number;
  58037. /**
  58038. * The path visibility optimization range. [Limit: > 0]
  58039. */
  58040. pathOptimizationRange: number;
  58041. /**
  58042. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58043. */
  58044. separationWeight: number;
  58045. }
  58046. /**
  58047. * Configures the navigation mesh creation
  58048. */
  58049. export interface INavMeshParameters {
  58050. /**
  58051. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58052. */
  58053. cs: number;
  58054. /**
  58055. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58056. */
  58057. ch: number;
  58058. /**
  58059. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58060. */
  58061. walkableSlopeAngle: number;
  58062. /**
  58063. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58064. * be considered walkable. [Limit: >= 3] [Units: vx]
  58065. */
  58066. walkableHeight: number;
  58067. /**
  58068. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58069. */
  58070. walkableClimb: number;
  58071. /**
  58072. * The distance to erode/shrink the walkable area of the heightfield away from
  58073. * obstructions. [Limit: >=0] [Units: vx]
  58074. */
  58075. walkableRadius: number;
  58076. /**
  58077. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58078. */
  58079. maxEdgeLen: number;
  58080. /**
  58081. * The maximum distance a simplfied contour's border edges should deviate
  58082. * the original raw contour. [Limit: >=0] [Units: vx]
  58083. */
  58084. maxSimplificationError: number;
  58085. /**
  58086. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58087. */
  58088. minRegionArea: number;
  58089. /**
  58090. * Any regions with a span count smaller than this value will, if possible,
  58091. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58092. */
  58093. mergeRegionArea: number;
  58094. /**
  58095. * The maximum number of vertices allowed for polygons generated during the
  58096. * contour to polygon conversion process. [Limit: >= 3]
  58097. */
  58098. maxVertsPerPoly: number;
  58099. /**
  58100. * Sets the sampling distance to use when generating the detail mesh.
  58101. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58102. */
  58103. detailSampleDist: number;
  58104. /**
  58105. * The maximum distance the detail mesh surface should deviate from heightfield
  58106. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58107. */
  58108. detailSampleMaxError: number;
  58109. }
  58110. }
  58111. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  58112. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  58113. import { Mesh } from "babylonjs/Meshes/mesh";
  58114. import { Scene } from "babylonjs/scene";
  58115. import { Vector3 } from "babylonjs/Maths/math";
  58116. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58117. /**
  58118. * RecastJS navigation plugin
  58119. */
  58120. export class RecastJSPlugin implements INavigationEnginePlugin {
  58121. /**
  58122. * Reference to the Recast library
  58123. */
  58124. bjsRECAST: any;
  58125. /**
  58126. * plugin name
  58127. */
  58128. name: string;
  58129. /**
  58130. * the first navmesh created. We might extend this to support multiple navmeshes
  58131. */
  58132. navMesh: any;
  58133. /**
  58134. * Initializes the recastJS plugin
  58135. * @param recastInjection can be used to inject your own recast reference
  58136. */
  58137. constructor(recastInjection?: any);
  58138. /**
  58139. * Creates a navigation mesh
  58140. * @param meshes array of all the geometry used to compute the navigatio mesh
  58141. * @param parameters bunch of parameters used to filter geometry
  58142. */
  58143. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58144. /**
  58145. * Create a navigation mesh debug mesh
  58146. * @param scene is where the mesh will be added
  58147. * @returns debug display mesh
  58148. */
  58149. createDebugNavMesh(scene: Scene): Mesh;
  58150. /**
  58151. * Get a navigation mesh constrained position, closest to the parameter position
  58152. * @param position world position
  58153. * @returns the closest point to position constrained by the navigation mesh
  58154. */
  58155. getClosestPoint(position: Vector3): Vector3;
  58156. /**
  58157. * Get a navigation mesh constrained position, within a particular radius
  58158. * @param position world position
  58159. * @param maxRadius the maximum distance to the constrained world position
  58160. * @returns the closest point to position constrained by the navigation mesh
  58161. */
  58162. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58163. /**
  58164. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58165. * @param start world position
  58166. * @param end world position
  58167. * @returns array containing world position composing the path
  58168. */
  58169. computePath(start: Vector3, end: Vector3): Vector3[];
  58170. /**
  58171. * Create a new Crowd so you can add agents
  58172. * @param maxAgents the maximum agent count in the crowd
  58173. * @param maxAgentRadius the maximum radius an agent can have
  58174. * @param scene to attach the crowd to
  58175. * @returns the crowd you can add agents to
  58176. */
  58177. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58178. /**
  58179. * Disposes
  58180. */
  58181. dispose(): void;
  58182. /**
  58183. * If this plugin is supported
  58184. * @returns true if plugin is supported
  58185. */
  58186. isSupported(): boolean;
  58187. }
  58188. /**
  58189. * Recast detour crowd implementation
  58190. */
  58191. export class RecastJSCrowd implements ICrowd {
  58192. /**
  58193. * Recast/detour plugin
  58194. */
  58195. bjsRECASTPlugin: RecastJSPlugin;
  58196. /**
  58197. * Link to the detour crowd
  58198. */
  58199. recastCrowd: any;
  58200. /**
  58201. * One transform per agent
  58202. */
  58203. transforms: TransformNode[];
  58204. /**
  58205. * All agents created
  58206. */
  58207. agents: number[];
  58208. /**
  58209. * Link to the scene is kept to unregister the crowd from the scene
  58210. */
  58211. private _scene;
  58212. /**
  58213. * Observer for crowd updates
  58214. */
  58215. private _onBeforeAnimationsObserver;
  58216. /**
  58217. * Constructor
  58218. * @param plugin recastJS plugin
  58219. * @param maxAgents the maximum agent count in the crowd
  58220. * @param maxAgentRadius the maximum radius an agent can have
  58221. * @param scene to attach the crowd to
  58222. * @returns the crowd you can add agents to
  58223. */
  58224. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58225. /**
  58226. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58227. * You can attach anything to that node. The node position is updated in the scene update tick.
  58228. * @param pos world position that will be constrained by the navigation mesh
  58229. * @param parameters agent parameters
  58230. * @param transform hooked to the agent that will be update by the scene
  58231. * @returns agent index
  58232. */
  58233. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58234. /**
  58235. * Returns the agent position in world space
  58236. * @param index agent index returned by addAgent
  58237. * @returns world space position
  58238. */
  58239. getAgentPosition(index: number): Vector3;
  58240. /**
  58241. * Returns the agent velocity in world space
  58242. * @param index agent index returned by addAgent
  58243. * @returns world space velocity
  58244. */
  58245. getAgentVelocity(index: number): Vector3;
  58246. /**
  58247. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58248. * @param index agent index returned by addAgent
  58249. * @param destination targeted world position
  58250. */
  58251. agentGoto(index: number, destination: Vector3): void;
  58252. /**
  58253. * remove a particular agent previously created
  58254. * @param index agent index returned by addAgent
  58255. */
  58256. removeAgent(index: number): void;
  58257. /**
  58258. * get the list of all agents attached to this crowd
  58259. * @returns list of agent indices
  58260. */
  58261. getAgents(): number[];
  58262. /**
  58263. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58264. * @param deltaTime in seconds
  58265. */
  58266. update(deltaTime: number): void;
  58267. /**
  58268. * Release all resources
  58269. */
  58270. dispose(): void;
  58271. }
  58272. }
  58273. declare module "babylonjs/Navigation/Plugins/index" {
  58274. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  58275. }
  58276. declare module "babylonjs/Navigation/index" {
  58277. export * from "babylonjs/Navigation/INavigationEngine";
  58278. export * from "babylonjs/Navigation/Plugins/index";
  58279. }
  58280. declare module "babylonjs/Offline/database" {
  58281. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  58282. /**
  58283. * Class used to enable access to IndexedDB
  58284. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58285. */
  58286. export class Database implements IOfflineProvider {
  58287. private _callbackManifestChecked;
  58288. private _currentSceneUrl;
  58289. private _db;
  58290. private _enableSceneOffline;
  58291. private _enableTexturesOffline;
  58292. private _manifestVersionFound;
  58293. private _mustUpdateRessources;
  58294. private _hasReachedQuota;
  58295. private _isSupported;
  58296. private _idbFactory;
  58297. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58298. private static IsUASupportingBlobStorage;
  58299. /**
  58300. * Gets a boolean indicating if Database storate is enabled (off by default)
  58301. */
  58302. static IDBStorageEnabled: boolean;
  58303. /**
  58304. * Gets a boolean indicating if scene must be saved in the database
  58305. */
  58306. readonly enableSceneOffline: boolean;
  58307. /**
  58308. * Gets a boolean indicating if textures must be saved in the database
  58309. */
  58310. readonly enableTexturesOffline: boolean;
  58311. /**
  58312. * Creates a new Database
  58313. * @param urlToScene defines the url to load the scene
  58314. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58315. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58316. */
  58317. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58318. private static _ParseURL;
  58319. private static _ReturnFullUrlLocation;
  58320. private _checkManifestFile;
  58321. /**
  58322. * Open the database and make it available
  58323. * @param successCallback defines the callback to call on success
  58324. * @param errorCallback defines the callback to call on error
  58325. */
  58326. open(successCallback: () => void, errorCallback: () => void): void;
  58327. /**
  58328. * Loads an image from the database
  58329. * @param url defines the url to load from
  58330. * @param image defines the target DOM image
  58331. */
  58332. loadImage(url: string, image: HTMLImageElement): void;
  58333. private _loadImageFromDBAsync;
  58334. private _saveImageIntoDBAsync;
  58335. private _checkVersionFromDB;
  58336. private _loadVersionFromDBAsync;
  58337. private _saveVersionIntoDBAsync;
  58338. /**
  58339. * Loads a file from database
  58340. * @param url defines the URL to load from
  58341. * @param sceneLoaded defines a callback to call on success
  58342. * @param progressCallBack defines a callback to call when progress changed
  58343. * @param errorCallback defines a callback to call on error
  58344. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58345. */
  58346. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58347. private _loadFileAsync;
  58348. private _saveFileAsync;
  58349. /**
  58350. * Validates if xhr data is correct
  58351. * @param xhr defines the request to validate
  58352. * @param dataType defines the expected data type
  58353. * @returns true if data is correct
  58354. */
  58355. private static _ValidateXHRData;
  58356. }
  58357. }
  58358. declare module "babylonjs/Offline/index" {
  58359. export * from "babylonjs/Offline/database";
  58360. export * from "babylonjs/Offline/IOfflineProvider";
  58361. }
  58362. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  58363. /** @hidden */
  58364. export var gpuUpdateParticlesPixelShader: {
  58365. name: string;
  58366. shader: string;
  58367. };
  58368. }
  58369. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  58370. /** @hidden */
  58371. export var gpuUpdateParticlesVertexShader: {
  58372. name: string;
  58373. shader: string;
  58374. };
  58375. }
  58376. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  58377. /** @hidden */
  58378. export var clipPlaneFragmentDeclaration2: {
  58379. name: string;
  58380. shader: string;
  58381. };
  58382. }
  58383. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  58384. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  58385. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58386. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58387. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58388. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58389. /** @hidden */
  58390. export var gpuRenderParticlesPixelShader: {
  58391. name: string;
  58392. shader: string;
  58393. };
  58394. }
  58395. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  58396. /** @hidden */
  58397. export var clipPlaneVertexDeclaration2: {
  58398. name: string;
  58399. shader: string;
  58400. };
  58401. }
  58402. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  58403. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  58404. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58405. /** @hidden */
  58406. export var gpuRenderParticlesVertexShader: {
  58407. name: string;
  58408. shader: string;
  58409. };
  58410. }
  58411. declare module "babylonjs/Particles/gpuParticleSystem" {
  58412. import { Nullable } from "babylonjs/types";
  58413. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  58414. import { Observable } from "babylonjs/Misc/observable";
  58415. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58416. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58417. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  58418. import { Scene, IDisposable } from "babylonjs/scene";
  58419. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  58420. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58421. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  58422. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  58423. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  58424. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  58425. /**
  58426. * This represents a GPU particle system in Babylon
  58427. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58428. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58429. */
  58430. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58431. /**
  58432. * The layer mask we are rendering the particles through.
  58433. */
  58434. layerMask: number;
  58435. private _capacity;
  58436. private _activeCount;
  58437. private _currentActiveCount;
  58438. private _accumulatedCount;
  58439. private _renderEffect;
  58440. private _updateEffect;
  58441. private _buffer0;
  58442. private _buffer1;
  58443. private _spriteBuffer;
  58444. private _updateVAO;
  58445. private _renderVAO;
  58446. private _targetIndex;
  58447. private _sourceBuffer;
  58448. private _targetBuffer;
  58449. private _engine;
  58450. private _currentRenderId;
  58451. private _started;
  58452. private _stopped;
  58453. private _timeDelta;
  58454. private _randomTexture;
  58455. private _randomTexture2;
  58456. private _attributesStrideSize;
  58457. private _updateEffectOptions;
  58458. private _randomTextureSize;
  58459. private _actualFrame;
  58460. private readonly _rawTextureWidth;
  58461. /**
  58462. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58463. */
  58464. static readonly IsSupported: boolean;
  58465. /**
  58466. * An event triggered when the system is disposed.
  58467. */
  58468. onDisposeObservable: Observable<GPUParticleSystem>;
  58469. /**
  58470. * Gets the maximum number of particles active at the same time.
  58471. * @returns The max number of active particles.
  58472. */
  58473. getCapacity(): number;
  58474. /**
  58475. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58476. * to override the particles.
  58477. */
  58478. forceDepthWrite: boolean;
  58479. /**
  58480. * Gets or set the number of active particles
  58481. */
  58482. activeParticleCount: number;
  58483. private _preWarmDone;
  58484. /**
  58485. * Is this system ready to be used/rendered
  58486. * @return true if the system is ready
  58487. */
  58488. isReady(): boolean;
  58489. /**
  58490. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58491. * @returns True if it has been started, otherwise false.
  58492. */
  58493. isStarted(): boolean;
  58494. /**
  58495. * Starts the particle system and begins to emit
  58496. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58497. */
  58498. start(delay?: number): void;
  58499. /**
  58500. * Stops the particle system.
  58501. */
  58502. stop(): void;
  58503. /**
  58504. * Remove all active particles
  58505. */
  58506. reset(): void;
  58507. /**
  58508. * Returns the string "GPUParticleSystem"
  58509. * @returns a string containing the class name
  58510. */
  58511. getClassName(): string;
  58512. private _colorGradientsTexture;
  58513. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58514. /**
  58515. * Adds a new color gradient
  58516. * @param gradient defines the gradient to use (between 0 and 1)
  58517. * @param color1 defines the color to affect to the specified gradient
  58518. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58519. * @returns the current particle system
  58520. */
  58521. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58522. /**
  58523. * Remove a specific color gradient
  58524. * @param gradient defines the gradient to remove
  58525. * @returns the current particle system
  58526. */
  58527. removeColorGradient(gradient: number): GPUParticleSystem;
  58528. private _angularSpeedGradientsTexture;
  58529. private _sizeGradientsTexture;
  58530. private _velocityGradientsTexture;
  58531. private _limitVelocityGradientsTexture;
  58532. private _dragGradientsTexture;
  58533. private _addFactorGradient;
  58534. /**
  58535. * Adds a new size gradient
  58536. * @param gradient defines the gradient to use (between 0 and 1)
  58537. * @param factor defines the size factor to affect to the specified gradient
  58538. * @returns the current particle system
  58539. */
  58540. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58541. /**
  58542. * Remove a specific size gradient
  58543. * @param gradient defines the gradient to remove
  58544. * @returns the current particle system
  58545. */
  58546. removeSizeGradient(gradient: number): GPUParticleSystem;
  58547. /**
  58548. * Adds a new angular speed gradient
  58549. * @param gradient defines the gradient to use (between 0 and 1)
  58550. * @param factor defines the angular speed to affect to the specified gradient
  58551. * @returns the current particle system
  58552. */
  58553. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58554. /**
  58555. * Remove a specific angular speed gradient
  58556. * @param gradient defines the gradient to remove
  58557. * @returns the current particle system
  58558. */
  58559. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58560. /**
  58561. * Adds a new velocity gradient
  58562. * @param gradient defines the gradient to use (between 0 and 1)
  58563. * @param factor defines the velocity to affect to the specified gradient
  58564. * @returns the current particle system
  58565. */
  58566. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58567. /**
  58568. * Remove a specific velocity gradient
  58569. * @param gradient defines the gradient to remove
  58570. * @returns the current particle system
  58571. */
  58572. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58573. /**
  58574. * Adds a new limit velocity gradient
  58575. * @param gradient defines the gradient to use (between 0 and 1)
  58576. * @param factor defines the limit velocity value to affect to the specified gradient
  58577. * @returns the current particle system
  58578. */
  58579. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58580. /**
  58581. * Remove a specific limit velocity gradient
  58582. * @param gradient defines the gradient to remove
  58583. * @returns the current particle system
  58584. */
  58585. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58586. /**
  58587. * Adds a new drag gradient
  58588. * @param gradient defines the gradient to use (between 0 and 1)
  58589. * @param factor defines the drag value to affect to the specified gradient
  58590. * @returns the current particle system
  58591. */
  58592. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58593. /**
  58594. * Remove a specific drag gradient
  58595. * @param gradient defines the gradient to remove
  58596. * @returns the current particle system
  58597. */
  58598. removeDragGradient(gradient: number): GPUParticleSystem;
  58599. /**
  58600. * Not supported by GPUParticleSystem
  58601. * @param gradient defines the gradient to use (between 0 and 1)
  58602. * @param factor defines the emit rate value to affect to the specified gradient
  58603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58604. * @returns the current particle system
  58605. */
  58606. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58607. /**
  58608. * Not supported by GPUParticleSystem
  58609. * @param gradient defines the gradient to remove
  58610. * @returns the current particle system
  58611. */
  58612. removeEmitRateGradient(gradient: number): IParticleSystem;
  58613. /**
  58614. * Not supported by GPUParticleSystem
  58615. * @param gradient defines the gradient to use (between 0 and 1)
  58616. * @param factor defines the start size value to affect to the specified gradient
  58617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58618. * @returns the current particle system
  58619. */
  58620. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58621. /**
  58622. * Not supported by GPUParticleSystem
  58623. * @param gradient defines the gradient to remove
  58624. * @returns the current particle system
  58625. */
  58626. removeStartSizeGradient(gradient: number): IParticleSystem;
  58627. /**
  58628. * Not supported by GPUParticleSystem
  58629. * @param gradient defines the gradient to use (between 0 and 1)
  58630. * @param min defines the color remap minimal range
  58631. * @param max defines the color remap maximal range
  58632. * @returns the current particle system
  58633. */
  58634. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58635. /**
  58636. * Not supported by GPUParticleSystem
  58637. * @param gradient defines the gradient to remove
  58638. * @returns the current particle system
  58639. */
  58640. removeColorRemapGradient(): IParticleSystem;
  58641. /**
  58642. * Not supported by GPUParticleSystem
  58643. * @param gradient defines the gradient to use (between 0 and 1)
  58644. * @param min defines the alpha remap minimal range
  58645. * @param max defines the alpha remap maximal range
  58646. * @returns the current particle system
  58647. */
  58648. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58649. /**
  58650. * Not supported by GPUParticleSystem
  58651. * @param gradient defines the gradient to remove
  58652. * @returns the current particle system
  58653. */
  58654. removeAlphaRemapGradient(): IParticleSystem;
  58655. /**
  58656. * Not supported by GPUParticleSystem
  58657. * @param gradient defines the gradient to use (between 0 and 1)
  58658. * @param color defines the color to affect to the specified gradient
  58659. * @returns the current particle system
  58660. */
  58661. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58662. /**
  58663. * Not supported by GPUParticleSystem
  58664. * @param gradient defines the gradient to remove
  58665. * @returns the current particle system
  58666. */
  58667. removeRampGradient(): IParticleSystem;
  58668. /**
  58669. * Not supported by GPUParticleSystem
  58670. * @returns the list of ramp gradients
  58671. */
  58672. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58673. /**
  58674. * Not supported by GPUParticleSystem
  58675. * Gets or sets a boolean indicating that ramp gradients must be used
  58676. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58677. */
  58678. useRampGradients: boolean;
  58679. /**
  58680. * Not supported by GPUParticleSystem
  58681. * @param gradient defines the gradient to use (between 0 and 1)
  58682. * @param factor defines the life time factor to affect to the specified gradient
  58683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58684. * @returns the current particle system
  58685. */
  58686. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58687. /**
  58688. * Not supported by GPUParticleSystem
  58689. * @param gradient defines the gradient to remove
  58690. * @returns the current particle system
  58691. */
  58692. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58693. /**
  58694. * Instantiates a GPU particle system.
  58695. * 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.
  58696. * @param name The name of the particle system
  58697. * @param options The options used to create the system
  58698. * @param scene The scene the particle system belongs to
  58699. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58700. */
  58701. constructor(name: string, options: Partial<{
  58702. capacity: number;
  58703. randomTextureSize: number;
  58704. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58705. protected _reset(): void;
  58706. private _createUpdateVAO;
  58707. private _createRenderVAO;
  58708. private _initialize;
  58709. /** @hidden */
  58710. _recreateUpdateEffect(): void;
  58711. /** @hidden */
  58712. _recreateRenderEffect(): void;
  58713. /**
  58714. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58715. * @param preWarm defines if we are in the pre-warmimg phase
  58716. */
  58717. animate(preWarm?: boolean): void;
  58718. private _createFactorGradientTexture;
  58719. private _createSizeGradientTexture;
  58720. private _createAngularSpeedGradientTexture;
  58721. private _createVelocityGradientTexture;
  58722. private _createLimitVelocityGradientTexture;
  58723. private _createDragGradientTexture;
  58724. private _createColorGradientTexture;
  58725. /**
  58726. * Renders the particle system in its current state
  58727. * @param preWarm defines if the system should only update the particles but not render them
  58728. * @returns the current number of particles
  58729. */
  58730. render(preWarm?: boolean): number;
  58731. /**
  58732. * Rebuilds the particle system
  58733. */
  58734. rebuild(): void;
  58735. private _releaseBuffers;
  58736. private _releaseVAOs;
  58737. /**
  58738. * Disposes the particle system and free the associated resources
  58739. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58740. */
  58741. dispose(disposeTexture?: boolean): void;
  58742. /**
  58743. * Clones the particle system.
  58744. * @param name The name of the cloned object
  58745. * @param newEmitter The new emitter to use
  58746. * @returns the cloned particle system
  58747. */
  58748. clone(name: string, newEmitter: any): GPUParticleSystem;
  58749. /**
  58750. * Serializes the particle system to a JSON object.
  58751. * @returns the JSON object
  58752. */
  58753. serialize(): any;
  58754. /**
  58755. * Parses a JSON object to create a GPU particle system.
  58756. * @param parsedParticleSystem The JSON object to parse
  58757. * @param scene The scene to create the particle system in
  58758. * @param rootUrl The root url to use to load external dependencies like texture
  58759. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58760. * @returns the parsed GPU particle system
  58761. */
  58762. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58763. }
  58764. }
  58765. declare module "babylonjs/Particles/particleSystemSet" {
  58766. import { Nullable } from "babylonjs/types";
  58767. import { Color3 } from "babylonjs/Maths/math.color";
  58768. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58770. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58771. import { Scene, IDisposable } from "babylonjs/scene";
  58772. /**
  58773. * Represents a set of particle systems working together to create a specific effect
  58774. */
  58775. export class ParticleSystemSet implements IDisposable {
  58776. private _emitterCreationOptions;
  58777. private _emitterNode;
  58778. /**
  58779. * Gets the particle system list
  58780. */
  58781. systems: IParticleSystem[];
  58782. /**
  58783. * Gets the emitter node used with this set
  58784. */
  58785. readonly emitterNode: Nullable<TransformNode>;
  58786. /**
  58787. * Creates a new emitter mesh as a sphere
  58788. * @param options defines the options used to create the sphere
  58789. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58790. * @param scene defines the hosting scene
  58791. */
  58792. setEmitterAsSphere(options: {
  58793. diameter: number;
  58794. segments: number;
  58795. color: Color3;
  58796. }, renderingGroupId: number, scene: Scene): void;
  58797. /**
  58798. * Starts all particle systems of the set
  58799. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58800. */
  58801. start(emitter?: AbstractMesh): void;
  58802. /**
  58803. * Release all associated resources
  58804. */
  58805. dispose(): void;
  58806. /**
  58807. * Serialize the set into a JSON compatible object
  58808. * @returns a JSON compatible representation of the set
  58809. */
  58810. serialize(): any;
  58811. /**
  58812. * Parse a new ParticleSystemSet from a serialized source
  58813. * @param data defines a JSON compatible representation of the set
  58814. * @param scene defines the hosting scene
  58815. * @param gpu defines if we want GPU particles or CPU particles
  58816. * @returns a new ParticleSystemSet
  58817. */
  58818. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58819. }
  58820. }
  58821. declare module "babylonjs/Particles/particleHelper" {
  58822. import { Nullable } from "babylonjs/types";
  58823. import { Scene } from "babylonjs/scene";
  58824. import { Vector3 } from "babylonjs/Maths/math.vector";
  58825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58826. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58827. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58828. /**
  58829. * This class is made for on one-liner static method to help creating particle system set.
  58830. */
  58831. export class ParticleHelper {
  58832. /**
  58833. * Gets or sets base Assets URL
  58834. */
  58835. static BaseAssetsUrl: string;
  58836. /**
  58837. * Create a default particle system that you can tweak
  58838. * @param emitter defines the emitter to use
  58839. * @param capacity defines the system capacity (default is 500 particles)
  58840. * @param scene defines the hosting scene
  58841. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58842. * @returns the new Particle system
  58843. */
  58844. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58845. /**
  58846. * This is the main static method (one-liner) of this helper to create different particle systems
  58847. * @param type This string represents the type to the particle system to create
  58848. * @param scene The scene where the particle system should live
  58849. * @param gpu If the system will use gpu
  58850. * @returns the ParticleSystemSet created
  58851. */
  58852. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58853. /**
  58854. * Static function used to export a particle system to a ParticleSystemSet variable.
  58855. * Please note that the emitter shape is not exported
  58856. * @param systems defines the particle systems to export
  58857. * @returns the created particle system set
  58858. */
  58859. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58860. }
  58861. }
  58862. declare module "babylonjs/Particles/particleSystemComponent" {
  58863. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58864. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58865. import "babylonjs/Shaders/particles.vertex";
  58866. module "babylonjs/Engines/engine" {
  58867. interface Engine {
  58868. /**
  58869. * Create an effect to use with particle systems.
  58870. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58871. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58872. * @param uniformsNames defines a list of attribute names
  58873. * @param samplers defines an array of string used to represent textures
  58874. * @param defines defines the string containing the defines to use to compile the shaders
  58875. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58876. * @param onCompiled defines a function to call when the effect creation is successful
  58877. * @param onError defines a function to call when the effect creation has failed
  58878. * @returns the new Effect
  58879. */
  58880. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58881. }
  58882. }
  58883. module "babylonjs/Meshes/mesh" {
  58884. interface Mesh {
  58885. /**
  58886. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58887. * @returns an array of IParticleSystem
  58888. */
  58889. getEmittedParticleSystems(): IParticleSystem[];
  58890. /**
  58891. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58892. * @returns an array of IParticleSystem
  58893. */
  58894. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58895. }
  58896. }
  58897. /**
  58898. * @hidden
  58899. */
  58900. export var _IDoNeedToBeInTheBuild: number;
  58901. }
  58902. declare module "babylonjs/Particles/index" {
  58903. export * from "babylonjs/Particles/baseParticleSystem";
  58904. export * from "babylonjs/Particles/EmitterTypes/index";
  58905. export * from "babylonjs/Particles/gpuParticleSystem";
  58906. export * from "babylonjs/Particles/IParticleSystem";
  58907. export * from "babylonjs/Particles/particle";
  58908. export * from "babylonjs/Particles/particleHelper";
  58909. export * from "babylonjs/Particles/particleSystem";
  58910. export * from "babylonjs/Particles/particleSystemComponent";
  58911. export * from "babylonjs/Particles/particleSystemSet";
  58912. export * from "babylonjs/Particles/solidParticle";
  58913. export * from "babylonjs/Particles/solidParticleSystem";
  58914. export * from "babylonjs/Particles/subEmitter";
  58915. }
  58916. declare module "babylonjs/Physics/physicsEngineComponent" {
  58917. import { Nullable } from "babylonjs/types";
  58918. import { Observable, Observer } from "babylonjs/Misc/observable";
  58919. import { Vector3 } from "babylonjs/Maths/math.vector";
  58920. import { Mesh } from "babylonjs/Meshes/mesh";
  58921. import { ISceneComponent } from "babylonjs/sceneComponent";
  58922. import { Scene } from "babylonjs/scene";
  58923. import { Node } from "babylonjs/node";
  58924. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58925. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58926. module "babylonjs/scene" {
  58927. interface Scene {
  58928. /** @hidden (Backing field) */
  58929. _physicsEngine: Nullable<IPhysicsEngine>;
  58930. /**
  58931. * Gets the current physics engine
  58932. * @returns a IPhysicsEngine or null if none attached
  58933. */
  58934. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58935. /**
  58936. * Enables physics to the current scene
  58937. * @param gravity defines the scene's gravity for the physics engine
  58938. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58939. * @return a boolean indicating if the physics engine was initialized
  58940. */
  58941. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58942. /**
  58943. * Disables and disposes the physics engine associated with the scene
  58944. */
  58945. disablePhysicsEngine(): void;
  58946. /**
  58947. * Gets a boolean indicating if there is an active physics engine
  58948. * @returns a boolean indicating if there is an active physics engine
  58949. */
  58950. isPhysicsEnabled(): boolean;
  58951. /**
  58952. * Deletes a physics compound impostor
  58953. * @param compound defines the compound to delete
  58954. */
  58955. deleteCompoundImpostor(compound: any): void;
  58956. /**
  58957. * An event triggered when physic simulation is about to be run
  58958. */
  58959. onBeforePhysicsObservable: Observable<Scene>;
  58960. /**
  58961. * An event triggered when physic simulation has been done
  58962. */
  58963. onAfterPhysicsObservable: Observable<Scene>;
  58964. }
  58965. }
  58966. module "babylonjs/Meshes/abstractMesh" {
  58967. interface AbstractMesh {
  58968. /** @hidden */
  58969. _physicsImpostor: Nullable<PhysicsImpostor>;
  58970. /**
  58971. * Gets or sets impostor used for physic simulation
  58972. * @see http://doc.babylonjs.com/features/physics_engine
  58973. */
  58974. physicsImpostor: Nullable<PhysicsImpostor>;
  58975. /**
  58976. * Gets the current physics impostor
  58977. * @see http://doc.babylonjs.com/features/physics_engine
  58978. * @returns a physics impostor or null
  58979. */
  58980. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58981. /** Apply a physic impulse to the mesh
  58982. * @param force defines the force to apply
  58983. * @param contactPoint defines where to apply the force
  58984. * @returns the current mesh
  58985. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58986. */
  58987. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58988. /**
  58989. * Creates a physic joint between two meshes
  58990. * @param otherMesh defines the other mesh to use
  58991. * @param pivot1 defines the pivot to use on this mesh
  58992. * @param pivot2 defines the pivot to use on the other mesh
  58993. * @param options defines additional options (can be plugin dependent)
  58994. * @returns the current mesh
  58995. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58996. */
  58997. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58998. /** @hidden */
  58999. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59000. }
  59001. }
  59002. /**
  59003. * Defines the physics engine scene component responsible to manage a physics engine
  59004. */
  59005. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59006. /**
  59007. * The component name helpful to identify the component in the list of scene components.
  59008. */
  59009. readonly name: string;
  59010. /**
  59011. * The scene the component belongs to.
  59012. */
  59013. scene: Scene;
  59014. /**
  59015. * Creates a new instance of the component for the given scene
  59016. * @param scene Defines the scene to register the component in
  59017. */
  59018. constructor(scene: Scene);
  59019. /**
  59020. * Registers the component in a given scene
  59021. */
  59022. register(): void;
  59023. /**
  59024. * Rebuilds the elements related to this component in case of
  59025. * context lost for instance.
  59026. */
  59027. rebuild(): void;
  59028. /**
  59029. * Disposes the component and the associated ressources
  59030. */
  59031. dispose(): void;
  59032. }
  59033. }
  59034. declare module "babylonjs/Physics/physicsHelper" {
  59035. import { Nullable } from "babylonjs/types";
  59036. import { Vector3 } from "babylonjs/Maths/math.vector";
  59037. import { Mesh } from "babylonjs/Meshes/mesh";
  59038. import { Scene } from "babylonjs/scene";
  59039. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59040. /**
  59041. * A helper for physics simulations
  59042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59043. */
  59044. export class PhysicsHelper {
  59045. private _scene;
  59046. private _physicsEngine;
  59047. /**
  59048. * Initializes the Physics helper
  59049. * @param scene Babylon.js scene
  59050. */
  59051. constructor(scene: Scene);
  59052. /**
  59053. * Applies a radial explosion impulse
  59054. * @param origin the origin of the explosion
  59055. * @param radiusOrEventOptions the radius or the options of radial explosion
  59056. * @param strength the explosion strength
  59057. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59058. * @returns A physics radial explosion event, or null
  59059. */
  59060. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59061. /**
  59062. * Applies a radial explosion force
  59063. * @param origin the origin of the explosion
  59064. * @param radiusOrEventOptions the radius or the options of radial explosion
  59065. * @param strength the explosion strength
  59066. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59067. * @returns A physics radial explosion event, or null
  59068. */
  59069. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59070. /**
  59071. * Creates a gravitational field
  59072. * @param origin the origin of the explosion
  59073. * @param radiusOrEventOptions the radius or the options of radial explosion
  59074. * @param strength the explosion strength
  59075. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59076. * @returns A physics gravitational field event, or null
  59077. */
  59078. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59079. /**
  59080. * Creates a physics updraft event
  59081. * @param origin the origin of the updraft
  59082. * @param radiusOrEventOptions the radius or the options of the updraft
  59083. * @param strength the strength of the updraft
  59084. * @param height the height of the updraft
  59085. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59086. * @returns A physics updraft event, or null
  59087. */
  59088. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59089. /**
  59090. * Creates a physics vortex event
  59091. * @param origin the of the vortex
  59092. * @param radiusOrEventOptions the radius or the options of the vortex
  59093. * @param strength the strength of the vortex
  59094. * @param height the height of the vortex
  59095. * @returns a Physics vortex event, or null
  59096. * A physics vortex event or null
  59097. */
  59098. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59099. }
  59100. /**
  59101. * Represents a physics radial explosion event
  59102. */
  59103. class PhysicsRadialExplosionEvent {
  59104. private _scene;
  59105. private _options;
  59106. private _sphere;
  59107. private _dataFetched;
  59108. /**
  59109. * Initializes a radial explosioin event
  59110. * @param _scene BabylonJS scene
  59111. * @param _options The options for the vortex event
  59112. */
  59113. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59114. /**
  59115. * Returns the data related to the radial explosion event (sphere).
  59116. * @returns The radial explosion event data
  59117. */
  59118. getData(): PhysicsRadialExplosionEventData;
  59119. /**
  59120. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59121. * @param impostor A physics imposter
  59122. * @param origin the origin of the explosion
  59123. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59124. */
  59125. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59126. /**
  59127. * Triggers affecterd impostors callbacks
  59128. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59129. */
  59130. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59131. /**
  59132. * Disposes the sphere.
  59133. * @param force Specifies if the sphere should be disposed by force
  59134. */
  59135. dispose(force?: boolean): void;
  59136. /*** Helpers ***/
  59137. private _prepareSphere;
  59138. private _intersectsWithSphere;
  59139. }
  59140. /**
  59141. * Represents a gravitational field event
  59142. */
  59143. class PhysicsGravitationalFieldEvent {
  59144. private _physicsHelper;
  59145. private _scene;
  59146. private _origin;
  59147. private _options;
  59148. private _tickCallback;
  59149. private _sphere;
  59150. private _dataFetched;
  59151. /**
  59152. * Initializes the physics gravitational field event
  59153. * @param _physicsHelper A physics helper
  59154. * @param _scene BabylonJS scene
  59155. * @param _origin The origin position of the gravitational field event
  59156. * @param _options The options for the vortex event
  59157. */
  59158. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59159. /**
  59160. * Returns the data related to the gravitational field event (sphere).
  59161. * @returns A gravitational field event
  59162. */
  59163. getData(): PhysicsGravitationalFieldEventData;
  59164. /**
  59165. * Enables the gravitational field.
  59166. */
  59167. enable(): void;
  59168. /**
  59169. * Disables the gravitational field.
  59170. */
  59171. disable(): void;
  59172. /**
  59173. * Disposes the sphere.
  59174. * @param force The force to dispose from the gravitational field event
  59175. */
  59176. dispose(force?: boolean): void;
  59177. private _tick;
  59178. }
  59179. /**
  59180. * Represents a physics updraft event
  59181. */
  59182. class PhysicsUpdraftEvent {
  59183. private _scene;
  59184. private _origin;
  59185. private _options;
  59186. private _physicsEngine;
  59187. private _originTop;
  59188. private _originDirection;
  59189. private _tickCallback;
  59190. private _cylinder;
  59191. private _cylinderPosition;
  59192. private _dataFetched;
  59193. /**
  59194. * Initializes the physics updraft event
  59195. * @param _scene BabylonJS scene
  59196. * @param _origin The origin position of the updraft
  59197. * @param _options The options for the updraft event
  59198. */
  59199. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59200. /**
  59201. * Returns the data related to the updraft event (cylinder).
  59202. * @returns A physics updraft event
  59203. */
  59204. getData(): PhysicsUpdraftEventData;
  59205. /**
  59206. * Enables the updraft.
  59207. */
  59208. enable(): void;
  59209. /**
  59210. * Disables the updraft.
  59211. */
  59212. disable(): void;
  59213. /**
  59214. * Disposes the cylinder.
  59215. * @param force Specifies if the updraft should be disposed by force
  59216. */
  59217. dispose(force?: boolean): void;
  59218. private getImpostorHitData;
  59219. private _tick;
  59220. /*** Helpers ***/
  59221. private _prepareCylinder;
  59222. private _intersectsWithCylinder;
  59223. }
  59224. /**
  59225. * Represents a physics vortex event
  59226. */
  59227. class PhysicsVortexEvent {
  59228. private _scene;
  59229. private _origin;
  59230. private _options;
  59231. private _physicsEngine;
  59232. private _originTop;
  59233. private _tickCallback;
  59234. private _cylinder;
  59235. private _cylinderPosition;
  59236. private _dataFetched;
  59237. /**
  59238. * Initializes the physics vortex event
  59239. * @param _scene The BabylonJS scene
  59240. * @param _origin The origin position of the vortex
  59241. * @param _options The options for the vortex event
  59242. */
  59243. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59244. /**
  59245. * Returns the data related to the vortex event (cylinder).
  59246. * @returns The physics vortex event data
  59247. */
  59248. getData(): PhysicsVortexEventData;
  59249. /**
  59250. * Enables the vortex.
  59251. */
  59252. enable(): void;
  59253. /**
  59254. * Disables the cortex.
  59255. */
  59256. disable(): void;
  59257. /**
  59258. * Disposes the sphere.
  59259. * @param force
  59260. */
  59261. dispose(force?: boolean): void;
  59262. private getImpostorHitData;
  59263. private _tick;
  59264. /*** Helpers ***/
  59265. private _prepareCylinder;
  59266. private _intersectsWithCylinder;
  59267. }
  59268. /**
  59269. * Options fot the radial explosion event
  59270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59271. */
  59272. export class PhysicsRadialExplosionEventOptions {
  59273. /**
  59274. * The radius of the sphere for the radial explosion.
  59275. */
  59276. radius: number;
  59277. /**
  59278. * The strenth of the explosion.
  59279. */
  59280. strength: number;
  59281. /**
  59282. * The strenght of the force in correspondence to the distance of the affected object
  59283. */
  59284. falloff: PhysicsRadialImpulseFalloff;
  59285. /**
  59286. * Sphere options for the radial explosion.
  59287. */
  59288. sphere: {
  59289. segments: number;
  59290. diameter: number;
  59291. };
  59292. /**
  59293. * Sphere options for the radial explosion.
  59294. */
  59295. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59296. }
  59297. /**
  59298. * Options fot the updraft event
  59299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59300. */
  59301. export class PhysicsUpdraftEventOptions {
  59302. /**
  59303. * The radius of the cylinder for the vortex
  59304. */
  59305. radius: number;
  59306. /**
  59307. * The strenth of the updraft.
  59308. */
  59309. strength: number;
  59310. /**
  59311. * The height of the cylinder for the updraft.
  59312. */
  59313. height: number;
  59314. /**
  59315. * The mode for the the updraft.
  59316. */
  59317. updraftMode: PhysicsUpdraftMode;
  59318. }
  59319. /**
  59320. * Options fot the vortex event
  59321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59322. */
  59323. export class PhysicsVortexEventOptions {
  59324. /**
  59325. * The radius of the cylinder for the vortex
  59326. */
  59327. radius: number;
  59328. /**
  59329. * The strenth of the vortex.
  59330. */
  59331. strength: number;
  59332. /**
  59333. * The height of the cylinder for the vortex.
  59334. */
  59335. height: number;
  59336. /**
  59337. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59338. */
  59339. centripetalForceThreshold: number;
  59340. /**
  59341. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59342. */
  59343. centripetalForceMultiplier: number;
  59344. /**
  59345. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59346. */
  59347. centrifugalForceMultiplier: number;
  59348. /**
  59349. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59350. */
  59351. updraftForceMultiplier: number;
  59352. }
  59353. /**
  59354. * The strenght of the force in correspondence to the distance of the affected object
  59355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59356. */
  59357. export enum PhysicsRadialImpulseFalloff {
  59358. /** Defines that impulse is constant in strength across it's whole radius */
  59359. Constant = 0,
  59360. /** Defines that impulse gets weaker if it's further from the origin */
  59361. Linear = 1
  59362. }
  59363. /**
  59364. * The strength of the force in correspondence to the distance of the affected object
  59365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59366. */
  59367. export enum PhysicsUpdraftMode {
  59368. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59369. Center = 0,
  59370. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59371. Perpendicular = 1
  59372. }
  59373. /**
  59374. * Interface for a physics hit data
  59375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59376. */
  59377. export interface PhysicsHitData {
  59378. /**
  59379. * The force applied at the contact point
  59380. */
  59381. force: Vector3;
  59382. /**
  59383. * The contact point
  59384. */
  59385. contactPoint: Vector3;
  59386. /**
  59387. * The distance from the origin to the contact point
  59388. */
  59389. distanceFromOrigin: number;
  59390. }
  59391. /**
  59392. * Interface for radial explosion event data
  59393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59394. */
  59395. export interface PhysicsRadialExplosionEventData {
  59396. /**
  59397. * A sphere used for the radial explosion event
  59398. */
  59399. sphere: Mesh;
  59400. }
  59401. /**
  59402. * Interface for gravitational field event data
  59403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59404. */
  59405. export interface PhysicsGravitationalFieldEventData {
  59406. /**
  59407. * A sphere mesh used for the gravitational field event
  59408. */
  59409. sphere: Mesh;
  59410. }
  59411. /**
  59412. * Interface for updraft event data
  59413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59414. */
  59415. export interface PhysicsUpdraftEventData {
  59416. /**
  59417. * A cylinder used for the updraft event
  59418. */
  59419. cylinder: Mesh;
  59420. }
  59421. /**
  59422. * Interface for vortex event data
  59423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59424. */
  59425. export interface PhysicsVortexEventData {
  59426. /**
  59427. * A cylinder used for the vortex event
  59428. */
  59429. cylinder: Mesh;
  59430. }
  59431. /**
  59432. * Interface for an affected physics impostor
  59433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59434. */
  59435. export interface PhysicsAffectedImpostorWithData {
  59436. /**
  59437. * The impostor affected by the effect
  59438. */
  59439. impostor: PhysicsImpostor;
  59440. /**
  59441. * The data about the hit/horce from the explosion
  59442. */
  59443. hitData: PhysicsHitData;
  59444. }
  59445. }
  59446. declare module "babylonjs/Physics/Plugins/index" {
  59447. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  59448. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  59449. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  59450. }
  59451. declare module "babylonjs/Physics/index" {
  59452. export * from "babylonjs/Physics/IPhysicsEngine";
  59453. export * from "babylonjs/Physics/physicsEngine";
  59454. export * from "babylonjs/Physics/physicsEngineComponent";
  59455. export * from "babylonjs/Physics/physicsHelper";
  59456. export * from "babylonjs/Physics/physicsImpostor";
  59457. export * from "babylonjs/Physics/physicsJoint";
  59458. export * from "babylonjs/Physics/Plugins/index";
  59459. }
  59460. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59461. /** @hidden */
  59462. export var blackAndWhitePixelShader: {
  59463. name: string;
  59464. shader: string;
  59465. };
  59466. }
  59467. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59468. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59469. import { Camera } from "babylonjs/Cameras/camera";
  59470. import { Engine } from "babylonjs/Engines/engine";
  59471. import "babylonjs/Shaders/blackAndWhite.fragment";
  59472. /**
  59473. * Post process used to render in black and white
  59474. */
  59475. export class BlackAndWhitePostProcess extends PostProcess {
  59476. /**
  59477. * Linear about to convert he result to black and white (default: 1)
  59478. */
  59479. degree: number;
  59480. /**
  59481. * Creates a black and white post process
  59482. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59483. * @param name The name of the effect.
  59484. * @param options The required width/height ratio to downsize to before computing the render pass.
  59485. * @param camera The camera to apply the render pass to.
  59486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59487. * @param engine The engine which the post process will be applied. (default: current engine)
  59488. * @param reusable If the post process can be reused on the same frame. (default: false)
  59489. */
  59490. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59491. }
  59492. }
  59493. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59494. import { Nullable } from "babylonjs/types";
  59495. import { Camera } from "babylonjs/Cameras/camera";
  59496. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59497. import { Engine } from "babylonjs/Engines/engine";
  59498. /**
  59499. * This represents a set of one or more post processes in Babylon.
  59500. * A post process can be used to apply a shader to a texture after it is rendered.
  59501. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59502. */
  59503. export class PostProcessRenderEffect {
  59504. private _postProcesses;
  59505. private _getPostProcesses;
  59506. private _singleInstance;
  59507. private _cameras;
  59508. private _indicesForCamera;
  59509. /**
  59510. * Name of the effect
  59511. * @hidden
  59512. */
  59513. _name: string;
  59514. /**
  59515. * Instantiates a post process render effect.
  59516. * A post process can be used to apply a shader to a texture after it is rendered.
  59517. * @param engine The engine the effect is tied to
  59518. * @param name The name of the effect
  59519. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59520. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59521. */
  59522. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59523. /**
  59524. * Checks if all the post processes in the effect are supported.
  59525. */
  59526. readonly isSupported: boolean;
  59527. /**
  59528. * Updates the current state of the effect
  59529. * @hidden
  59530. */
  59531. _update(): void;
  59532. /**
  59533. * Attaches the effect on cameras
  59534. * @param cameras The camera to attach to.
  59535. * @hidden
  59536. */
  59537. _attachCameras(cameras: Camera): void;
  59538. /**
  59539. * Attaches the effect on cameras
  59540. * @param cameras The camera to attach to.
  59541. * @hidden
  59542. */
  59543. _attachCameras(cameras: Camera[]): void;
  59544. /**
  59545. * Detaches the effect on cameras
  59546. * @param cameras The camera to detatch from.
  59547. * @hidden
  59548. */
  59549. _detachCameras(cameras: Camera): void;
  59550. /**
  59551. * Detatches the effect on cameras
  59552. * @param cameras The camera to detatch from.
  59553. * @hidden
  59554. */
  59555. _detachCameras(cameras: Camera[]): void;
  59556. /**
  59557. * Enables the effect on given cameras
  59558. * @param cameras The camera to enable.
  59559. * @hidden
  59560. */
  59561. _enable(cameras: Camera): void;
  59562. /**
  59563. * Enables the effect on given cameras
  59564. * @param cameras The camera to enable.
  59565. * @hidden
  59566. */
  59567. _enable(cameras: Nullable<Camera[]>): void;
  59568. /**
  59569. * Disables the effect on the given cameras
  59570. * @param cameras The camera to disable.
  59571. * @hidden
  59572. */
  59573. _disable(cameras: Camera): void;
  59574. /**
  59575. * Disables the effect on the given cameras
  59576. * @param cameras The camera to disable.
  59577. * @hidden
  59578. */
  59579. _disable(cameras: Nullable<Camera[]>): void;
  59580. /**
  59581. * Gets a list of the post processes contained in the effect.
  59582. * @param camera The camera to get the post processes on.
  59583. * @returns The list of the post processes in the effect.
  59584. */
  59585. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59586. }
  59587. }
  59588. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  59589. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59590. /** @hidden */
  59591. export var extractHighlightsPixelShader: {
  59592. name: string;
  59593. shader: string;
  59594. };
  59595. }
  59596. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  59597. import { Nullable } from "babylonjs/types";
  59598. import { Camera } from "babylonjs/Cameras/camera";
  59599. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59600. import { Engine } from "babylonjs/Engines/engine";
  59601. import "babylonjs/Shaders/extractHighlights.fragment";
  59602. /**
  59603. * 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.
  59604. */
  59605. export class ExtractHighlightsPostProcess extends PostProcess {
  59606. /**
  59607. * The luminance threshold, pixels below this value will be set to black.
  59608. */
  59609. threshold: number;
  59610. /** @hidden */
  59611. _exposure: number;
  59612. /**
  59613. * Post process which has the input texture to be used when performing highlight extraction
  59614. * @hidden
  59615. */
  59616. _inputPostProcess: Nullable<PostProcess>;
  59617. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59618. }
  59619. }
  59620. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59621. /** @hidden */
  59622. export var bloomMergePixelShader: {
  59623. name: string;
  59624. shader: string;
  59625. };
  59626. }
  59627. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59628. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59629. import { Nullable } from "babylonjs/types";
  59630. import { Engine } from "babylonjs/Engines/engine";
  59631. import { Camera } from "babylonjs/Cameras/camera";
  59632. import "babylonjs/Shaders/bloomMerge.fragment";
  59633. /**
  59634. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59635. */
  59636. export class BloomMergePostProcess extends PostProcess {
  59637. /** Weight of the bloom to be added to the original input. */
  59638. weight: number;
  59639. /**
  59640. * Creates a new instance of @see BloomMergePostProcess
  59641. * @param name The name of the effect.
  59642. * @param originalFromInput Post process which's input will be used for the merge.
  59643. * @param blurred Blurred highlights post process which's output will be used.
  59644. * @param weight Weight of the bloom to be added to the original input.
  59645. * @param options The required width/height ratio to downsize to before computing the render pass.
  59646. * @param camera The camera to apply the render pass to.
  59647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59648. * @param engine The engine which the post process will be applied. (default: current engine)
  59649. * @param reusable If the post process can be reused on the same frame. (default: false)
  59650. * @param textureType Type of textures used when performing the post process. (default: 0)
  59651. * @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)
  59652. */
  59653. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59654. /** Weight of the bloom to be added to the original input. */
  59655. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59656. }
  59657. }
  59658. declare module "babylonjs/PostProcesses/bloomEffect" {
  59659. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59660. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59661. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59662. import { Camera } from "babylonjs/Cameras/camera";
  59663. import { Scene } from "babylonjs/scene";
  59664. /**
  59665. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59666. */
  59667. export class BloomEffect extends PostProcessRenderEffect {
  59668. private bloomScale;
  59669. /**
  59670. * @hidden Internal
  59671. */
  59672. _effects: Array<PostProcess>;
  59673. /**
  59674. * @hidden Internal
  59675. */
  59676. _downscale: ExtractHighlightsPostProcess;
  59677. private _blurX;
  59678. private _blurY;
  59679. private _merge;
  59680. /**
  59681. * The luminance threshold to find bright areas of the image to bloom.
  59682. */
  59683. threshold: number;
  59684. /**
  59685. * The strength of the bloom.
  59686. */
  59687. weight: number;
  59688. /**
  59689. * Specifies the size of the bloom blur kernel, relative to the final output size
  59690. */
  59691. kernel: number;
  59692. /**
  59693. * Creates a new instance of @see BloomEffect
  59694. * @param scene The scene the effect belongs to.
  59695. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59696. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59697. * @param bloomWeight The the strength of bloom.
  59698. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59699. * @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)
  59700. */
  59701. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59702. /**
  59703. * Disposes each of the internal effects for a given camera.
  59704. * @param camera The camera to dispose the effect on.
  59705. */
  59706. disposeEffects(camera: Camera): void;
  59707. /**
  59708. * @hidden Internal
  59709. */
  59710. _updateEffects(): void;
  59711. /**
  59712. * Internal
  59713. * @returns if all the contained post processes are ready.
  59714. * @hidden
  59715. */
  59716. _isReady(): boolean;
  59717. }
  59718. }
  59719. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59720. /** @hidden */
  59721. export var chromaticAberrationPixelShader: {
  59722. name: string;
  59723. shader: string;
  59724. };
  59725. }
  59726. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59727. import { Vector2 } from "babylonjs/Maths/math.vector";
  59728. import { Nullable } from "babylonjs/types";
  59729. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59730. import { Camera } from "babylonjs/Cameras/camera";
  59731. import { Engine } from "babylonjs/Engines/engine";
  59732. import "babylonjs/Shaders/chromaticAberration.fragment";
  59733. /**
  59734. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59735. */
  59736. export class ChromaticAberrationPostProcess extends PostProcess {
  59737. /**
  59738. * The amount of seperation of rgb channels (default: 30)
  59739. */
  59740. aberrationAmount: number;
  59741. /**
  59742. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59743. */
  59744. radialIntensity: number;
  59745. /**
  59746. * 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))
  59747. */
  59748. direction: Vector2;
  59749. /**
  59750. * 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))
  59751. */
  59752. centerPosition: Vector2;
  59753. /**
  59754. * Creates a new instance ChromaticAberrationPostProcess
  59755. * @param name The name of the effect.
  59756. * @param screenWidth The width of the screen to apply the effect on.
  59757. * @param screenHeight The height of the screen to apply the effect on.
  59758. * @param options The required width/height ratio to downsize to before computing the render pass.
  59759. * @param camera The camera to apply the render pass to.
  59760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59761. * @param engine The engine which the post process will be applied. (default: current engine)
  59762. * @param reusable If the post process can be reused on the same frame. (default: false)
  59763. * @param textureType Type of textures used when performing the post process. (default: 0)
  59764. * @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)
  59765. */
  59766. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59767. }
  59768. }
  59769. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59770. /** @hidden */
  59771. export var circleOfConfusionPixelShader: {
  59772. name: string;
  59773. shader: string;
  59774. };
  59775. }
  59776. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59777. import { Nullable } from "babylonjs/types";
  59778. import { Engine } from "babylonjs/Engines/engine";
  59779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59780. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59781. import { Camera } from "babylonjs/Cameras/camera";
  59782. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59783. /**
  59784. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59785. */
  59786. export class CircleOfConfusionPostProcess extends PostProcess {
  59787. /**
  59788. * 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.
  59789. */
  59790. lensSize: number;
  59791. /**
  59792. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59793. */
  59794. fStop: number;
  59795. /**
  59796. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59797. */
  59798. focusDistance: number;
  59799. /**
  59800. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59801. */
  59802. focalLength: number;
  59803. private _depthTexture;
  59804. /**
  59805. * Creates a new instance CircleOfConfusionPostProcess
  59806. * @param name The name of the effect.
  59807. * @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.
  59808. * @param options The required width/height ratio to downsize to before computing the render pass.
  59809. * @param camera The camera to apply the render pass to.
  59810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59811. * @param engine The engine which the post process will be applied. (default: current engine)
  59812. * @param reusable If the post process can be reused on the same frame. (default: false)
  59813. * @param textureType Type of textures used when performing the post process. (default: 0)
  59814. * @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)
  59815. */
  59816. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59817. /**
  59818. * 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.
  59819. */
  59820. depthTexture: RenderTargetTexture;
  59821. }
  59822. }
  59823. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59824. /** @hidden */
  59825. export var colorCorrectionPixelShader: {
  59826. name: string;
  59827. shader: string;
  59828. };
  59829. }
  59830. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59831. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59832. import { Engine } from "babylonjs/Engines/engine";
  59833. import { Camera } from "babylonjs/Cameras/camera";
  59834. import "babylonjs/Shaders/colorCorrection.fragment";
  59835. /**
  59836. *
  59837. * This post-process allows the modification of rendered colors by using
  59838. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59839. *
  59840. * The object needs to be provided an url to a texture containing the color
  59841. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59842. * Use an image editing software to tweak the LUT to match your needs.
  59843. *
  59844. * For an example of a color LUT, see here:
  59845. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59846. * For explanations on color grading, see here:
  59847. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59848. *
  59849. */
  59850. export class ColorCorrectionPostProcess extends PostProcess {
  59851. private _colorTableTexture;
  59852. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59853. }
  59854. }
  59855. declare module "babylonjs/Shaders/convolution.fragment" {
  59856. /** @hidden */
  59857. export var convolutionPixelShader: {
  59858. name: string;
  59859. shader: string;
  59860. };
  59861. }
  59862. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59863. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59864. import { Nullable } from "babylonjs/types";
  59865. import { Camera } from "babylonjs/Cameras/camera";
  59866. import { Engine } from "babylonjs/Engines/engine";
  59867. import "babylonjs/Shaders/convolution.fragment";
  59868. /**
  59869. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59870. * input texture to perform effects such as edge detection or sharpening
  59871. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59872. */
  59873. export class ConvolutionPostProcess extends PostProcess {
  59874. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59875. kernel: number[];
  59876. /**
  59877. * Creates a new instance ConvolutionPostProcess
  59878. * @param name The name of the effect.
  59879. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59880. * @param options The required width/height ratio to downsize to before computing the render pass.
  59881. * @param camera The camera to apply the render pass to.
  59882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59883. * @param engine The engine which the post process will be applied. (default: current engine)
  59884. * @param reusable If the post process can be reused on the same frame. (default: false)
  59885. * @param textureType Type of textures used when performing the post process. (default: 0)
  59886. */
  59887. constructor(name: string,
  59888. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59889. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59890. /**
  59891. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59892. */
  59893. static EdgeDetect0Kernel: number[];
  59894. /**
  59895. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59896. */
  59897. static EdgeDetect1Kernel: number[];
  59898. /**
  59899. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59900. */
  59901. static EdgeDetect2Kernel: number[];
  59902. /**
  59903. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59904. */
  59905. static SharpenKernel: number[];
  59906. /**
  59907. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59908. */
  59909. static EmbossKernel: number[];
  59910. /**
  59911. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59912. */
  59913. static GaussianKernel: number[];
  59914. }
  59915. }
  59916. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  59917. import { Nullable } from "babylonjs/types";
  59918. import { Vector2 } from "babylonjs/Maths/math.vector";
  59919. import { Camera } from "babylonjs/Cameras/camera";
  59920. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59921. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59922. import { Engine } from "babylonjs/Engines/engine";
  59923. import { Scene } from "babylonjs/scene";
  59924. /**
  59925. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59926. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59927. * based on samples that have a large difference in distance than the center pixel.
  59928. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59929. */
  59930. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59931. direction: Vector2;
  59932. /**
  59933. * Creates a new instance CircleOfConfusionPostProcess
  59934. * @param name The name of the effect.
  59935. * @param scene The scene the effect belongs to.
  59936. * @param direction The direction the blur should be applied.
  59937. * @param kernel The size of the kernel used to blur.
  59938. * @param options The required width/height ratio to downsize to before computing the render pass.
  59939. * @param camera The camera to apply the render pass to.
  59940. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59941. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59943. * @param engine The engine which the post process will be applied. (default: current engine)
  59944. * @param reusable If the post process can be reused on the same frame. (default: false)
  59945. * @param textureType Type of textures used when performing the post process. (default: 0)
  59946. * @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)
  59947. */
  59948. 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);
  59949. }
  59950. }
  59951. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  59952. /** @hidden */
  59953. export var depthOfFieldMergePixelShader: {
  59954. name: string;
  59955. shader: string;
  59956. };
  59957. }
  59958. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  59959. import { Nullable } from "babylonjs/types";
  59960. import { Camera } from "babylonjs/Cameras/camera";
  59961. import { Effect } from "babylonjs/Materials/effect";
  59962. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59963. import { Engine } from "babylonjs/Engines/engine";
  59964. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  59965. /**
  59966. * Options to be set when merging outputs from the default pipeline.
  59967. */
  59968. export class DepthOfFieldMergePostProcessOptions {
  59969. /**
  59970. * The original image to merge on top of
  59971. */
  59972. originalFromInput: PostProcess;
  59973. /**
  59974. * Parameters to perform the merge of the depth of field effect
  59975. */
  59976. depthOfField?: {
  59977. circleOfConfusion: PostProcess;
  59978. blurSteps: Array<PostProcess>;
  59979. };
  59980. /**
  59981. * Parameters to perform the merge of bloom effect
  59982. */
  59983. bloom?: {
  59984. blurred: PostProcess;
  59985. weight: number;
  59986. };
  59987. }
  59988. /**
  59989. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59990. */
  59991. export class DepthOfFieldMergePostProcess extends PostProcess {
  59992. private blurSteps;
  59993. /**
  59994. * Creates a new instance of DepthOfFieldMergePostProcess
  59995. * @param name The name of the effect.
  59996. * @param originalFromInput Post process which's input will be used for the merge.
  59997. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59998. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59999. * @param options The required width/height ratio to downsize to before computing the render pass.
  60000. * @param camera The camera to apply the render pass to.
  60001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60002. * @param engine The engine which the post process will be applied. (default: current engine)
  60003. * @param reusable If the post process can be reused on the same frame. (default: false)
  60004. * @param textureType Type of textures used when performing the post process. (default: 0)
  60005. * @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)
  60006. */
  60007. 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);
  60008. /**
  60009. * Updates the effect with the current post process compile time values and recompiles the shader.
  60010. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60011. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60012. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60013. * @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
  60014. * @param onCompiled Called when the shader has been compiled.
  60015. * @param onError Called if there is an error when compiling a shader.
  60016. */
  60017. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60018. }
  60019. }
  60020. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  60021. import { Nullable } from "babylonjs/types";
  60022. import { Camera } from "babylonjs/Cameras/camera";
  60023. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60025. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60026. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60027. import { Scene } from "babylonjs/scene";
  60028. /**
  60029. * Specifies the level of max blur that should be applied when using the depth of field effect
  60030. */
  60031. export enum DepthOfFieldEffectBlurLevel {
  60032. /**
  60033. * Subtle blur
  60034. */
  60035. Low = 0,
  60036. /**
  60037. * Medium blur
  60038. */
  60039. Medium = 1,
  60040. /**
  60041. * Large blur
  60042. */
  60043. High = 2
  60044. }
  60045. /**
  60046. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60047. */
  60048. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60049. private _circleOfConfusion;
  60050. /**
  60051. * @hidden Internal, blurs from high to low
  60052. */
  60053. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60054. private _depthOfFieldBlurY;
  60055. private _dofMerge;
  60056. /**
  60057. * @hidden Internal post processes in depth of field effect
  60058. */
  60059. _effects: Array<PostProcess>;
  60060. /**
  60061. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60062. */
  60063. focalLength: number;
  60064. /**
  60065. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60066. */
  60067. fStop: number;
  60068. /**
  60069. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60070. */
  60071. focusDistance: number;
  60072. /**
  60073. * 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.
  60074. */
  60075. lensSize: number;
  60076. /**
  60077. * Creates a new instance DepthOfFieldEffect
  60078. * @param scene The scene the effect belongs to.
  60079. * @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.
  60080. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60081. * @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)
  60082. */
  60083. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60084. /**
  60085. * Get the current class name of the current effet
  60086. * @returns "DepthOfFieldEffect"
  60087. */
  60088. getClassName(): string;
  60089. /**
  60090. * 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.
  60091. */
  60092. depthTexture: RenderTargetTexture;
  60093. /**
  60094. * Disposes each of the internal effects for a given camera.
  60095. * @param camera The camera to dispose the effect on.
  60096. */
  60097. disposeEffects(camera: Camera): void;
  60098. /**
  60099. * @hidden Internal
  60100. */
  60101. _updateEffects(): void;
  60102. /**
  60103. * Internal
  60104. * @returns if all the contained post processes are ready.
  60105. * @hidden
  60106. */
  60107. _isReady(): boolean;
  60108. }
  60109. }
  60110. declare module "babylonjs/Shaders/displayPass.fragment" {
  60111. /** @hidden */
  60112. export var displayPassPixelShader: {
  60113. name: string;
  60114. shader: string;
  60115. };
  60116. }
  60117. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  60118. import { Nullable } from "babylonjs/types";
  60119. import { Camera } from "babylonjs/Cameras/camera";
  60120. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60121. import { Engine } from "babylonjs/Engines/engine";
  60122. import "babylonjs/Shaders/displayPass.fragment";
  60123. /**
  60124. * DisplayPassPostProcess which produces an output the same as it's input
  60125. */
  60126. export class DisplayPassPostProcess extends PostProcess {
  60127. /**
  60128. * Creates the DisplayPassPostProcess
  60129. * @param name The name of the effect.
  60130. * @param options The required width/height ratio to downsize to before computing the render pass.
  60131. * @param camera The camera to apply the render pass to.
  60132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60133. * @param engine The engine which the post process will be applied. (default: current engine)
  60134. * @param reusable If the post process can be reused on the same frame. (default: false)
  60135. */
  60136. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60137. }
  60138. }
  60139. declare module "babylonjs/Shaders/filter.fragment" {
  60140. /** @hidden */
  60141. export var filterPixelShader: {
  60142. name: string;
  60143. shader: string;
  60144. };
  60145. }
  60146. declare module "babylonjs/PostProcesses/filterPostProcess" {
  60147. import { Nullable } from "babylonjs/types";
  60148. import { Matrix } from "babylonjs/Maths/math.vector";
  60149. import { Camera } from "babylonjs/Cameras/camera";
  60150. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60151. import { Engine } from "babylonjs/Engines/engine";
  60152. import "babylonjs/Shaders/filter.fragment";
  60153. /**
  60154. * Applies a kernel filter to the image
  60155. */
  60156. export class FilterPostProcess extends PostProcess {
  60157. /** The matrix to be applied to the image */
  60158. kernelMatrix: Matrix;
  60159. /**
  60160. *
  60161. * @param name The name of the effect.
  60162. * @param kernelMatrix The matrix to be applied to the image
  60163. * @param options The required width/height ratio to downsize to before computing the render pass.
  60164. * @param camera The camera to apply the render pass to.
  60165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60166. * @param engine The engine which the post process will be applied. (default: current engine)
  60167. * @param reusable If the post process can be reused on the same frame. (default: false)
  60168. */
  60169. constructor(name: string,
  60170. /** The matrix to be applied to the image */
  60171. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60172. }
  60173. }
  60174. declare module "babylonjs/Shaders/fxaa.fragment" {
  60175. /** @hidden */
  60176. export var fxaaPixelShader: {
  60177. name: string;
  60178. shader: string;
  60179. };
  60180. }
  60181. declare module "babylonjs/Shaders/fxaa.vertex" {
  60182. /** @hidden */
  60183. export var fxaaVertexShader: {
  60184. name: string;
  60185. shader: string;
  60186. };
  60187. }
  60188. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  60189. import { Nullable } from "babylonjs/types";
  60190. import { Camera } from "babylonjs/Cameras/camera";
  60191. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60192. import { Engine } from "babylonjs/Engines/engine";
  60193. import "babylonjs/Shaders/fxaa.fragment";
  60194. import "babylonjs/Shaders/fxaa.vertex";
  60195. /**
  60196. * Fxaa post process
  60197. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60198. */
  60199. export class FxaaPostProcess extends PostProcess {
  60200. /** @hidden */
  60201. texelWidth: number;
  60202. /** @hidden */
  60203. texelHeight: number;
  60204. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60205. private _getDefines;
  60206. }
  60207. }
  60208. declare module "babylonjs/Shaders/grain.fragment" {
  60209. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60210. /** @hidden */
  60211. export var grainPixelShader: {
  60212. name: string;
  60213. shader: string;
  60214. };
  60215. }
  60216. declare module "babylonjs/PostProcesses/grainPostProcess" {
  60217. import { Nullable } from "babylonjs/types";
  60218. import { Camera } from "babylonjs/Cameras/camera";
  60219. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60220. import { Engine } from "babylonjs/Engines/engine";
  60221. import "babylonjs/Shaders/grain.fragment";
  60222. /**
  60223. * The GrainPostProcess adds noise to the image at mid luminance levels
  60224. */
  60225. export class GrainPostProcess extends PostProcess {
  60226. /**
  60227. * The intensity of the grain added (default: 30)
  60228. */
  60229. intensity: number;
  60230. /**
  60231. * If the grain should be randomized on every frame
  60232. */
  60233. animated: boolean;
  60234. /**
  60235. * Creates a new instance of @see GrainPostProcess
  60236. * @param name The name of the effect.
  60237. * @param options The required width/height ratio to downsize to before computing the render pass.
  60238. * @param camera The camera to apply the render pass to.
  60239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60240. * @param engine The engine which the post process will be applied. (default: current engine)
  60241. * @param reusable If the post process can be reused on the same frame. (default: false)
  60242. * @param textureType Type of textures used when performing the post process. (default: 0)
  60243. * @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)
  60244. */
  60245. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60246. }
  60247. }
  60248. declare module "babylonjs/Shaders/highlights.fragment" {
  60249. /** @hidden */
  60250. export var highlightsPixelShader: {
  60251. name: string;
  60252. shader: string;
  60253. };
  60254. }
  60255. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  60256. import { Nullable } from "babylonjs/types";
  60257. import { Camera } from "babylonjs/Cameras/camera";
  60258. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60259. import { Engine } from "babylonjs/Engines/engine";
  60260. import "babylonjs/Shaders/highlights.fragment";
  60261. /**
  60262. * Extracts highlights from the image
  60263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60264. */
  60265. export class HighlightsPostProcess extends PostProcess {
  60266. /**
  60267. * Extracts highlights from the image
  60268. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60269. * @param name The name of the effect.
  60270. * @param options The required width/height ratio to downsize to before computing the render pass.
  60271. * @param camera The camera to apply the render pass to.
  60272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60273. * @param engine The engine which the post process will be applied. (default: current engine)
  60274. * @param reusable If the post process can be reused on the same frame. (default: false)
  60275. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60276. */
  60277. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60278. }
  60279. }
  60280. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  60281. /** @hidden */
  60282. export var mrtFragmentDeclaration: {
  60283. name: string;
  60284. shader: string;
  60285. };
  60286. }
  60287. declare module "babylonjs/Shaders/geometry.fragment" {
  60288. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  60289. /** @hidden */
  60290. export var geometryPixelShader: {
  60291. name: string;
  60292. shader: string;
  60293. };
  60294. }
  60295. declare module "babylonjs/Shaders/geometry.vertex" {
  60296. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60297. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60298. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60299. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60300. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60301. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60302. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60303. /** @hidden */
  60304. export var geometryVertexShader: {
  60305. name: string;
  60306. shader: string;
  60307. };
  60308. }
  60309. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  60310. import { Matrix } from "babylonjs/Maths/math.vector";
  60311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60312. import { Mesh } from "babylonjs/Meshes/mesh";
  60313. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  60314. import { Effect } from "babylonjs/Materials/effect";
  60315. import { Scene } from "babylonjs/scene";
  60316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60317. import "babylonjs/Shaders/geometry.fragment";
  60318. import "babylonjs/Shaders/geometry.vertex";
  60319. /** @hidden */
  60320. interface ISavedTransformationMatrix {
  60321. world: Matrix;
  60322. viewProjection: Matrix;
  60323. }
  60324. /**
  60325. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60326. */
  60327. export class GeometryBufferRenderer {
  60328. /**
  60329. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60330. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60331. */
  60332. static readonly POSITION_TEXTURE_TYPE: number;
  60333. /**
  60334. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60335. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60336. */
  60337. static readonly VELOCITY_TEXTURE_TYPE: number;
  60338. /**
  60339. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60340. * in order to compute objects velocities when enableVelocity is set to "true"
  60341. * @hidden
  60342. */
  60343. _previousTransformationMatrices: {
  60344. [index: number]: ISavedTransformationMatrix;
  60345. };
  60346. /**
  60347. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60348. * in order to compute objects velocities when enableVelocity is set to "true"
  60349. * @hidden
  60350. */
  60351. _previousBonesTransformationMatrices: {
  60352. [index: number]: Float32Array;
  60353. };
  60354. /**
  60355. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60356. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60357. */
  60358. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60359. private _scene;
  60360. private _multiRenderTarget;
  60361. private _ratio;
  60362. private _enablePosition;
  60363. private _enableVelocity;
  60364. private _positionIndex;
  60365. private _velocityIndex;
  60366. protected _effect: Effect;
  60367. protected _cachedDefines: string;
  60368. /**
  60369. * Set the render list (meshes to be rendered) used in the G buffer.
  60370. */
  60371. renderList: Mesh[];
  60372. /**
  60373. * Gets wether or not G buffer are supported by the running hardware.
  60374. * This requires draw buffer supports
  60375. */
  60376. readonly isSupported: boolean;
  60377. /**
  60378. * Returns the index of the given texture type in the G-Buffer textures array
  60379. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60380. * @returns the index of the given texture type in the G-Buffer textures array
  60381. */
  60382. getTextureIndex(textureType: number): number;
  60383. /**
  60384. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60385. */
  60386. /**
  60387. * Sets whether or not objects positions are enabled for the G buffer.
  60388. */
  60389. enablePosition: boolean;
  60390. /**
  60391. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60392. */
  60393. /**
  60394. * Sets wether or not objects velocities are enabled for the G buffer.
  60395. */
  60396. enableVelocity: boolean;
  60397. /**
  60398. * Gets the scene associated with the buffer.
  60399. */
  60400. readonly scene: Scene;
  60401. /**
  60402. * Gets the ratio used by the buffer during its creation.
  60403. * How big is the buffer related to the main canvas.
  60404. */
  60405. readonly ratio: number;
  60406. /** @hidden */
  60407. static _SceneComponentInitialization: (scene: Scene) => void;
  60408. /**
  60409. * Creates a new G Buffer for the scene
  60410. * @param scene The scene the buffer belongs to
  60411. * @param ratio How big is the buffer related to the main canvas.
  60412. */
  60413. constructor(scene: Scene, ratio?: number);
  60414. /**
  60415. * Checks wether everything is ready to render a submesh to the G buffer.
  60416. * @param subMesh the submesh to check readiness for
  60417. * @param useInstances is the mesh drawn using instance or not
  60418. * @returns true if ready otherwise false
  60419. */
  60420. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60421. /**
  60422. * Gets the current underlying G Buffer.
  60423. * @returns the buffer
  60424. */
  60425. getGBuffer(): MultiRenderTarget;
  60426. /**
  60427. * Gets the number of samples used to render the buffer (anti aliasing).
  60428. */
  60429. /**
  60430. * Sets the number of samples used to render the buffer (anti aliasing).
  60431. */
  60432. samples: number;
  60433. /**
  60434. * Disposes the renderer and frees up associated resources.
  60435. */
  60436. dispose(): void;
  60437. protected _createRenderTargets(): void;
  60438. private _copyBonesTransformationMatrices;
  60439. }
  60440. }
  60441. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  60442. import { Nullable } from "babylonjs/types";
  60443. import { Scene } from "babylonjs/scene";
  60444. import { ISceneComponent } from "babylonjs/sceneComponent";
  60445. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  60446. module "babylonjs/scene" {
  60447. interface Scene {
  60448. /** @hidden (Backing field) */
  60449. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60450. /**
  60451. * Gets or Sets the current geometry buffer associated to the scene.
  60452. */
  60453. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60454. /**
  60455. * Enables a GeometryBufferRender and associates it with the scene
  60456. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60457. * @returns the GeometryBufferRenderer
  60458. */
  60459. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60460. /**
  60461. * Disables the GeometryBufferRender associated with the scene
  60462. */
  60463. disableGeometryBufferRenderer(): void;
  60464. }
  60465. }
  60466. /**
  60467. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60468. * in several rendering techniques.
  60469. */
  60470. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60471. /**
  60472. * The component name helpful to identify the component in the list of scene components.
  60473. */
  60474. readonly name: string;
  60475. /**
  60476. * The scene the component belongs to.
  60477. */
  60478. scene: Scene;
  60479. /**
  60480. * Creates a new instance of the component for the given scene
  60481. * @param scene Defines the scene to register the component in
  60482. */
  60483. constructor(scene: Scene);
  60484. /**
  60485. * Registers the component in a given scene
  60486. */
  60487. register(): void;
  60488. /**
  60489. * Rebuilds the elements related to this component in case of
  60490. * context lost for instance.
  60491. */
  60492. rebuild(): void;
  60493. /**
  60494. * Disposes the component and the associated ressources
  60495. */
  60496. dispose(): void;
  60497. private _gatherRenderTargets;
  60498. }
  60499. }
  60500. declare module "babylonjs/Shaders/motionBlur.fragment" {
  60501. /** @hidden */
  60502. export var motionBlurPixelShader: {
  60503. name: string;
  60504. shader: string;
  60505. };
  60506. }
  60507. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  60508. import { Nullable } from "babylonjs/types";
  60509. import { Camera } from "babylonjs/Cameras/camera";
  60510. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60511. import { Scene } from "babylonjs/scene";
  60512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60513. import "babylonjs/Animations/animatable";
  60514. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60515. import "babylonjs/Shaders/motionBlur.fragment";
  60516. import { Engine } from "babylonjs/Engines/engine";
  60517. /**
  60518. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60519. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60520. * As an example, all you have to do is to create the post-process:
  60521. * var mb = new BABYLON.MotionBlurPostProcess(
  60522. * 'mb', // The name of the effect.
  60523. * scene, // The scene containing the objects to blur according to their velocity.
  60524. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60525. * camera // The camera to apply the render pass to.
  60526. * );
  60527. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60528. */
  60529. export class MotionBlurPostProcess extends PostProcess {
  60530. /**
  60531. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60532. */
  60533. motionStrength: number;
  60534. /**
  60535. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60536. */
  60537. /**
  60538. * Sets the number of iterations to be used for motion blur quality
  60539. */
  60540. motionBlurSamples: number;
  60541. private _motionBlurSamples;
  60542. private _geometryBufferRenderer;
  60543. /**
  60544. * Creates a new instance MotionBlurPostProcess
  60545. * @param name The name of the effect.
  60546. * @param scene The scene containing the objects to blur according to their velocity.
  60547. * @param options The required width/height ratio to downsize to before computing the render pass.
  60548. * @param camera The camera to apply the render pass to.
  60549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60550. * @param engine The engine which the post process will be applied. (default: current engine)
  60551. * @param reusable If the post process can be reused on the same frame. (default: false)
  60552. * @param textureType Type of textures used when performing the post process. (default: 0)
  60553. * @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)
  60554. */
  60555. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60556. /**
  60557. * Excludes the given skinned mesh from computing bones velocities.
  60558. * 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.
  60559. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60560. */
  60561. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60562. /**
  60563. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60564. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60565. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60566. */
  60567. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60568. /**
  60569. * Disposes the post process.
  60570. * @param camera The camera to dispose the post process on.
  60571. */
  60572. dispose(camera?: Camera): void;
  60573. }
  60574. }
  60575. declare module "babylonjs/Shaders/refraction.fragment" {
  60576. /** @hidden */
  60577. export var refractionPixelShader: {
  60578. name: string;
  60579. shader: string;
  60580. };
  60581. }
  60582. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  60583. import { Color3 } from "babylonjs/Maths/math.color";
  60584. import { Camera } from "babylonjs/Cameras/camera";
  60585. import { Texture } from "babylonjs/Materials/Textures/texture";
  60586. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60587. import { Engine } from "babylonjs/Engines/engine";
  60588. import "babylonjs/Shaders/refraction.fragment";
  60589. /**
  60590. * Post process which applies a refractin texture
  60591. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60592. */
  60593. export class RefractionPostProcess extends PostProcess {
  60594. /** the base color of the refraction (used to taint the rendering) */
  60595. color: Color3;
  60596. /** simulated refraction depth */
  60597. depth: number;
  60598. /** the coefficient of the base color (0 to remove base color tainting) */
  60599. colorLevel: number;
  60600. private _refTexture;
  60601. private _ownRefractionTexture;
  60602. /**
  60603. * Gets or sets the refraction texture
  60604. * Please note that you are responsible for disposing the texture if you set it manually
  60605. */
  60606. refractionTexture: Texture;
  60607. /**
  60608. * Initializes the RefractionPostProcess
  60609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60610. * @param name The name of the effect.
  60611. * @param refractionTextureUrl Url of the refraction texture to use
  60612. * @param color the base color of the refraction (used to taint the rendering)
  60613. * @param depth simulated refraction depth
  60614. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60615. * @param camera The camera to apply the render pass to.
  60616. * @param options The required width/height ratio to downsize to before computing the render pass.
  60617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60618. * @param engine The engine which the post process will be applied. (default: current engine)
  60619. * @param reusable If the post process can be reused on the same frame. (default: false)
  60620. */
  60621. constructor(name: string, refractionTextureUrl: string,
  60622. /** the base color of the refraction (used to taint the rendering) */
  60623. color: Color3,
  60624. /** simulated refraction depth */
  60625. depth: number,
  60626. /** the coefficient of the base color (0 to remove base color tainting) */
  60627. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60628. /**
  60629. * Disposes of the post process
  60630. * @param camera Camera to dispose post process on
  60631. */
  60632. dispose(camera: Camera): void;
  60633. }
  60634. }
  60635. declare module "babylonjs/Shaders/sharpen.fragment" {
  60636. /** @hidden */
  60637. export var sharpenPixelShader: {
  60638. name: string;
  60639. shader: string;
  60640. };
  60641. }
  60642. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60643. import { Nullable } from "babylonjs/types";
  60644. import { Camera } from "babylonjs/Cameras/camera";
  60645. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60646. import "babylonjs/Shaders/sharpen.fragment";
  60647. import { Engine } from "babylonjs/Engines/engine";
  60648. /**
  60649. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60650. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60651. */
  60652. export class SharpenPostProcess extends PostProcess {
  60653. /**
  60654. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60655. */
  60656. colorAmount: number;
  60657. /**
  60658. * How much sharpness should be applied (default: 0.3)
  60659. */
  60660. edgeAmount: number;
  60661. /**
  60662. * Creates a new instance ConvolutionPostProcess
  60663. * @param name The name of the effect.
  60664. * @param options The required width/height ratio to downsize to before computing the render pass.
  60665. * @param camera The camera to apply the render pass to.
  60666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60667. * @param engine The engine which the post process will be applied. (default: current engine)
  60668. * @param reusable If the post process can be reused on the same frame. (default: false)
  60669. * @param textureType Type of textures used when performing the post process. (default: 0)
  60670. * @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)
  60671. */
  60672. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60673. }
  60674. }
  60675. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60676. import { Nullable } from "babylonjs/types";
  60677. import { Camera } from "babylonjs/Cameras/camera";
  60678. import { Engine } from "babylonjs/Engines/engine";
  60679. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60680. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60681. /**
  60682. * PostProcessRenderPipeline
  60683. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60684. */
  60685. export class PostProcessRenderPipeline {
  60686. private engine;
  60687. private _renderEffects;
  60688. private _renderEffectsForIsolatedPass;
  60689. /**
  60690. * List of inspectable custom properties (used by the Inspector)
  60691. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60692. */
  60693. inspectableCustomProperties: IInspectable[];
  60694. /**
  60695. * @hidden
  60696. */
  60697. protected _cameras: Camera[];
  60698. /** @hidden */
  60699. _name: string;
  60700. /**
  60701. * Gets pipeline name
  60702. */
  60703. readonly name: string;
  60704. /**
  60705. * Initializes a PostProcessRenderPipeline
  60706. * @param engine engine to add the pipeline to
  60707. * @param name name of the pipeline
  60708. */
  60709. constructor(engine: Engine, name: string);
  60710. /**
  60711. * Gets the class name
  60712. * @returns "PostProcessRenderPipeline"
  60713. */
  60714. getClassName(): string;
  60715. /**
  60716. * If all the render effects in the pipeline are supported
  60717. */
  60718. readonly isSupported: boolean;
  60719. /**
  60720. * Adds an effect to the pipeline
  60721. * @param renderEffect the effect to add
  60722. */
  60723. addEffect(renderEffect: PostProcessRenderEffect): void;
  60724. /** @hidden */
  60725. _rebuild(): void;
  60726. /** @hidden */
  60727. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60728. /** @hidden */
  60729. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60730. /** @hidden */
  60731. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60732. /** @hidden */
  60733. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60734. /** @hidden */
  60735. _attachCameras(cameras: Camera, unique: boolean): void;
  60736. /** @hidden */
  60737. _attachCameras(cameras: Camera[], unique: boolean): void;
  60738. /** @hidden */
  60739. _detachCameras(cameras: Camera): void;
  60740. /** @hidden */
  60741. _detachCameras(cameras: Nullable<Camera[]>): void;
  60742. /** @hidden */
  60743. _update(): void;
  60744. /** @hidden */
  60745. _reset(): void;
  60746. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60747. /**
  60748. * Disposes of the pipeline
  60749. */
  60750. dispose(): void;
  60751. }
  60752. }
  60753. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60754. import { Camera } from "babylonjs/Cameras/camera";
  60755. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60756. /**
  60757. * PostProcessRenderPipelineManager class
  60758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60759. */
  60760. export class PostProcessRenderPipelineManager {
  60761. private _renderPipelines;
  60762. /**
  60763. * Initializes a PostProcessRenderPipelineManager
  60764. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60765. */
  60766. constructor();
  60767. /**
  60768. * Gets the list of supported render pipelines
  60769. */
  60770. readonly supportedPipelines: PostProcessRenderPipeline[];
  60771. /**
  60772. * Adds a pipeline to the manager
  60773. * @param renderPipeline The pipeline to add
  60774. */
  60775. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60776. /**
  60777. * Attaches a camera to the pipeline
  60778. * @param renderPipelineName The name of the pipeline to attach to
  60779. * @param cameras the camera to attach
  60780. * @param unique if the camera can be attached multiple times to the pipeline
  60781. */
  60782. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60783. /**
  60784. * Detaches a camera from the pipeline
  60785. * @param renderPipelineName The name of the pipeline to detach from
  60786. * @param cameras the camera to detach
  60787. */
  60788. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60789. /**
  60790. * Enables an effect by name on a pipeline
  60791. * @param renderPipelineName the name of the pipeline to enable the effect in
  60792. * @param renderEffectName the name of the effect to enable
  60793. * @param cameras the cameras that the effect should be enabled on
  60794. */
  60795. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60796. /**
  60797. * Disables an effect by name on a pipeline
  60798. * @param renderPipelineName the name of the pipeline to disable the effect in
  60799. * @param renderEffectName the name of the effect to disable
  60800. * @param cameras the cameras that the effect should be disabled on
  60801. */
  60802. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60803. /**
  60804. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60805. */
  60806. update(): void;
  60807. /** @hidden */
  60808. _rebuild(): void;
  60809. /**
  60810. * Disposes of the manager and pipelines
  60811. */
  60812. dispose(): void;
  60813. }
  60814. }
  60815. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60816. import { ISceneComponent } from "babylonjs/sceneComponent";
  60817. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60818. import { Scene } from "babylonjs/scene";
  60819. module "babylonjs/scene" {
  60820. interface Scene {
  60821. /** @hidden (Backing field) */
  60822. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60823. /**
  60824. * Gets the postprocess render pipeline manager
  60825. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60826. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60827. */
  60828. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60829. }
  60830. }
  60831. /**
  60832. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60833. */
  60834. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60835. /**
  60836. * The component name helpfull to identify the component in the list of scene components.
  60837. */
  60838. readonly name: string;
  60839. /**
  60840. * The scene the component belongs to.
  60841. */
  60842. scene: Scene;
  60843. /**
  60844. * Creates a new instance of the component for the given scene
  60845. * @param scene Defines the scene to register the component in
  60846. */
  60847. constructor(scene: Scene);
  60848. /**
  60849. * Registers the component in a given scene
  60850. */
  60851. register(): void;
  60852. /**
  60853. * Rebuilds the elements related to this component in case of
  60854. * context lost for instance.
  60855. */
  60856. rebuild(): void;
  60857. /**
  60858. * Disposes the component and the associated ressources
  60859. */
  60860. dispose(): void;
  60861. private _gatherRenderTargets;
  60862. }
  60863. }
  60864. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60865. import { Nullable } from "babylonjs/types";
  60866. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60867. import { Camera } from "babylonjs/Cameras/camera";
  60868. import { IDisposable } from "babylonjs/scene";
  60869. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60870. import { Scene } from "babylonjs/scene";
  60871. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60872. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60873. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60874. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  60875. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60876. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60877. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  60878. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60879. import { Animation } from "babylonjs/Animations/animation";
  60880. /**
  60881. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60882. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60883. */
  60884. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60885. private _scene;
  60886. private _camerasToBeAttached;
  60887. /**
  60888. * ID of the sharpen post process,
  60889. */
  60890. private readonly SharpenPostProcessId;
  60891. /**
  60892. * @ignore
  60893. * ID of the image processing post process;
  60894. */
  60895. readonly ImageProcessingPostProcessId: string;
  60896. /**
  60897. * @ignore
  60898. * ID of the Fast Approximate Anti-Aliasing post process;
  60899. */
  60900. readonly FxaaPostProcessId: string;
  60901. /**
  60902. * ID of the chromatic aberration post process,
  60903. */
  60904. private readonly ChromaticAberrationPostProcessId;
  60905. /**
  60906. * ID of the grain post process
  60907. */
  60908. private readonly GrainPostProcessId;
  60909. /**
  60910. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60911. */
  60912. sharpen: SharpenPostProcess;
  60913. private _sharpenEffect;
  60914. private bloom;
  60915. /**
  60916. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60917. */
  60918. depthOfField: DepthOfFieldEffect;
  60919. /**
  60920. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60921. */
  60922. fxaa: FxaaPostProcess;
  60923. /**
  60924. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60925. */
  60926. imageProcessing: ImageProcessingPostProcess;
  60927. /**
  60928. * Chromatic aberration post process which will shift rgb colors in the image
  60929. */
  60930. chromaticAberration: ChromaticAberrationPostProcess;
  60931. private _chromaticAberrationEffect;
  60932. /**
  60933. * Grain post process which add noise to the image
  60934. */
  60935. grain: GrainPostProcess;
  60936. private _grainEffect;
  60937. /**
  60938. * Glow post process which adds a glow to emissive areas of the image
  60939. */
  60940. private _glowLayer;
  60941. /**
  60942. * Animations which can be used to tweak settings over a period of time
  60943. */
  60944. animations: Animation[];
  60945. private _imageProcessingConfigurationObserver;
  60946. private _sharpenEnabled;
  60947. private _bloomEnabled;
  60948. private _depthOfFieldEnabled;
  60949. private _depthOfFieldBlurLevel;
  60950. private _fxaaEnabled;
  60951. private _imageProcessingEnabled;
  60952. private _defaultPipelineTextureType;
  60953. private _bloomScale;
  60954. private _chromaticAberrationEnabled;
  60955. private _grainEnabled;
  60956. private _buildAllowed;
  60957. /**
  60958. * Gets active scene
  60959. */
  60960. readonly scene: Scene;
  60961. /**
  60962. * Enable or disable the sharpen process from the pipeline
  60963. */
  60964. sharpenEnabled: boolean;
  60965. private _resizeObserver;
  60966. private _hardwareScaleLevel;
  60967. private _bloomKernel;
  60968. /**
  60969. * Specifies the size of the bloom blur kernel, relative to the final output size
  60970. */
  60971. bloomKernel: number;
  60972. /**
  60973. * Specifies the weight of the bloom in the final rendering
  60974. */
  60975. private _bloomWeight;
  60976. /**
  60977. * Specifies the luma threshold for the area that will be blurred by the bloom
  60978. */
  60979. private _bloomThreshold;
  60980. private _hdr;
  60981. /**
  60982. * The strength of the bloom.
  60983. */
  60984. bloomWeight: number;
  60985. /**
  60986. * The strength of the bloom.
  60987. */
  60988. bloomThreshold: number;
  60989. /**
  60990. * The scale of the bloom, lower value will provide better performance.
  60991. */
  60992. bloomScale: number;
  60993. /**
  60994. * Enable or disable the bloom from the pipeline
  60995. */
  60996. bloomEnabled: boolean;
  60997. private _rebuildBloom;
  60998. /**
  60999. * If the depth of field is enabled.
  61000. */
  61001. depthOfFieldEnabled: boolean;
  61002. /**
  61003. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61004. */
  61005. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61006. /**
  61007. * If the anti aliasing is enabled.
  61008. */
  61009. fxaaEnabled: boolean;
  61010. private _samples;
  61011. /**
  61012. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61013. */
  61014. samples: number;
  61015. /**
  61016. * If image processing is enabled.
  61017. */
  61018. imageProcessingEnabled: boolean;
  61019. /**
  61020. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61021. */
  61022. glowLayerEnabled: boolean;
  61023. /**
  61024. * Gets the glow layer (or null if not defined)
  61025. */
  61026. readonly glowLayer: Nullable<GlowLayer>;
  61027. /**
  61028. * Enable or disable the chromaticAberration process from the pipeline
  61029. */
  61030. chromaticAberrationEnabled: boolean;
  61031. /**
  61032. * Enable or disable the grain process from the pipeline
  61033. */
  61034. grainEnabled: boolean;
  61035. /**
  61036. * @constructor
  61037. * @param name - The rendering pipeline name (default: "")
  61038. * @param hdr - If high dynamic range textures should be used (default: true)
  61039. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61040. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61041. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61042. */
  61043. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61044. /**
  61045. * Get the class name
  61046. * @returns "DefaultRenderingPipeline"
  61047. */
  61048. getClassName(): string;
  61049. /**
  61050. * Force the compilation of the entire pipeline.
  61051. */
  61052. prepare(): void;
  61053. private _hasCleared;
  61054. private _prevPostProcess;
  61055. private _prevPrevPostProcess;
  61056. private _setAutoClearAndTextureSharing;
  61057. private _depthOfFieldSceneObserver;
  61058. private _buildPipeline;
  61059. private _disposePostProcesses;
  61060. /**
  61061. * Adds a camera to the pipeline
  61062. * @param camera the camera to be added
  61063. */
  61064. addCamera(camera: Camera): void;
  61065. /**
  61066. * Removes a camera from the pipeline
  61067. * @param camera the camera to remove
  61068. */
  61069. removeCamera(camera: Camera): void;
  61070. /**
  61071. * Dispose of the pipeline and stop all post processes
  61072. */
  61073. dispose(): void;
  61074. /**
  61075. * Serialize the rendering pipeline (Used when exporting)
  61076. * @returns the serialized object
  61077. */
  61078. serialize(): any;
  61079. /**
  61080. * Parse the serialized pipeline
  61081. * @param source Source pipeline.
  61082. * @param scene The scene to load the pipeline to.
  61083. * @param rootUrl The URL of the serialized pipeline.
  61084. * @returns An instantiated pipeline from the serialized object.
  61085. */
  61086. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61087. }
  61088. }
  61089. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  61090. /** @hidden */
  61091. export var lensHighlightsPixelShader: {
  61092. name: string;
  61093. shader: string;
  61094. };
  61095. }
  61096. declare module "babylonjs/Shaders/depthOfField.fragment" {
  61097. /** @hidden */
  61098. export var depthOfFieldPixelShader: {
  61099. name: string;
  61100. shader: string;
  61101. };
  61102. }
  61103. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  61104. import { Camera } from "babylonjs/Cameras/camera";
  61105. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61106. import { Scene } from "babylonjs/scene";
  61107. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61108. import "babylonjs/Shaders/chromaticAberration.fragment";
  61109. import "babylonjs/Shaders/lensHighlights.fragment";
  61110. import "babylonjs/Shaders/depthOfField.fragment";
  61111. /**
  61112. * BABYLON.JS Chromatic Aberration GLSL Shader
  61113. * Author: Olivier Guyot
  61114. * Separates very slightly R, G and B colors on the edges of the screen
  61115. * Inspired by Francois Tarlier & Martins Upitis
  61116. */
  61117. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61118. /**
  61119. * @ignore
  61120. * The chromatic aberration PostProcess id in the pipeline
  61121. */
  61122. LensChromaticAberrationEffect: string;
  61123. /**
  61124. * @ignore
  61125. * The highlights enhancing PostProcess id in the pipeline
  61126. */
  61127. HighlightsEnhancingEffect: string;
  61128. /**
  61129. * @ignore
  61130. * The depth-of-field PostProcess id in the pipeline
  61131. */
  61132. LensDepthOfFieldEffect: string;
  61133. private _scene;
  61134. private _depthTexture;
  61135. private _grainTexture;
  61136. private _chromaticAberrationPostProcess;
  61137. private _highlightsPostProcess;
  61138. private _depthOfFieldPostProcess;
  61139. private _edgeBlur;
  61140. private _grainAmount;
  61141. private _chromaticAberration;
  61142. private _distortion;
  61143. private _highlightsGain;
  61144. private _highlightsThreshold;
  61145. private _dofDistance;
  61146. private _dofAperture;
  61147. private _dofDarken;
  61148. private _dofPentagon;
  61149. private _blurNoise;
  61150. /**
  61151. * @constructor
  61152. *
  61153. * Effect parameters are as follow:
  61154. * {
  61155. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61156. * edge_blur: number; // from 0 to x (1 for realism)
  61157. * distortion: number; // from 0 to x (1 for realism)
  61158. * grain_amount: number; // from 0 to 1
  61159. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61160. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61161. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61162. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61163. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61164. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61165. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61166. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61167. * }
  61168. * Note: if an effect parameter is unset, effect is disabled
  61169. *
  61170. * @param name The rendering pipeline name
  61171. * @param parameters - An object containing all parameters (see above)
  61172. * @param scene The scene linked to this pipeline
  61173. * @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)
  61174. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61175. */
  61176. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61177. /**
  61178. * Get the class name
  61179. * @returns "LensRenderingPipeline"
  61180. */
  61181. getClassName(): string;
  61182. /**
  61183. * Gets associated scene
  61184. */
  61185. readonly scene: Scene;
  61186. /**
  61187. * Gets or sets the edge blur
  61188. */
  61189. edgeBlur: number;
  61190. /**
  61191. * Gets or sets the grain amount
  61192. */
  61193. grainAmount: number;
  61194. /**
  61195. * Gets or sets the chromatic aberration amount
  61196. */
  61197. chromaticAberration: number;
  61198. /**
  61199. * Gets or sets the depth of field aperture
  61200. */
  61201. dofAperture: number;
  61202. /**
  61203. * Gets or sets the edge distortion
  61204. */
  61205. edgeDistortion: number;
  61206. /**
  61207. * Gets or sets the depth of field distortion
  61208. */
  61209. dofDistortion: number;
  61210. /**
  61211. * Gets or sets the darken out of focus amount
  61212. */
  61213. darkenOutOfFocus: number;
  61214. /**
  61215. * Gets or sets a boolean indicating if blur noise is enabled
  61216. */
  61217. blurNoise: boolean;
  61218. /**
  61219. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61220. */
  61221. pentagonBokeh: boolean;
  61222. /**
  61223. * Gets or sets the highlight grain amount
  61224. */
  61225. highlightsGain: number;
  61226. /**
  61227. * Gets or sets the highlight threshold
  61228. */
  61229. highlightsThreshold: number;
  61230. /**
  61231. * Sets the amount of blur at the edges
  61232. * @param amount blur amount
  61233. */
  61234. setEdgeBlur(amount: number): void;
  61235. /**
  61236. * Sets edge blur to 0
  61237. */
  61238. disableEdgeBlur(): void;
  61239. /**
  61240. * Sets the amout of grain
  61241. * @param amount Amount of grain
  61242. */
  61243. setGrainAmount(amount: number): void;
  61244. /**
  61245. * Set grain amount to 0
  61246. */
  61247. disableGrain(): void;
  61248. /**
  61249. * Sets the chromatic aberration amount
  61250. * @param amount amount of chromatic aberration
  61251. */
  61252. setChromaticAberration(amount: number): void;
  61253. /**
  61254. * Sets chromatic aberration amount to 0
  61255. */
  61256. disableChromaticAberration(): void;
  61257. /**
  61258. * Sets the EdgeDistortion amount
  61259. * @param amount amount of EdgeDistortion
  61260. */
  61261. setEdgeDistortion(amount: number): void;
  61262. /**
  61263. * Sets edge distortion to 0
  61264. */
  61265. disableEdgeDistortion(): void;
  61266. /**
  61267. * Sets the FocusDistance amount
  61268. * @param amount amount of FocusDistance
  61269. */
  61270. setFocusDistance(amount: number): void;
  61271. /**
  61272. * Disables depth of field
  61273. */
  61274. disableDepthOfField(): void;
  61275. /**
  61276. * Sets the Aperture amount
  61277. * @param amount amount of Aperture
  61278. */
  61279. setAperture(amount: number): void;
  61280. /**
  61281. * Sets the DarkenOutOfFocus amount
  61282. * @param amount amount of DarkenOutOfFocus
  61283. */
  61284. setDarkenOutOfFocus(amount: number): void;
  61285. private _pentagonBokehIsEnabled;
  61286. /**
  61287. * Creates a pentagon bokeh effect
  61288. */
  61289. enablePentagonBokeh(): void;
  61290. /**
  61291. * Disables the pentagon bokeh effect
  61292. */
  61293. disablePentagonBokeh(): void;
  61294. /**
  61295. * Enables noise blur
  61296. */
  61297. enableNoiseBlur(): void;
  61298. /**
  61299. * Disables noise blur
  61300. */
  61301. disableNoiseBlur(): void;
  61302. /**
  61303. * Sets the HighlightsGain amount
  61304. * @param amount amount of HighlightsGain
  61305. */
  61306. setHighlightsGain(amount: number): void;
  61307. /**
  61308. * Sets the HighlightsThreshold amount
  61309. * @param amount amount of HighlightsThreshold
  61310. */
  61311. setHighlightsThreshold(amount: number): void;
  61312. /**
  61313. * Disables highlights
  61314. */
  61315. disableHighlights(): void;
  61316. /**
  61317. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61318. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61319. */
  61320. dispose(disableDepthRender?: boolean): void;
  61321. private _createChromaticAberrationPostProcess;
  61322. private _createHighlightsPostProcess;
  61323. private _createDepthOfFieldPostProcess;
  61324. private _createGrainTexture;
  61325. }
  61326. }
  61327. declare module "babylonjs/Shaders/ssao2.fragment" {
  61328. /** @hidden */
  61329. export var ssao2PixelShader: {
  61330. name: string;
  61331. shader: string;
  61332. };
  61333. }
  61334. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  61335. /** @hidden */
  61336. export var ssaoCombinePixelShader: {
  61337. name: string;
  61338. shader: string;
  61339. };
  61340. }
  61341. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  61342. import { Camera } from "babylonjs/Cameras/camera";
  61343. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61344. import { Scene } from "babylonjs/scene";
  61345. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61346. import "babylonjs/Shaders/ssao2.fragment";
  61347. import "babylonjs/Shaders/ssaoCombine.fragment";
  61348. /**
  61349. * Render pipeline to produce ssao effect
  61350. */
  61351. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61352. /**
  61353. * @ignore
  61354. * The PassPostProcess id in the pipeline that contains the original scene color
  61355. */
  61356. SSAOOriginalSceneColorEffect: string;
  61357. /**
  61358. * @ignore
  61359. * The SSAO PostProcess id in the pipeline
  61360. */
  61361. SSAORenderEffect: string;
  61362. /**
  61363. * @ignore
  61364. * The horizontal blur PostProcess id in the pipeline
  61365. */
  61366. SSAOBlurHRenderEffect: string;
  61367. /**
  61368. * @ignore
  61369. * The vertical blur PostProcess id in the pipeline
  61370. */
  61371. SSAOBlurVRenderEffect: string;
  61372. /**
  61373. * @ignore
  61374. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61375. */
  61376. SSAOCombineRenderEffect: string;
  61377. /**
  61378. * The output strength of the SSAO post-process. Default value is 1.0.
  61379. */
  61380. totalStrength: number;
  61381. /**
  61382. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61383. */
  61384. maxZ: number;
  61385. /**
  61386. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61387. */
  61388. minZAspect: number;
  61389. private _samples;
  61390. /**
  61391. * Number of samples used for the SSAO calculations. Default value is 8
  61392. */
  61393. samples: number;
  61394. private _textureSamples;
  61395. /**
  61396. * Number of samples to use for antialiasing
  61397. */
  61398. textureSamples: number;
  61399. /**
  61400. * Ratio object used for SSAO ratio and blur ratio
  61401. */
  61402. private _ratio;
  61403. /**
  61404. * Dynamically generated sphere sampler.
  61405. */
  61406. private _sampleSphere;
  61407. /**
  61408. * Blur filter offsets
  61409. */
  61410. private _samplerOffsets;
  61411. private _expensiveBlur;
  61412. /**
  61413. * If bilateral blur should be used
  61414. */
  61415. expensiveBlur: boolean;
  61416. /**
  61417. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61418. */
  61419. radius: number;
  61420. /**
  61421. * The base color of the SSAO post-process
  61422. * The final result is "base + ssao" between [0, 1]
  61423. */
  61424. base: number;
  61425. /**
  61426. * Support test.
  61427. */
  61428. static readonly IsSupported: boolean;
  61429. private _scene;
  61430. private _depthTexture;
  61431. private _normalTexture;
  61432. private _randomTexture;
  61433. private _originalColorPostProcess;
  61434. private _ssaoPostProcess;
  61435. private _blurHPostProcess;
  61436. private _blurVPostProcess;
  61437. private _ssaoCombinePostProcess;
  61438. private _firstUpdate;
  61439. /**
  61440. * Gets active scene
  61441. */
  61442. readonly scene: Scene;
  61443. /**
  61444. * @constructor
  61445. * @param name The rendering pipeline name
  61446. * @param scene The scene linked to this pipeline
  61447. * @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 }
  61448. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61449. */
  61450. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61451. /**
  61452. * Get the class name
  61453. * @returns "SSAO2RenderingPipeline"
  61454. */
  61455. getClassName(): string;
  61456. /**
  61457. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61458. */
  61459. dispose(disableGeometryBufferRenderer?: boolean): void;
  61460. private _createBlurPostProcess;
  61461. /** @hidden */
  61462. _rebuild(): void;
  61463. private _bits;
  61464. private _radicalInverse_VdC;
  61465. private _hammersley;
  61466. private _hemisphereSample_uniform;
  61467. private _generateHemisphere;
  61468. private _createSSAOPostProcess;
  61469. private _createSSAOCombinePostProcess;
  61470. private _createRandomTexture;
  61471. /**
  61472. * Serialize the rendering pipeline (Used when exporting)
  61473. * @returns the serialized object
  61474. */
  61475. serialize(): any;
  61476. /**
  61477. * Parse the serialized pipeline
  61478. * @param source Source pipeline.
  61479. * @param scene The scene to load the pipeline to.
  61480. * @param rootUrl The URL of the serialized pipeline.
  61481. * @returns An instantiated pipeline from the serialized object.
  61482. */
  61483. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61484. }
  61485. }
  61486. declare module "babylonjs/Shaders/ssao.fragment" {
  61487. /** @hidden */
  61488. export var ssaoPixelShader: {
  61489. name: string;
  61490. shader: string;
  61491. };
  61492. }
  61493. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61494. import { Camera } from "babylonjs/Cameras/camera";
  61495. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61496. import { Scene } from "babylonjs/scene";
  61497. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61498. import "babylonjs/Shaders/ssao.fragment";
  61499. import "babylonjs/Shaders/ssaoCombine.fragment";
  61500. /**
  61501. * Render pipeline to produce ssao effect
  61502. */
  61503. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61504. /**
  61505. * @ignore
  61506. * The PassPostProcess id in the pipeline that contains the original scene color
  61507. */
  61508. SSAOOriginalSceneColorEffect: string;
  61509. /**
  61510. * @ignore
  61511. * The SSAO PostProcess id in the pipeline
  61512. */
  61513. SSAORenderEffect: string;
  61514. /**
  61515. * @ignore
  61516. * The horizontal blur PostProcess id in the pipeline
  61517. */
  61518. SSAOBlurHRenderEffect: string;
  61519. /**
  61520. * @ignore
  61521. * The vertical blur PostProcess id in the pipeline
  61522. */
  61523. SSAOBlurVRenderEffect: string;
  61524. /**
  61525. * @ignore
  61526. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61527. */
  61528. SSAOCombineRenderEffect: string;
  61529. /**
  61530. * The output strength of the SSAO post-process. Default value is 1.0.
  61531. */
  61532. totalStrength: number;
  61533. /**
  61534. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61535. */
  61536. radius: number;
  61537. /**
  61538. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61539. * Must not be equal to fallOff and superior to fallOff.
  61540. * Default value is 0.0075
  61541. */
  61542. area: number;
  61543. /**
  61544. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61545. * Must not be equal to area and inferior to area.
  61546. * Default value is 0.000001
  61547. */
  61548. fallOff: number;
  61549. /**
  61550. * The base color of the SSAO post-process
  61551. * The final result is "base + ssao" between [0, 1]
  61552. */
  61553. base: number;
  61554. private _scene;
  61555. private _depthTexture;
  61556. private _randomTexture;
  61557. private _originalColorPostProcess;
  61558. private _ssaoPostProcess;
  61559. private _blurHPostProcess;
  61560. private _blurVPostProcess;
  61561. private _ssaoCombinePostProcess;
  61562. private _firstUpdate;
  61563. /**
  61564. * Gets active scene
  61565. */
  61566. readonly scene: Scene;
  61567. /**
  61568. * @constructor
  61569. * @param name - The rendering pipeline name
  61570. * @param scene - The scene linked to this pipeline
  61571. * @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 }
  61572. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61573. */
  61574. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61575. /**
  61576. * Get the class name
  61577. * @returns "SSAORenderingPipeline"
  61578. */
  61579. getClassName(): string;
  61580. /**
  61581. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61582. */
  61583. dispose(disableDepthRender?: boolean): void;
  61584. private _createBlurPostProcess;
  61585. /** @hidden */
  61586. _rebuild(): void;
  61587. private _createSSAOPostProcess;
  61588. private _createSSAOCombinePostProcess;
  61589. private _createRandomTexture;
  61590. }
  61591. }
  61592. declare module "babylonjs/Shaders/standard.fragment" {
  61593. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61594. /** @hidden */
  61595. export var standardPixelShader: {
  61596. name: string;
  61597. shader: string;
  61598. };
  61599. }
  61600. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  61601. import { Nullable } from "babylonjs/types";
  61602. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61603. import { Camera } from "babylonjs/Cameras/camera";
  61604. import { Texture } from "babylonjs/Materials/Textures/texture";
  61605. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61606. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61607. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61608. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61609. import { IDisposable } from "babylonjs/scene";
  61610. import { SpotLight } from "babylonjs/Lights/spotLight";
  61611. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61612. import { Scene } from "babylonjs/scene";
  61613. import { Animation } from "babylonjs/Animations/animation";
  61614. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61615. import "babylonjs/Shaders/standard.fragment";
  61616. /**
  61617. * Standard rendering pipeline
  61618. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61619. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61620. */
  61621. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61622. /**
  61623. * Public members
  61624. */
  61625. /**
  61626. * Post-process which contains the original scene color before the pipeline applies all the effects
  61627. */
  61628. originalPostProcess: Nullable<PostProcess>;
  61629. /**
  61630. * Post-process used to down scale an image x4
  61631. */
  61632. downSampleX4PostProcess: Nullable<PostProcess>;
  61633. /**
  61634. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61635. */
  61636. brightPassPostProcess: Nullable<PostProcess>;
  61637. /**
  61638. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61639. */
  61640. blurHPostProcesses: PostProcess[];
  61641. /**
  61642. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61643. */
  61644. blurVPostProcesses: PostProcess[];
  61645. /**
  61646. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61647. */
  61648. textureAdderPostProcess: Nullable<PostProcess>;
  61649. /**
  61650. * Post-process used to create volumetric lighting effect
  61651. */
  61652. volumetricLightPostProcess: Nullable<PostProcess>;
  61653. /**
  61654. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61655. */
  61656. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61657. /**
  61658. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61659. */
  61660. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61661. /**
  61662. * Post-process used to merge the volumetric light effect and the real scene color
  61663. */
  61664. volumetricLightMergePostProces: Nullable<PostProcess>;
  61665. /**
  61666. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61667. */
  61668. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61669. /**
  61670. * Base post-process used to calculate the average luminance of the final image for HDR
  61671. */
  61672. luminancePostProcess: Nullable<PostProcess>;
  61673. /**
  61674. * Post-processes used to create down sample post-processes in order to get
  61675. * the average luminance of the final image for HDR
  61676. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61677. */
  61678. luminanceDownSamplePostProcesses: PostProcess[];
  61679. /**
  61680. * Post-process used to create a HDR effect (light adaptation)
  61681. */
  61682. hdrPostProcess: Nullable<PostProcess>;
  61683. /**
  61684. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61685. */
  61686. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61687. /**
  61688. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61689. */
  61690. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61691. /**
  61692. * Post-process used to merge the final HDR post-process and the real scene color
  61693. */
  61694. hdrFinalPostProcess: Nullable<PostProcess>;
  61695. /**
  61696. * Post-process used to create a lens flare effect
  61697. */
  61698. lensFlarePostProcess: Nullable<PostProcess>;
  61699. /**
  61700. * Post-process that merges the result of the lens flare post-process and the real scene color
  61701. */
  61702. lensFlareComposePostProcess: Nullable<PostProcess>;
  61703. /**
  61704. * Post-process used to create a motion blur effect
  61705. */
  61706. motionBlurPostProcess: Nullable<PostProcess>;
  61707. /**
  61708. * Post-process used to create a depth of field effect
  61709. */
  61710. depthOfFieldPostProcess: Nullable<PostProcess>;
  61711. /**
  61712. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61713. */
  61714. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61715. /**
  61716. * Represents the brightness threshold in order to configure the illuminated surfaces
  61717. */
  61718. brightThreshold: number;
  61719. /**
  61720. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61721. */
  61722. blurWidth: number;
  61723. /**
  61724. * Sets if the blur for highlighted surfaces must be only horizontal
  61725. */
  61726. horizontalBlur: boolean;
  61727. /**
  61728. * Gets the overall exposure used by the pipeline
  61729. */
  61730. /**
  61731. * Sets the overall exposure used by the pipeline
  61732. */
  61733. exposure: number;
  61734. /**
  61735. * Texture used typically to simulate "dirty" on camera lens
  61736. */
  61737. lensTexture: Nullable<Texture>;
  61738. /**
  61739. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61740. */
  61741. volumetricLightCoefficient: number;
  61742. /**
  61743. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61744. */
  61745. volumetricLightPower: number;
  61746. /**
  61747. * Used the set the blur intensity to smooth the volumetric lights
  61748. */
  61749. volumetricLightBlurScale: number;
  61750. /**
  61751. * Light (spot or directional) used to generate the volumetric lights rays
  61752. * The source light must have a shadow generate so the pipeline can get its
  61753. * depth map
  61754. */
  61755. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61756. /**
  61757. * For eye adaptation, represents the minimum luminance the eye can see
  61758. */
  61759. hdrMinimumLuminance: number;
  61760. /**
  61761. * For eye adaptation, represents the decrease luminance speed
  61762. */
  61763. hdrDecreaseRate: number;
  61764. /**
  61765. * For eye adaptation, represents the increase luminance speed
  61766. */
  61767. hdrIncreaseRate: number;
  61768. /**
  61769. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61770. */
  61771. /**
  61772. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61773. */
  61774. hdrAutoExposure: boolean;
  61775. /**
  61776. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61777. */
  61778. lensColorTexture: Nullable<Texture>;
  61779. /**
  61780. * The overall strengh for the lens flare effect
  61781. */
  61782. lensFlareStrength: number;
  61783. /**
  61784. * Dispersion coefficient for lens flare ghosts
  61785. */
  61786. lensFlareGhostDispersal: number;
  61787. /**
  61788. * Main lens flare halo width
  61789. */
  61790. lensFlareHaloWidth: number;
  61791. /**
  61792. * Based on the lens distortion effect, defines how much the lens flare result
  61793. * is distorted
  61794. */
  61795. lensFlareDistortionStrength: number;
  61796. /**
  61797. * Lens star texture must be used to simulate rays on the flares and is available
  61798. * in the documentation
  61799. */
  61800. lensStarTexture: Nullable<Texture>;
  61801. /**
  61802. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61803. * flare effect by taking account of the dirt texture
  61804. */
  61805. lensFlareDirtTexture: Nullable<Texture>;
  61806. /**
  61807. * Represents the focal length for the depth of field effect
  61808. */
  61809. depthOfFieldDistance: number;
  61810. /**
  61811. * Represents the blur intensity for the blurred part of the depth of field effect
  61812. */
  61813. depthOfFieldBlurWidth: number;
  61814. /**
  61815. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61816. */
  61817. /**
  61818. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61819. */
  61820. motionStrength: number;
  61821. /**
  61822. * Gets wether or not the motion blur post-process is object based or screen based.
  61823. */
  61824. /**
  61825. * Sets wether or not the motion blur post-process should be object based or screen based
  61826. */
  61827. objectBasedMotionBlur: boolean;
  61828. /**
  61829. * List of animations for the pipeline (IAnimatable implementation)
  61830. */
  61831. animations: Animation[];
  61832. /**
  61833. * Private members
  61834. */
  61835. private _scene;
  61836. private _currentDepthOfFieldSource;
  61837. private _basePostProcess;
  61838. private _fixedExposure;
  61839. private _currentExposure;
  61840. private _hdrAutoExposure;
  61841. private _hdrCurrentLuminance;
  61842. private _motionStrength;
  61843. private _isObjectBasedMotionBlur;
  61844. private _floatTextureType;
  61845. private _ratio;
  61846. private _bloomEnabled;
  61847. private _depthOfFieldEnabled;
  61848. private _vlsEnabled;
  61849. private _lensFlareEnabled;
  61850. private _hdrEnabled;
  61851. private _motionBlurEnabled;
  61852. private _fxaaEnabled;
  61853. private _motionBlurSamples;
  61854. private _volumetricLightStepsCount;
  61855. private _samples;
  61856. /**
  61857. * @ignore
  61858. * Specifies if the bloom pipeline is enabled
  61859. */
  61860. BloomEnabled: boolean;
  61861. /**
  61862. * @ignore
  61863. * Specifies if the depth of field pipeline is enabed
  61864. */
  61865. DepthOfFieldEnabled: boolean;
  61866. /**
  61867. * @ignore
  61868. * Specifies if the lens flare pipeline is enabed
  61869. */
  61870. LensFlareEnabled: boolean;
  61871. /**
  61872. * @ignore
  61873. * Specifies if the HDR pipeline is enabled
  61874. */
  61875. HDREnabled: boolean;
  61876. /**
  61877. * @ignore
  61878. * Specifies if the volumetric lights scattering effect is enabled
  61879. */
  61880. VLSEnabled: boolean;
  61881. /**
  61882. * @ignore
  61883. * Specifies if the motion blur effect is enabled
  61884. */
  61885. MotionBlurEnabled: boolean;
  61886. /**
  61887. * Specifies if anti-aliasing is enabled
  61888. */
  61889. fxaaEnabled: boolean;
  61890. /**
  61891. * Specifies the number of steps used to calculate the volumetric lights
  61892. * Typically in interval [50, 200]
  61893. */
  61894. volumetricLightStepsCount: number;
  61895. /**
  61896. * Specifies the number of samples used for the motion blur effect
  61897. * Typically in interval [16, 64]
  61898. */
  61899. motionBlurSamples: number;
  61900. /**
  61901. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61902. */
  61903. samples: number;
  61904. /**
  61905. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61906. * @constructor
  61907. * @param name The rendering pipeline name
  61908. * @param scene The scene linked to this pipeline
  61909. * @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)
  61910. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61911. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61912. */
  61913. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61914. private _buildPipeline;
  61915. private _createDownSampleX4PostProcess;
  61916. private _createBrightPassPostProcess;
  61917. private _createBlurPostProcesses;
  61918. private _createTextureAdderPostProcess;
  61919. private _createVolumetricLightPostProcess;
  61920. private _createLuminancePostProcesses;
  61921. private _createHdrPostProcess;
  61922. private _createLensFlarePostProcess;
  61923. private _createDepthOfFieldPostProcess;
  61924. private _createMotionBlurPostProcess;
  61925. private _getDepthTexture;
  61926. private _disposePostProcesses;
  61927. /**
  61928. * Dispose of the pipeline and stop all post processes
  61929. */
  61930. dispose(): void;
  61931. /**
  61932. * Serialize the rendering pipeline (Used when exporting)
  61933. * @returns the serialized object
  61934. */
  61935. serialize(): any;
  61936. /**
  61937. * Parse the serialized pipeline
  61938. * @param source Source pipeline.
  61939. * @param scene The scene to load the pipeline to.
  61940. * @param rootUrl The URL of the serialized pipeline.
  61941. * @returns An instantiated pipeline from the serialized object.
  61942. */
  61943. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61944. /**
  61945. * Luminance steps
  61946. */
  61947. static LuminanceSteps: number;
  61948. }
  61949. }
  61950. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  61951. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  61952. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  61953. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  61954. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  61955. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  61956. }
  61957. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  61958. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  61959. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61960. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61961. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61962. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61963. }
  61964. declare module "babylonjs/Shaders/tonemap.fragment" {
  61965. /** @hidden */
  61966. export var tonemapPixelShader: {
  61967. name: string;
  61968. shader: string;
  61969. };
  61970. }
  61971. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  61972. import { Camera } from "babylonjs/Cameras/camera";
  61973. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61974. import "babylonjs/Shaders/tonemap.fragment";
  61975. import { Engine } from "babylonjs/Engines/engine";
  61976. /** Defines operator used for tonemapping */
  61977. export enum TonemappingOperator {
  61978. /** Hable */
  61979. Hable = 0,
  61980. /** Reinhard */
  61981. Reinhard = 1,
  61982. /** HejiDawson */
  61983. HejiDawson = 2,
  61984. /** Photographic */
  61985. Photographic = 3
  61986. }
  61987. /**
  61988. * Defines a post process to apply tone mapping
  61989. */
  61990. export class TonemapPostProcess extends PostProcess {
  61991. private _operator;
  61992. /** Defines the required exposure adjustement */
  61993. exposureAdjustment: number;
  61994. /**
  61995. * Creates a new TonemapPostProcess
  61996. * @param name defines the name of the postprocess
  61997. * @param _operator defines the operator to use
  61998. * @param exposureAdjustment defines the required exposure adjustement
  61999. * @param camera defines the camera to use (can be null)
  62000. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62001. * @param engine defines the hosting engine (can be ignore if camera is set)
  62002. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62003. */
  62004. constructor(name: string, _operator: TonemappingOperator,
  62005. /** Defines the required exposure adjustement */
  62006. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62007. }
  62008. }
  62009. declare module "babylonjs/Shaders/depth.vertex" {
  62010. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62011. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62012. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62013. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62014. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62015. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62016. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62017. /** @hidden */
  62018. export var depthVertexShader: {
  62019. name: string;
  62020. shader: string;
  62021. };
  62022. }
  62023. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  62024. /** @hidden */
  62025. export var volumetricLightScatteringPixelShader: {
  62026. name: string;
  62027. shader: string;
  62028. };
  62029. }
  62030. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  62031. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62032. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62033. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62034. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62035. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62036. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62037. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62038. /** @hidden */
  62039. export var volumetricLightScatteringPassVertexShader: {
  62040. name: string;
  62041. shader: string;
  62042. };
  62043. }
  62044. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  62045. /** @hidden */
  62046. export var volumetricLightScatteringPassPixelShader: {
  62047. name: string;
  62048. shader: string;
  62049. };
  62050. }
  62051. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  62052. import { Vector3 } from "babylonjs/Maths/math.vector";
  62053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62054. import { Mesh } from "babylonjs/Meshes/mesh";
  62055. import { Camera } from "babylonjs/Cameras/camera";
  62056. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62057. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62058. import { Scene } from "babylonjs/scene";
  62059. import "babylonjs/Meshes/Builders/planeBuilder";
  62060. import "babylonjs/Shaders/depth.vertex";
  62061. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  62062. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  62063. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  62064. import { Engine } from "babylonjs/Engines/engine";
  62065. /**
  62066. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62067. */
  62068. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62069. private _volumetricLightScatteringPass;
  62070. private _volumetricLightScatteringRTT;
  62071. private _viewPort;
  62072. private _screenCoordinates;
  62073. private _cachedDefines;
  62074. /**
  62075. * If not undefined, the mesh position is computed from the attached node position
  62076. */
  62077. attachedNode: {
  62078. position: Vector3;
  62079. };
  62080. /**
  62081. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62082. */
  62083. customMeshPosition: Vector3;
  62084. /**
  62085. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62086. */
  62087. useCustomMeshPosition: boolean;
  62088. /**
  62089. * If the post-process should inverse the light scattering direction
  62090. */
  62091. invert: boolean;
  62092. /**
  62093. * The internal mesh used by the post-process
  62094. */
  62095. mesh: Mesh;
  62096. /**
  62097. * @hidden
  62098. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62099. */
  62100. useDiffuseColor: boolean;
  62101. /**
  62102. * Array containing the excluded meshes not rendered in the internal pass
  62103. */
  62104. excludedMeshes: AbstractMesh[];
  62105. /**
  62106. * Controls the overall intensity of the post-process
  62107. */
  62108. exposure: number;
  62109. /**
  62110. * Dissipates each sample's contribution in range [0, 1]
  62111. */
  62112. decay: number;
  62113. /**
  62114. * Controls the overall intensity of each sample
  62115. */
  62116. weight: number;
  62117. /**
  62118. * Controls the density of each sample
  62119. */
  62120. density: number;
  62121. /**
  62122. * @constructor
  62123. * @param name The post-process name
  62124. * @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)
  62125. * @param camera The camera that the post-process will be attached to
  62126. * @param mesh The mesh used to create the light scattering
  62127. * @param samples The post-process quality, default 100
  62128. * @param samplingModeThe post-process filtering mode
  62129. * @param engine The babylon engine
  62130. * @param reusable If the post-process is reusable
  62131. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62132. */
  62133. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62134. /**
  62135. * Returns the string "VolumetricLightScatteringPostProcess"
  62136. * @returns "VolumetricLightScatteringPostProcess"
  62137. */
  62138. getClassName(): string;
  62139. private _isReady;
  62140. /**
  62141. * Sets the new light position for light scattering effect
  62142. * @param position The new custom light position
  62143. */
  62144. setCustomMeshPosition(position: Vector3): void;
  62145. /**
  62146. * Returns the light position for light scattering effect
  62147. * @return Vector3 The custom light position
  62148. */
  62149. getCustomMeshPosition(): Vector3;
  62150. /**
  62151. * Disposes the internal assets and detaches the post-process from the camera
  62152. */
  62153. dispose(camera: Camera): void;
  62154. /**
  62155. * Returns the render target texture used by the post-process
  62156. * @return the render target texture used by the post-process
  62157. */
  62158. getPass(): RenderTargetTexture;
  62159. private _meshExcluded;
  62160. private _createPass;
  62161. private _updateMeshScreenCoordinates;
  62162. /**
  62163. * Creates a default mesh for the Volumeric Light Scattering post-process
  62164. * @param name The mesh name
  62165. * @param scene The scene where to create the mesh
  62166. * @return the default mesh
  62167. */
  62168. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62169. }
  62170. }
  62171. declare module "babylonjs/PostProcesses/index" {
  62172. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  62173. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  62174. export * from "babylonjs/PostProcesses/bloomEffect";
  62175. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  62176. export * from "babylonjs/PostProcesses/blurPostProcess";
  62177. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62178. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  62179. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  62180. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  62181. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62182. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  62183. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  62184. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  62185. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62186. export * from "babylonjs/PostProcesses/filterPostProcess";
  62187. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  62188. export * from "babylonjs/PostProcesses/grainPostProcess";
  62189. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  62190. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62191. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  62192. export * from "babylonjs/PostProcesses/passPostProcess";
  62193. export * from "babylonjs/PostProcesses/postProcess";
  62194. export * from "babylonjs/PostProcesses/postProcessManager";
  62195. export * from "babylonjs/PostProcesses/refractionPostProcess";
  62196. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  62197. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  62198. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  62199. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  62200. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  62201. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  62202. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  62203. }
  62204. declare module "babylonjs/Probes/index" {
  62205. export * from "babylonjs/Probes/reflectionProbe";
  62206. }
  62207. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  62208. import { Scene } from "babylonjs/scene";
  62209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62210. import { SmartArray } from "babylonjs/Misc/smartArray";
  62211. import { ISceneComponent } from "babylonjs/sceneComponent";
  62212. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  62213. import "babylonjs/Meshes/Builders/boxBuilder";
  62214. import "babylonjs/Shaders/color.fragment";
  62215. import "babylonjs/Shaders/color.vertex";
  62216. import { Color3 } from "babylonjs/Maths/math.color";
  62217. module "babylonjs/scene" {
  62218. interface Scene {
  62219. /** @hidden (Backing field) */
  62220. _boundingBoxRenderer: BoundingBoxRenderer;
  62221. /** @hidden (Backing field) */
  62222. _forceShowBoundingBoxes: boolean;
  62223. /**
  62224. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62225. */
  62226. forceShowBoundingBoxes: boolean;
  62227. /**
  62228. * Gets the bounding box renderer associated with the scene
  62229. * @returns a BoundingBoxRenderer
  62230. */
  62231. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62232. }
  62233. }
  62234. module "babylonjs/Meshes/abstractMesh" {
  62235. interface AbstractMesh {
  62236. /** @hidden (Backing field) */
  62237. _showBoundingBox: boolean;
  62238. /**
  62239. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62240. */
  62241. showBoundingBox: boolean;
  62242. }
  62243. }
  62244. /**
  62245. * Component responsible of rendering the bounding box of the meshes in a scene.
  62246. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62247. */
  62248. export class BoundingBoxRenderer implements ISceneComponent {
  62249. /**
  62250. * The component name helpfull to identify the component in the list of scene components.
  62251. */
  62252. readonly name: string;
  62253. /**
  62254. * The scene the component belongs to.
  62255. */
  62256. scene: Scene;
  62257. /**
  62258. * Color of the bounding box lines placed in front of an object
  62259. */
  62260. frontColor: Color3;
  62261. /**
  62262. * Color of the bounding box lines placed behind an object
  62263. */
  62264. backColor: Color3;
  62265. /**
  62266. * Defines if the renderer should show the back lines or not
  62267. */
  62268. showBackLines: boolean;
  62269. /**
  62270. * @hidden
  62271. */
  62272. renderList: SmartArray<BoundingBox>;
  62273. private _colorShader;
  62274. private _vertexBuffers;
  62275. private _indexBuffer;
  62276. private _fillIndexBuffer;
  62277. private _fillIndexData;
  62278. /**
  62279. * Instantiates a new bounding box renderer in a scene.
  62280. * @param scene the scene the renderer renders in
  62281. */
  62282. constructor(scene: Scene);
  62283. /**
  62284. * Registers the component in a given scene
  62285. */
  62286. register(): void;
  62287. private _evaluateSubMesh;
  62288. private _activeMesh;
  62289. private _prepareRessources;
  62290. private _createIndexBuffer;
  62291. /**
  62292. * Rebuilds the elements related to this component in case of
  62293. * context lost for instance.
  62294. */
  62295. rebuild(): void;
  62296. /**
  62297. * @hidden
  62298. */
  62299. reset(): void;
  62300. /**
  62301. * Render the bounding boxes of a specific rendering group
  62302. * @param renderingGroupId defines the rendering group to render
  62303. */
  62304. render(renderingGroupId: number): void;
  62305. /**
  62306. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62307. * @param mesh Define the mesh to render the occlusion bounding box for
  62308. */
  62309. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62310. /**
  62311. * Dispose and release the resources attached to this renderer.
  62312. */
  62313. dispose(): void;
  62314. }
  62315. }
  62316. declare module "babylonjs/Shaders/depth.fragment" {
  62317. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62318. /** @hidden */
  62319. export var depthPixelShader: {
  62320. name: string;
  62321. shader: string;
  62322. };
  62323. }
  62324. declare module "babylonjs/Rendering/depthRenderer" {
  62325. import { Nullable } from "babylonjs/types";
  62326. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62327. import { Scene } from "babylonjs/scene";
  62328. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62329. import { Camera } from "babylonjs/Cameras/camera";
  62330. import "babylonjs/Shaders/depth.fragment";
  62331. import "babylonjs/Shaders/depth.vertex";
  62332. /**
  62333. * This represents a depth renderer in Babylon.
  62334. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62335. */
  62336. export class DepthRenderer {
  62337. private _scene;
  62338. private _depthMap;
  62339. private _effect;
  62340. private readonly _storeNonLinearDepth;
  62341. private readonly _clearColor;
  62342. /** Get if the depth renderer is using packed depth or not */
  62343. readonly isPacked: boolean;
  62344. private _cachedDefines;
  62345. private _camera;
  62346. /**
  62347. * Specifiess that the depth renderer will only be used within
  62348. * the camera it is created for.
  62349. * This can help forcing its rendering during the camera processing.
  62350. */
  62351. useOnlyInActiveCamera: boolean;
  62352. /** @hidden */
  62353. static _SceneComponentInitialization: (scene: Scene) => void;
  62354. /**
  62355. * Instantiates a depth renderer
  62356. * @param scene The scene the renderer belongs to
  62357. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62358. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62359. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62360. */
  62361. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62362. /**
  62363. * Creates the depth rendering effect and checks if the effect is ready.
  62364. * @param subMesh The submesh to be used to render the depth map of
  62365. * @param useInstances If multiple world instances should be used
  62366. * @returns if the depth renderer is ready to render the depth map
  62367. */
  62368. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62369. /**
  62370. * Gets the texture which the depth map will be written to.
  62371. * @returns The depth map texture
  62372. */
  62373. getDepthMap(): RenderTargetTexture;
  62374. /**
  62375. * Disposes of the depth renderer.
  62376. */
  62377. dispose(): void;
  62378. }
  62379. }
  62380. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  62381. import { Nullable } from "babylonjs/types";
  62382. import { Scene } from "babylonjs/scene";
  62383. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62384. import { Camera } from "babylonjs/Cameras/camera";
  62385. import { ISceneComponent } from "babylonjs/sceneComponent";
  62386. module "babylonjs/scene" {
  62387. interface Scene {
  62388. /** @hidden (Backing field) */
  62389. _depthRenderer: {
  62390. [id: string]: DepthRenderer;
  62391. };
  62392. /**
  62393. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62394. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62395. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62396. * @returns the created depth renderer
  62397. */
  62398. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62399. /**
  62400. * Disables a depth renderer for a given camera
  62401. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62402. */
  62403. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62404. }
  62405. }
  62406. /**
  62407. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62408. * in several rendering techniques.
  62409. */
  62410. export class DepthRendererSceneComponent implements ISceneComponent {
  62411. /**
  62412. * The component name helpfull to identify the component in the list of scene components.
  62413. */
  62414. readonly name: string;
  62415. /**
  62416. * The scene the component belongs to.
  62417. */
  62418. scene: Scene;
  62419. /**
  62420. * Creates a new instance of the component for the given scene
  62421. * @param scene Defines the scene to register the component in
  62422. */
  62423. constructor(scene: Scene);
  62424. /**
  62425. * Registers the component in a given scene
  62426. */
  62427. register(): void;
  62428. /**
  62429. * Rebuilds the elements related to this component in case of
  62430. * context lost for instance.
  62431. */
  62432. rebuild(): void;
  62433. /**
  62434. * Disposes the component and the associated ressources
  62435. */
  62436. dispose(): void;
  62437. private _gatherRenderTargets;
  62438. private _gatherActiveCameraRenderTargets;
  62439. }
  62440. }
  62441. declare module "babylonjs/Shaders/outline.fragment" {
  62442. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62443. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  62444. /** @hidden */
  62445. export var outlinePixelShader: {
  62446. name: string;
  62447. shader: string;
  62448. };
  62449. }
  62450. declare module "babylonjs/Shaders/outline.vertex" {
  62451. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62452. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62453. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62454. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62455. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62456. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62457. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62458. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62459. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  62460. /** @hidden */
  62461. export var outlineVertexShader: {
  62462. name: string;
  62463. shader: string;
  62464. };
  62465. }
  62466. declare module "babylonjs/Rendering/outlineRenderer" {
  62467. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62468. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  62469. import { Scene } from "babylonjs/scene";
  62470. import { ISceneComponent } from "babylonjs/sceneComponent";
  62471. import "babylonjs/Shaders/outline.fragment";
  62472. import "babylonjs/Shaders/outline.vertex";
  62473. module "babylonjs/scene" {
  62474. interface Scene {
  62475. /** @hidden */
  62476. _outlineRenderer: OutlineRenderer;
  62477. /**
  62478. * Gets the outline renderer associated with the scene
  62479. * @returns a OutlineRenderer
  62480. */
  62481. getOutlineRenderer(): OutlineRenderer;
  62482. }
  62483. }
  62484. module "babylonjs/Meshes/abstractMesh" {
  62485. interface AbstractMesh {
  62486. /** @hidden (Backing field) */
  62487. _renderOutline: boolean;
  62488. /**
  62489. * Gets or sets a boolean indicating if the outline must be rendered as well
  62490. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62491. */
  62492. renderOutline: boolean;
  62493. /** @hidden (Backing field) */
  62494. _renderOverlay: boolean;
  62495. /**
  62496. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62497. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62498. */
  62499. renderOverlay: boolean;
  62500. }
  62501. }
  62502. /**
  62503. * This class is responsible to draw bothe outline/overlay of meshes.
  62504. * It should not be used directly but through the available method on mesh.
  62505. */
  62506. export class OutlineRenderer implements ISceneComponent {
  62507. /**
  62508. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62509. */
  62510. private static _StencilReference;
  62511. /**
  62512. * The name of the component. Each component must have a unique name.
  62513. */
  62514. name: string;
  62515. /**
  62516. * The scene the component belongs to.
  62517. */
  62518. scene: Scene;
  62519. /**
  62520. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62521. */
  62522. zOffset: number;
  62523. private _engine;
  62524. private _effect;
  62525. private _cachedDefines;
  62526. private _savedDepthWrite;
  62527. /**
  62528. * Instantiates a new outline renderer. (There could be only one per scene).
  62529. * @param scene Defines the scene it belongs to
  62530. */
  62531. constructor(scene: Scene);
  62532. /**
  62533. * Register the component to one instance of a scene.
  62534. */
  62535. register(): void;
  62536. /**
  62537. * Rebuilds the elements related to this component in case of
  62538. * context lost for instance.
  62539. */
  62540. rebuild(): void;
  62541. /**
  62542. * Disposes the component and the associated ressources.
  62543. */
  62544. dispose(): void;
  62545. /**
  62546. * Renders the outline in the canvas.
  62547. * @param subMesh Defines the sumesh to render
  62548. * @param batch Defines the batch of meshes in case of instances
  62549. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62550. */
  62551. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62552. /**
  62553. * Returns whether or not the outline renderer is ready for a given submesh.
  62554. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62555. * @param subMesh Defines the submesh to check readyness for
  62556. * @param useInstances Defines wheter wee are trying to render instances or not
  62557. * @returns true if ready otherwise false
  62558. */
  62559. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62560. private _beforeRenderingMesh;
  62561. private _afterRenderingMesh;
  62562. }
  62563. }
  62564. declare module "babylonjs/Rendering/index" {
  62565. export * from "babylonjs/Rendering/boundingBoxRenderer";
  62566. export * from "babylonjs/Rendering/depthRenderer";
  62567. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  62568. export * from "babylonjs/Rendering/edgesRenderer";
  62569. export * from "babylonjs/Rendering/geometryBufferRenderer";
  62570. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62571. export * from "babylonjs/Rendering/outlineRenderer";
  62572. export * from "babylonjs/Rendering/renderingGroup";
  62573. export * from "babylonjs/Rendering/renderingManager";
  62574. export * from "babylonjs/Rendering/utilityLayerRenderer";
  62575. }
  62576. declare module "babylonjs/Sprites/index" {
  62577. export * from "babylonjs/Sprites/sprite";
  62578. export * from "babylonjs/Sprites/spriteManager";
  62579. export * from "babylonjs/Sprites/spriteSceneComponent";
  62580. }
  62581. declare module "babylonjs/Misc/assetsManager" {
  62582. import { Scene } from "babylonjs/scene";
  62583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62584. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62585. import { Skeleton } from "babylonjs/Bones/skeleton";
  62586. import { Observable } from "babylonjs/Misc/observable";
  62587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62588. import { Texture } from "babylonjs/Materials/Textures/texture";
  62589. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  62590. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  62591. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  62592. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  62593. /**
  62594. * Defines the list of states available for a task inside a AssetsManager
  62595. */
  62596. export enum AssetTaskState {
  62597. /**
  62598. * Initialization
  62599. */
  62600. INIT = 0,
  62601. /**
  62602. * Running
  62603. */
  62604. RUNNING = 1,
  62605. /**
  62606. * Done
  62607. */
  62608. DONE = 2,
  62609. /**
  62610. * Error
  62611. */
  62612. ERROR = 3
  62613. }
  62614. /**
  62615. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62616. */
  62617. export abstract class AbstractAssetTask {
  62618. /**
  62619. * Task name
  62620. */ name: string;
  62621. /**
  62622. * Callback called when the task is successful
  62623. */
  62624. onSuccess: (task: any) => void;
  62625. /**
  62626. * Callback called when the task is not successful
  62627. */
  62628. onError: (task: any, message?: string, exception?: any) => void;
  62629. /**
  62630. * Creates a new AssetsManager
  62631. * @param name defines the name of the task
  62632. */
  62633. constructor(
  62634. /**
  62635. * Task name
  62636. */ name: string);
  62637. private _isCompleted;
  62638. private _taskState;
  62639. private _errorObject;
  62640. /**
  62641. * Get if the task is completed
  62642. */
  62643. readonly isCompleted: boolean;
  62644. /**
  62645. * Gets the current state of the task
  62646. */
  62647. readonly taskState: AssetTaskState;
  62648. /**
  62649. * Gets the current error object (if task is in error)
  62650. */
  62651. readonly errorObject: {
  62652. message?: string;
  62653. exception?: any;
  62654. };
  62655. /**
  62656. * Internal only
  62657. * @hidden
  62658. */
  62659. _setErrorObject(message?: string, exception?: any): void;
  62660. /**
  62661. * Execute the current task
  62662. * @param scene defines the scene where you want your assets to be loaded
  62663. * @param onSuccess is a callback called when the task is successfully executed
  62664. * @param onError is a callback called if an error occurs
  62665. */
  62666. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62667. /**
  62668. * Execute the current task
  62669. * @param scene defines the scene where you want your assets to be loaded
  62670. * @param onSuccess is a callback called when the task is successfully executed
  62671. * @param onError is a callback called if an error occurs
  62672. */
  62673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62674. /**
  62675. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62676. * This can be used with failed tasks that have the reason for failure fixed.
  62677. */
  62678. reset(): void;
  62679. private onErrorCallback;
  62680. private onDoneCallback;
  62681. }
  62682. /**
  62683. * Define the interface used by progress events raised during assets loading
  62684. */
  62685. export interface IAssetsProgressEvent {
  62686. /**
  62687. * Defines the number of remaining tasks to process
  62688. */
  62689. remainingCount: number;
  62690. /**
  62691. * Defines the total number of tasks
  62692. */
  62693. totalCount: number;
  62694. /**
  62695. * Defines the task that was just processed
  62696. */
  62697. task: AbstractAssetTask;
  62698. }
  62699. /**
  62700. * Class used to share progress information about assets loading
  62701. */
  62702. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62703. /**
  62704. * Defines the number of remaining tasks to process
  62705. */
  62706. remainingCount: number;
  62707. /**
  62708. * Defines the total number of tasks
  62709. */
  62710. totalCount: number;
  62711. /**
  62712. * Defines the task that was just processed
  62713. */
  62714. task: AbstractAssetTask;
  62715. /**
  62716. * Creates a AssetsProgressEvent
  62717. * @param remainingCount defines the number of remaining tasks to process
  62718. * @param totalCount defines the total number of tasks
  62719. * @param task defines the task that was just processed
  62720. */
  62721. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62722. }
  62723. /**
  62724. * Define a task used by AssetsManager to load meshes
  62725. */
  62726. export class MeshAssetTask extends AbstractAssetTask {
  62727. /**
  62728. * Defines the name of the task
  62729. */
  62730. name: string;
  62731. /**
  62732. * Defines the list of mesh's names you want to load
  62733. */
  62734. meshesNames: any;
  62735. /**
  62736. * Defines the root url to use as a base to load your meshes and associated resources
  62737. */
  62738. rootUrl: string;
  62739. /**
  62740. * Defines the filename of the scene to load from
  62741. */
  62742. sceneFilename: string;
  62743. /**
  62744. * Gets the list of loaded meshes
  62745. */
  62746. loadedMeshes: Array<AbstractMesh>;
  62747. /**
  62748. * Gets the list of loaded particle systems
  62749. */
  62750. loadedParticleSystems: Array<IParticleSystem>;
  62751. /**
  62752. * Gets the list of loaded skeletons
  62753. */
  62754. loadedSkeletons: Array<Skeleton>;
  62755. /**
  62756. * Gets the list of loaded animation groups
  62757. */
  62758. loadedAnimationGroups: Array<AnimationGroup>;
  62759. /**
  62760. * Callback called when the task is successful
  62761. */
  62762. onSuccess: (task: MeshAssetTask) => void;
  62763. /**
  62764. * Callback called when the task is successful
  62765. */
  62766. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62767. /**
  62768. * Creates a new MeshAssetTask
  62769. * @param name defines the name of the task
  62770. * @param meshesNames defines the list of mesh's names you want to load
  62771. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62772. * @param sceneFilename defines the filename of the scene to load from
  62773. */
  62774. constructor(
  62775. /**
  62776. * Defines the name of the task
  62777. */
  62778. name: string,
  62779. /**
  62780. * Defines the list of mesh's names you want to load
  62781. */
  62782. meshesNames: any,
  62783. /**
  62784. * Defines the root url to use as a base to load your meshes and associated resources
  62785. */
  62786. rootUrl: string,
  62787. /**
  62788. * Defines the filename of the scene to load from
  62789. */
  62790. sceneFilename: string);
  62791. /**
  62792. * Execute the current task
  62793. * @param scene defines the scene where you want your assets to be loaded
  62794. * @param onSuccess is a callback called when the task is successfully executed
  62795. * @param onError is a callback called if an error occurs
  62796. */
  62797. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62798. }
  62799. /**
  62800. * Define a task used by AssetsManager to load text content
  62801. */
  62802. export class TextFileAssetTask extends AbstractAssetTask {
  62803. /**
  62804. * Defines the name of the task
  62805. */
  62806. name: string;
  62807. /**
  62808. * Defines the location of the file to load
  62809. */
  62810. url: string;
  62811. /**
  62812. * Gets the loaded text string
  62813. */
  62814. text: string;
  62815. /**
  62816. * Callback called when the task is successful
  62817. */
  62818. onSuccess: (task: TextFileAssetTask) => void;
  62819. /**
  62820. * Callback called when the task is successful
  62821. */
  62822. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62823. /**
  62824. * Creates a new TextFileAssetTask object
  62825. * @param name defines the name of the task
  62826. * @param url defines the location of the file to load
  62827. */
  62828. constructor(
  62829. /**
  62830. * Defines the name of the task
  62831. */
  62832. name: string,
  62833. /**
  62834. * Defines the location of the file to load
  62835. */
  62836. url: string);
  62837. /**
  62838. * Execute the current task
  62839. * @param scene defines the scene where you want your assets to be loaded
  62840. * @param onSuccess is a callback called when the task is successfully executed
  62841. * @param onError is a callback called if an error occurs
  62842. */
  62843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62844. }
  62845. /**
  62846. * Define a task used by AssetsManager to load binary data
  62847. */
  62848. export class BinaryFileAssetTask extends AbstractAssetTask {
  62849. /**
  62850. * Defines the name of the task
  62851. */
  62852. name: string;
  62853. /**
  62854. * Defines the location of the file to load
  62855. */
  62856. url: string;
  62857. /**
  62858. * Gets the lodaded data (as an array buffer)
  62859. */
  62860. data: ArrayBuffer;
  62861. /**
  62862. * Callback called when the task is successful
  62863. */
  62864. onSuccess: (task: BinaryFileAssetTask) => void;
  62865. /**
  62866. * Callback called when the task is successful
  62867. */
  62868. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62869. /**
  62870. * Creates a new BinaryFileAssetTask object
  62871. * @param name defines the name of the new task
  62872. * @param url defines the location of the file to load
  62873. */
  62874. constructor(
  62875. /**
  62876. * Defines the name of the task
  62877. */
  62878. name: string,
  62879. /**
  62880. * Defines the location of the file to load
  62881. */
  62882. url: string);
  62883. /**
  62884. * Execute the current task
  62885. * @param scene defines the scene where you want your assets to be loaded
  62886. * @param onSuccess is a callback called when the task is successfully executed
  62887. * @param onError is a callback called if an error occurs
  62888. */
  62889. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62890. }
  62891. /**
  62892. * Define a task used by AssetsManager to load images
  62893. */
  62894. export class ImageAssetTask extends AbstractAssetTask {
  62895. /**
  62896. * Defines the name of the task
  62897. */
  62898. name: string;
  62899. /**
  62900. * Defines the location of the image to load
  62901. */
  62902. url: string;
  62903. /**
  62904. * Gets the loaded images
  62905. */
  62906. image: HTMLImageElement;
  62907. /**
  62908. * Callback called when the task is successful
  62909. */
  62910. onSuccess: (task: ImageAssetTask) => void;
  62911. /**
  62912. * Callback called when the task is successful
  62913. */
  62914. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62915. /**
  62916. * Creates a new ImageAssetTask
  62917. * @param name defines the name of the task
  62918. * @param url defines the location of the image to load
  62919. */
  62920. constructor(
  62921. /**
  62922. * Defines the name of the task
  62923. */
  62924. name: string,
  62925. /**
  62926. * Defines the location of the image to load
  62927. */
  62928. url: string);
  62929. /**
  62930. * Execute the current task
  62931. * @param scene defines the scene where you want your assets to be loaded
  62932. * @param onSuccess is a callback called when the task is successfully executed
  62933. * @param onError is a callback called if an error occurs
  62934. */
  62935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62936. }
  62937. /**
  62938. * Defines the interface used by texture loading tasks
  62939. */
  62940. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62941. /**
  62942. * Gets the loaded texture
  62943. */
  62944. texture: TEX;
  62945. }
  62946. /**
  62947. * Define a task used by AssetsManager to load 2D textures
  62948. */
  62949. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62950. /**
  62951. * Defines the name of the task
  62952. */
  62953. name: string;
  62954. /**
  62955. * Defines the location of the file to load
  62956. */
  62957. url: string;
  62958. /**
  62959. * Defines if mipmap should not be generated (default is false)
  62960. */
  62961. noMipmap?: boolean | undefined;
  62962. /**
  62963. * Defines if texture must be inverted on Y axis (default is false)
  62964. */
  62965. invertY?: boolean | undefined;
  62966. /**
  62967. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62968. */
  62969. samplingMode: number;
  62970. /**
  62971. * Gets the loaded texture
  62972. */
  62973. texture: Texture;
  62974. /**
  62975. * Callback called when the task is successful
  62976. */
  62977. onSuccess: (task: TextureAssetTask) => void;
  62978. /**
  62979. * Callback called when the task is successful
  62980. */
  62981. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62982. /**
  62983. * Creates a new TextureAssetTask object
  62984. * @param name defines the name of the task
  62985. * @param url defines the location of the file to load
  62986. * @param noMipmap defines if mipmap should not be generated (default is false)
  62987. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62988. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62989. */
  62990. constructor(
  62991. /**
  62992. * Defines the name of the task
  62993. */
  62994. name: string,
  62995. /**
  62996. * Defines the location of the file to load
  62997. */
  62998. url: string,
  62999. /**
  63000. * Defines if mipmap should not be generated (default is false)
  63001. */
  63002. noMipmap?: boolean | undefined,
  63003. /**
  63004. * Defines if texture must be inverted on Y axis (default is false)
  63005. */
  63006. invertY?: boolean | undefined,
  63007. /**
  63008. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63009. */
  63010. samplingMode?: number);
  63011. /**
  63012. * Execute the current task
  63013. * @param scene defines the scene where you want your assets to be loaded
  63014. * @param onSuccess is a callback called when the task is successfully executed
  63015. * @param onError is a callback called if an error occurs
  63016. */
  63017. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63018. }
  63019. /**
  63020. * Define a task used by AssetsManager to load cube textures
  63021. */
  63022. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63023. /**
  63024. * Defines the name of the task
  63025. */
  63026. name: string;
  63027. /**
  63028. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63029. */
  63030. url: string;
  63031. /**
  63032. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63033. */
  63034. extensions?: string[] | undefined;
  63035. /**
  63036. * Defines if mipmaps should not be generated (default is false)
  63037. */
  63038. noMipmap?: boolean | undefined;
  63039. /**
  63040. * Defines the explicit list of files (undefined by default)
  63041. */
  63042. files?: string[] | undefined;
  63043. /**
  63044. * Gets the loaded texture
  63045. */
  63046. texture: CubeTexture;
  63047. /**
  63048. * Callback called when the task is successful
  63049. */
  63050. onSuccess: (task: CubeTextureAssetTask) => void;
  63051. /**
  63052. * Callback called when the task is successful
  63053. */
  63054. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63055. /**
  63056. * Creates a new CubeTextureAssetTask
  63057. * @param name defines the name of the task
  63058. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63059. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63060. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63061. * @param files defines the explicit list of files (undefined by default)
  63062. */
  63063. constructor(
  63064. /**
  63065. * Defines the name of the task
  63066. */
  63067. name: string,
  63068. /**
  63069. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63070. */
  63071. url: string,
  63072. /**
  63073. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63074. */
  63075. extensions?: string[] | undefined,
  63076. /**
  63077. * Defines if mipmaps should not be generated (default is false)
  63078. */
  63079. noMipmap?: boolean | undefined,
  63080. /**
  63081. * Defines the explicit list of files (undefined by default)
  63082. */
  63083. files?: string[] | undefined);
  63084. /**
  63085. * Execute the current task
  63086. * @param scene defines the scene where you want your assets to be loaded
  63087. * @param onSuccess is a callback called when the task is successfully executed
  63088. * @param onError is a callback called if an error occurs
  63089. */
  63090. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63091. }
  63092. /**
  63093. * Define a task used by AssetsManager to load HDR cube textures
  63094. */
  63095. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63096. /**
  63097. * Defines the name of the task
  63098. */
  63099. name: string;
  63100. /**
  63101. * Defines the location of the file to load
  63102. */
  63103. url: string;
  63104. /**
  63105. * Defines the desired size (the more it increases the longer the generation will be)
  63106. */
  63107. size: number;
  63108. /**
  63109. * Defines if mipmaps should not be generated (default is false)
  63110. */
  63111. noMipmap: boolean;
  63112. /**
  63113. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63114. */
  63115. generateHarmonics: boolean;
  63116. /**
  63117. * 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)
  63118. */
  63119. gammaSpace: boolean;
  63120. /**
  63121. * Internal Use Only
  63122. */
  63123. reserved: boolean;
  63124. /**
  63125. * Gets the loaded texture
  63126. */
  63127. texture: HDRCubeTexture;
  63128. /**
  63129. * Callback called when the task is successful
  63130. */
  63131. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63132. /**
  63133. * Callback called when the task is successful
  63134. */
  63135. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63136. /**
  63137. * Creates a new HDRCubeTextureAssetTask object
  63138. * @param name defines the name of the task
  63139. * @param url defines the location of the file to load
  63140. * @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.
  63141. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63142. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63143. * @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)
  63144. * @param reserved Internal use only
  63145. */
  63146. constructor(
  63147. /**
  63148. * Defines the name of the task
  63149. */
  63150. name: string,
  63151. /**
  63152. * Defines the location of the file to load
  63153. */
  63154. url: string,
  63155. /**
  63156. * Defines the desired size (the more it increases the longer the generation will be)
  63157. */
  63158. size: number,
  63159. /**
  63160. * Defines if mipmaps should not be generated (default is false)
  63161. */
  63162. noMipmap?: boolean,
  63163. /**
  63164. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63165. */
  63166. generateHarmonics?: boolean,
  63167. /**
  63168. * 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)
  63169. */
  63170. gammaSpace?: boolean,
  63171. /**
  63172. * Internal Use Only
  63173. */
  63174. reserved?: boolean);
  63175. /**
  63176. * Execute the current task
  63177. * @param scene defines the scene where you want your assets to be loaded
  63178. * @param onSuccess is a callback called when the task is successfully executed
  63179. * @param onError is a callback called if an error occurs
  63180. */
  63181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63182. }
  63183. /**
  63184. * Define a task used by AssetsManager to load Equirectangular cube textures
  63185. */
  63186. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63187. /**
  63188. * Defines the name of the task
  63189. */
  63190. name: string;
  63191. /**
  63192. * Defines the location of the file to load
  63193. */
  63194. url: string;
  63195. /**
  63196. * Defines the desired size (the more it increases the longer the generation will be)
  63197. */
  63198. size: number;
  63199. /**
  63200. * Defines if mipmaps should not be generated (default is false)
  63201. */
  63202. noMipmap: boolean;
  63203. /**
  63204. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63205. * but the standard material would require them in Gamma space) (default is true)
  63206. */
  63207. gammaSpace: boolean;
  63208. /**
  63209. * Gets the loaded texture
  63210. */
  63211. texture: EquiRectangularCubeTexture;
  63212. /**
  63213. * Callback called when the task is successful
  63214. */
  63215. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63216. /**
  63217. * Callback called when the task is successful
  63218. */
  63219. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63220. /**
  63221. * Creates a new EquiRectangularCubeTextureAssetTask object
  63222. * @param name defines the name of the task
  63223. * @param url defines the location of the file to load
  63224. * @param size defines the desired size (the more it increases the longer the generation will be)
  63225. * If the size is omitted this implies you are using a preprocessed cubemap.
  63226. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63227. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63228. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63229. * (default is true)
  63230. */
  63231. constructor(
  63232. /**
  63233. * Defines the name of the task
  63234. */
  63235. name: string,
  63236. /**
  63237. * Defines the location of the file to load
  63238. */
  63239. url: string,
  63240. /**
  63241. * Defines the desired size (the more it increases the longer the generation will be)
  63242. */
  63243. size: number,
  63244. /**
  63245. * Defines if mipmaps should not be generated (default is false)
  63246. */
  63247. noMipmap?: boolean,
  63248. /**
  63249. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63250. * but the standard material would require them in Gamma space) (default is true)
  63251. */
  63252. gammaSpace?: boolean);
  63253. /**
  63254. * Execute the current task
  63255. * @param scene defines the scene where you want your assets to be loaded
  63256. * @param onSuccess is a callback called when the task is successfully executed
  63257. * @param onError is a callback called if an error occurs
  63258. */
  63259. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63260. }
  63261. /**
  63262. * This class can be used to easily import assets into a scene
  63263. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63264. */
  63265. export class AssetsManager {
  63266. private _scene;
  63267. private _isLoading;
  63268. protected _tasks: AbstractAssetTask[];
  63269. protected _waitingTasksCount: number;
  63270. protected _totalTasksCount: number;
  63271. /**
  63272. * Callback called when all tasks are processed
  63273. */
  63274. onFinish: (tasks: AbstractAssetTask[]) => void;
  63275. /**
  63276. * Callback called when a task is successful
  63277. */
  63278. onTaskSuccess: (task: AbstractAssetTask) => void;
  63279. /**
  63280. * Callback called when a task had an error
  63281. */
  63282. onTaskError: (task: AbstractAssetTask) => void;
  63283. /**
  63284. * Callback called when a task is done (whatever the result is)
  63285. */
  63286. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63287. /**
  63288. * Observable called when all tasks are processed
  63289. */
  63290. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63291. /**
  63292. * Observable called when a task had an error
  63293. */
  63294. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63295. /**
  63296. * Observable called when all tasks were executed
  63297. */
  63298. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63299. /**
  63300. * Observable called when a task is done (whatever the result is)
  63301. */
  63302. onProgressObservable: Observable<IAssetsProgressEvent>;
  63303. /**
  63304. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63305. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63306. */
  63307. useDefaultLoadingScreen: boolean;
  63308. /**
  63309. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63310. * when all assets have been downloaded.
  63311. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63312. */
  63313. autoHideLoadingUI: boolean;
  63314. /**
  63315. * Creates a new AssetsManager
  63316. * @param scene defines the scene to work on
  63317. */
  63318. constructor(scene: Scene);
  63319. /**
  63320. * Add a MeshAssetTask to the list of active tasks
  63321. * @param taskName defines the name of the new task
  63322. * @param meshesNames defines the name of meshes to load
  63323. * @param rootUrl defines the root url to use to locate files
  63324. * @param sceneFilename defines the filename of the scene file
  63325. * @returns a new MeshAssetTask object
  63326. */
  63327. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63328. /**
  63329. * Add a TextFileAssetTask to the list of active tasks
  63330. * @param taskName defines the name of the new task
  63331. * @param url defines the url of the file to load
  63332. * @returns a new TextFileAssetTask object
  63333. */
  63334. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63335. /**
  63336. * Add a BinaryFileAssetTask to the list of active tasks
  63337. * @param taskName defines the name of the new task
  63338. * @param url defines the url of the file to load
  63339. * @returns a new BinaryFileAssetTask object
  63340. */
  63341. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63342. /**
  63343. * Add a ImageAssetTask to the list of active tasks
  63344. * @param taskName defines the name of the new task
  63345. * @param url defines the url of the file to load
  63346. * @returns a new ImageAssetTask object
  63347. */
  63348. addImageTask(taskName: string, url: string): ImageAssetTask;
  63349. /**
  63350. * Add a TextureAssetTask to the list of active tasks
  63351. * @param taskName defines the name of the new task
  63352. * @param url defines the url of the file to load
  63353. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63354. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63355. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63356. * @returns a new TextureAssetTask object
  63357. */
  63358. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63359. /**
  63360. * Add a CubeTextureAssetTask to the list of active tasks
  63361. * @param taskName defines the name of the new task
  63362. * @param url defines the url of the file to load
  63363. * @param extensions defines the extension to use to load the cube map (can be null)
  63364. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63365. * @param files defines the list of files to load (can be null)
  63366. * @returns a new CubeTextureAssetTask object
  63367. */
  63368. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63369. /**
  63370. *
  63371. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63372. * @param taskName defines the name of the new task
  63373. * @param url defines the url of the file to load
  63374. * @param size defines the size you want for the cubemap (can be null)
  63375. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63376. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63377. * @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)
  63378. * @param reserved Internal use only
  63379. * @returns a new HDRCubeTextureAssetTask object
  63380. */
  63381. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63382. /**
  63383. *
  63384. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63385. * @param taskName defines the name of the new task
  63386. * @param url defines the url of the file to load
  63387. * @param size defines the size you want for the cubemap (can be null)
  63388. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63389. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63390. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63391. * @returns a new EquiRectangularCubeTextureAssetTask object
  63392. */
  63393. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63394. /**
  63395. * Remove a task from the assets manager.
  63396. * @param task the task to remove
  63397. */
  63398. removeTask(task: AbstractAssetTask): void;
  63399. private _decreaseWaitingTasksCount;
  63400. private _runTask;
  63401. /**
  63402. * Reset the AssetsManager and remove all tasks
  63403. * @return the current instance of the AssetsManager
  63404. */
  63405. reset(): AssetsManager;
  63406. /**
  63407. * Start the loading process
  63408. * @return the current instance of the AssetsManager
  63409. */
  63410. load(): AssetsManager;
  63411. /**
  63412. * Start the loading process as an async operation
  63413. * @return a promise returning the list of failed tasks
  63414. */
  63415. loadAsync(): Promise<void>;
  63416. }
  63417. }
  63418. declare module "babylonjs/Misc/deferred" {
  63419. /**
  63420. * Wrapper class for promise with external resolve and reject.
  63421. */
  63422. export class Deferred<T> {
  63423. /**
  63424. * The promise associated with this deferred object.
  63425. */
  63426. readonly promise: Promise<T>;
  63427. private _resolve;
  63428. private _reject;
  63429. /**
  63430. * The resolve method of the promise associated with this deferred object.
  63431. */
  63432. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63433. /**
  63434. * The reject method of the promise associated with this deferred object.
  63435. */
  63436. readonly reject: (reason?: any) => void;
  63437. /**
  63438. * Constructor for this deferred object.
  63439. */
  63440. constructor();
  63441. }
  63442. }
  63443. declare module "babylonjs/Misc/meshExploder" {
  63444. import { Mesh } from "babylonjs/Meshes/mesh";
  63445. /**
  63446. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63447. */
  63448. export class MeshExploder {
  63449. private _centerMesh;
  63450. private _meshes;
  63451. private _meshesOrigins;
  63452. private _toCenterVectors;
  63453. private _scaledDirection;
  63454. private _newPosition;
  63455. private _centerPosition;
  63456. /**
  63457. * Explodes meshes from a center mesh.
  63458. * @param meshes The meshes to explode.
  63459. * @param centerMesh The mesh to be center of explosion.
  63460. */
  63461. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63462. private _setCenterMesh;
  63463. /**
  63464. * Get class name
  63465. * @returns "MeshExploder"
  63466. */
  63467. getClassName(): string;
  63468. /**
  63469. * "Exploded meshes"
  63470. * @returns Array of meshes with the centerMesh at index 0.
  63471. */
  63472. getMeshes(): Array<Mesh>;
  63473. /**
  63474. * Explodes meshes giving a specific direction
  63475. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63476. */
  63477. explode(direction?: number): void;
  63478. }
  63479. }
  63480. declare module "babylonjs/Misc/filesInput" {
  63481. import { Engine } from "babylonjs/Engines/engine";
  63482. import { Scene } from "babylonjs/scene";
  63483. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  63484. /**
  63485. * Class used to help managing file picking and drag'n'drop
  63486. */
  63487. export class FilesInput {
  63488. /**
  63489. * List of files ready to be loaded
  63490. */
  63491. static readonly FilesToLoad: {
  63492. [key: string]: File;
  63493. };
  63494. /**
  63495. * Callback called when a file is processed
  63496. */
  63497. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63498. private _engine;
  63499. private _currentScene;
  63500. private _sceneLoadedCallback;
  63501. private _progressCallback;
  63502. private _additionalRenderLoopLogicCallback;
  63503. private _textureLoadingCallback;
  63504. private _startingProcessingFilesCallback;
  63505. private _onReloadCallback;
  63506. private _errorCallback;
  63507. private _elementToMonitor;
  63508. private _sceneFileToLoad;
  63509. private _filesToLoad;
  63510. /**
  63511. * Creates a new FilesInput
  63512. * @param engine defines the rendering engine
  63513. * @param scene defines the hosting scene
  63514. * @param sceneLoadedCallback callback called when scene is loaded
  63515. * @param progressCallback callback called to track progress
  63516. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63517. * @param textureLoadingCallback callback called when a texture is loading
  63518. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63519. * @param onReloadCallback callback called when a reload is requested
  63520. * @param errorCallback callback call if an error occurs
  63521. */
  63522. 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);
  63523. private _dragEnterHandler;
  63524. private _dragOverHandler;
  63525. private _dropHandler;
  63526. /**
  63527. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63528. * @param elementToMonitor defines the DOM element to track
  63529. */
  63530. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63531. /**
  63532. * Release all associated resources
  63533. */
  63534. dispose(): void;
  63535. private renderFunction;
  63536. private drag;
  63537. private drop;
  63538. private _traverseFolder;
  63539. private _processFiles;
  63540. /**
  63541. * Load files from a drop event
  63542. * @param event defines the drop event to use as source
  63543. */
  63544. loadFiles(event: any): void;
  63545. private _processReload;
  63546. /**
  63547. * Reload the current scene from the loaded files
  63548. */
  63549. reload(): void;
  63550. }
  63551. }
  63552. declare module "babylonjs/Misc/HighDynamicRange/index" {
  63553. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  63554. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  63555. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63556. }
  63557. declare module "babylonjs/Misc/sceneOptimizer" {
  63558. import { Scene, IDisposable } from "babylonjs/scene";
  63559. import { Observable } from "babylonjs/Misc/observable";
  63560. /**
  63561. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63563. */
  63564. export class SceneOptimization {
  63565. /**
  63566. * Defines the priority of this optimization (0 by default which means first in the list)
  63567. */
  63568. priority: number;
  63569. /**
  63570. * Gets a string describing the action executed by the current optimization
  63571. * @returns description string
  63572. */
  63573. getDescription(): string;
  63574. /**
  63575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63576. * @param scene defines the current scene where to apply this optimization
  63577. * @param optimizer defines the current optimizer
  63578. * @returns true if everything that can be done was applied
  63579. */
  63580. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63581. /**
  63582. * Creates the SceneOptimization object
  63583. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63584. * @param desc defines the description associated with the optimization
  63585. */
  63586. constructor(
  63587. /**
  63588. * Defines the priority of this optimization (0 by default which means first in the list)
  63589. */
  63590. priority?: number);
  63591. }
  63592. /**
  63593. * Defines an optimization used to reduce the size of render target textures
  63594. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63595. */
  63596. export class TextureOptimization extends SceneOptimization {
  63597. /**
  63598. * Defines the priority of this optimization (0 by default which means first in the list)
  63599. */
  63600. priority: number;
  63601. /**
  63602. * 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
  63603. */
  63604. maximumSize: number;
  63605. /**
  63606. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63607. */
  63608. step: number;
  63609. /**
  63610. * Gets a string describing the action executed by the current optimization
  63611. * @returns description string
  63612. */
  63613. getDescription(): string;
  63614. /**
  63615. * Creates the TextureOptimization object
  63616. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63617. * @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
  63618. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63619. */
  63620. constructor(
  63621. /**
  63622. * Defines the priority of this optimization (0 by default which means first in the list)
  63623. */
  63624. priority?: number,
  63625. /**
  63626. * 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
  63627. */
  63628. maximumSize?: number,
  63629. /**
  63630. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63631. */
  63632. step?: number);
  63633. /**
  63634. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63635. * @param scene defines the current scene where to apply this optimization
  63636. * @param optimizer defines the current optimizer
  63637. * @returns true if everything that can be done was applied
  63638. */
  63639. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63640. }
  63641. /**
  63642. * Defines an optimization used to increase or decrease the rendering resolution
  63643. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63644. */
  63645. export class HardwareScalingOptimization extends SceneOptimization {
  63646. /**
  63647. * Defines the priority of this optimization (0 by default which means first in the list)
  63648. */
  63649. priority: number;
  63650. /**
  63651. * Defines the maximum scale to use (2 by default)
  63652. */
  63653. maximumScale: number;
  63654. /**
  63655. * Defines the step to use between two passes (0.5 by default)
  63656. */
  63657. step: number;
  63658. private _currentScale;
  63659. private _directionOffset;
  63660. /**
  63661. * Gets a string describing the action executed by the current optimization
  63662. * @return description string
  63663. */
  63664. getDescription(): string;
  63665. /**
  63666. * Creates the HardwareScalingOptimization object
  63667. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63668. * @param maximumScale defines the maximum scale to use (2 by default)
  63669. * @param step defines the step to use between two passes (0.5 by default)
  63670. */
  63671. constructor(
  63672. /**
  63673. * Defines the priority of this optimization (0 by default which means first in the list)
  63674. */
  63675. priority?: number,
  63676. /**
  63677. * Defines the maximum scale to use (2 by default)
  63678. */
  63679. maximumScale?: number,
  63680. /**
  63681. * Defines the step to use between two passes (0.5 by default)
  63682. */
  63683. step?: number);
  63684. /**
  63685. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63686. * @param scene defines the current scene where to apply this optimization
  63687. * @param optimizer defines the current optimizer
  63688. * @returns true if everything that can be done was applied
  63689. */
  63690. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63691. }
  63692. /**
  63693. * Defines an optimization used to remove shadows
  63694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63695. */
  63696. export class ShadowsOptimization extends SceneOptimization {
  63697. /**
  63698. * Gets a string describing the action executed by the current optimization
  63699. * @return description string
  63700. */
  63701. getDescription(): string;
  63702. /**
  63703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63704. * @param scene defines the current scene where to apply this optimization
  63705. * @param optimizer defines the current optimizer
  63706. * @returns true if everything that can be done was applied
  63707. */
  63708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63709. }
  63710. /**
  63711. * Defines an optimization used to turn post-processes off
  63712. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63713. */
  63714. export class PostProcessesOptimization extends SceneOptimization {
  63715. /**
  63716. * Gets a string describing the action executed by the current optimization
  63717. * @return description string
  63718. */
  63719. getDescription(): string;
  63720. /**
  63721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63722. * @param scene defines the current scene where to apply this optimization
  63723. * @param optimizer defines the current optimizer
  63724. * @returns true if everything that can be done was applied
  63725. */
  63726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63727. }
  63728. /**
  63729. * Defines an optimization used to turn lens flares off
  63730. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63731. */
  63732. export class LensFlaresOptimization extends SceneOptimization {
  63733. /**
  63734. * Gets a string describing the action executed by the current optimization
  63735. * @return description string
  63736. */
  63737. getDescription(): string;
  63738. /**
  63739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63740. * @param scene defines the current scene where to apply this optimization
  63741. * @param optimizer defines the current optimizer
  63742. * @returns true if everything that can be done was applied
  63743. */
  63744. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63745. }
  63746. /**
  63747. * Defines an optimization based on user defined callback.
  63748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63749. */
  63750. export class CustomOptimization extends SceneOptimization {
  63751. /**
  63752. * Callback called to apply the custom optimization.
  63753. */
  63754. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63755. /**
  63756. * Callback called to get custom description
  63757. */
  63758. onGetDescription: () => string;
  63759. /**
  63760. * Gets a string describing the action executed by the current optimization
  63761. * @returns description string
  63762. */
  63763. getDescription(): string;
  63764. /**
  63765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63766. * @param scene defines the current scene where to apply this optimization
  63767. * @param optimizer defines the current optimizer
  63768. * @returns true if everything that can be done was applied
  63769. */
  63770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63771. }
  63772. /**
  63773. * Defines an optimization used to turn particles off
  63774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63775. */
  63776. export class ParticlesOptimization extends SceneOptimization {
  63777. /**
  63778. * Gets a string describing the action executed by the current optimization
  63779. * @return description string
  63780. */
  63781. getDescription(): string;
  63782. /**
  63783. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63784. * @param scene defines the current scene where to apply this optimization
  63785. * @param optimizer defines the current optimizer
  63786. * @returns true if everything that can be done was applied
  63787. */
  63788. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63789. }
  63790. /**
  63791. * Defines an optimization used to turn render targets off
  63792. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63793. */
  63794. export class RenderTargetsOptimization extends SceneOptimization {
  63795. /**
  63796. * Gets a string describing the action executed by the current optimization
  63797. * @return description string
  63798. */
  63799. getDescription(): string;
  63800. /**
  63801. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63802. * @param scene defines the current scene where to apply this optimization
  63803. * @param optimizer defines the current optimizer
  63804. * @returns true if everything that can be done was applied
  63805. */
  63806. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63807. }
  63808. /**
  63809. * Defines an optimization used to merge meshes with compatible materials
  63810. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63811. */
  63812. export class MergeMeshesOptimization extends SceneOptimization {
  63813. private static _UpdateSelectionTree;
  63814. /**
  63815. * Gets or sets a boolean which defines if optimization octree has to be updated
  63816. */
  63817. /**
  63818. * Gets or sets a boolean which defines if optimization octree has to be updated
  63819. */
  63820. static UpdateSelectionTree: boolean;
  63821. /**
  63822. * Gets a string describing the action executed by the current optimization
  63823. * @return description string
  63824. */
  63825. getDescription(): string;
  63826. private _canBeMerged;
  63827. /**
  63828. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63829. * @param scene defines the current scene where to apply this optimization
  63830. * @param optimizer defines the current optimizer
  63831. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63832. * @returns true if everything that can be done was applied
  63833. */
  63834. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63835. }
  63836. /**
  63837. * Defines a list of options used by SceneOptimizer
  63838. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63839. */
  63840. export class SceneOptimizerOptions {
  63841. /**
  63842. * Defines the target frame rate to reach (60 by default)
  63843. */
  63844. targetFrameRate: number;
  63845. /**
  63846. * Defines the interval between two checkes (2000ms by default)
  63847. */
  63848. trackerDuration: number;
  63849. /**
  63850. * Gets the list of optimizations to apply
  63851. */
  63852. optimizations: SceneOptimization[];
  63853. /**
  63854. * Creates a new list of options used by SceneOptimizer
  63855. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63856. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63857. */
  63858. constructor(
  63859. /**
  63860. * Defines the target frame rate to reach (60 by default)
  63861. */
  63862. targetFrameRate?: number,
  63863. /**
  63864. * Defines the interval between two checkes (2000ms by default)
  63865. */
  63866. trackerDuration?: number);
  63867. /**
  63868. * Add a new optimization
  63869. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63870. * @returns the current SceneOptimizerOptions
  63871. */
  63872. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63873. /**
  63874. * Add a new custom optimization
  63875. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63876. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63877. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63878. * @returns the current SceneOptimizerOptions
  63879. */
  63880. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63881. /**
  63882. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63883. * @param targetFrameRate defines the target frame rate (60 by default)
  63884. * @returns a SceneOptimizerOptions object
  63885. */
  63886. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63887. /**
  63888. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63889. * @param targetFrameRate defines the target frame rate (60 by default)
  63890. * @returns a SceneOptimizerOptions object
  63891. */
  63892. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63893. /**
  63894. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63895. * @param targetFrameRate defines the target frame rate (60 by default)
  63896. * @returns a SceneOptimizerOptions object
  63897. */
  63898. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63899. }
  63900. /**
  63901. * Class used to run optimizations in order to reach a target frame rate
  63902. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63903. */
  63904. export class SceneOptimizer implements IDisposable {
  63905. private _isRunning;
  63906. private _options;
  63907. private _scene;
  63908. private _currentPriorityLevel;
  63909. private _targetFrameRate;
  63910. private _trackerDuration;
  63911. private _currentFrameRate;
  63912. private _sceneDisposeObserver;
  63913. private _improvementMode;
  63914. /**
  63915. * Defines an observable called when the optimizer reaches the target frame rate
  63916. */
  63917. onSuccessObservable: Observable<SceneOptimizer>;
  63918. /**
  63919. * Defines an observable called when the optimizer enables an optimization
  63920. */
  63921. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63922. /**
  63923. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63924. */
  63925. onFailureObservable: Observable<SceneOptimizer>;
  63926. /**
  63927. * Gets a boolean indicating if the optimizer is in improvement mode
  63928. */
  63929. readonly isInImprovementMode: boolean;
  63930. /**
  63931. * Gets the current priority level (0 at start)
  63932. */
  63933. readonly currentPriorityLevel: number;
  63934. /**
  63935. * Gets the current frame rate checked by the SceneOptimizer
  63936. */
  63937. readonly currentFrameRate: number;
  63938. /**
  63939. * Gets or sets the current target frame rate (60 by default)
  63940. */
  63941. /**
  63942. * Gets or sets the current target frame rate (60 by default)
  63943. */
  63944. targetFrameRate: number;
  63945. /**
  63946. * Gets or sets the current interval between two checks (every 2000ms by default)
  63947. */
  63948. /**
  63949. * Gets or sets the current interval between two checks (every 2000ms by default)
  63950. */
  63951. trackerDuration: number;
  63952. /**
  63953. * Gets the list of active optimizations
  63954. */
  63955. readonly optimizations: SceneOptimization[];
  63956. /**
  63957. * Creates a new SceneOptimizer
  63958. * @param scene defines the scene to work on
  63959. * @param options defines the options to use with the SceneOptimizer
  63960. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63961. * @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)
  63962. */
  63963. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63964. /**
  63965. * Stops the current optimizer
  63966. */
  63967. stop(): void;
  63968. /**
  63969. * Reset the optimizer to initial step (current priority level = 0)
  63970. */
  63971. reset(): void;
  63972. /**
  63973. * Start the optimizer. By default it will try to reach a specific framerate
  63974. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63975. */
  63976. start(): void;
  63977. private _checkCurrentState;
  63978. /**
  63979. * Release all resources
  63980. */
  63981. dispose(): void;
  63982. /**
  63983. * Helper function to create a SceneOptimizer with one single line of code
  63984. * @param scene defines the scene to work on
  63985. * @param options defines the options to use with the SceneOptimizer
  63986. * @param onSuccess defines a callback to call on success
  63987. * @param onFailure defines a callback to call on failure
  63988. * @returns the new SceneOptimizer object
  63989. */
  63990. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63991. }
  63992. }
  63993. declare module "babylonjs/Misc/sceneSerializer" {
  63994. import { Scene } from "babylonjs/scene";
  63995. /**
  63996. * Class used to serialize a scene into a string
  63997. */
  63998. export class SceneSerializer {
  63999. /**
  64000. * Clear cache used by a previous serialization
  64001. */
  64002. static ClearCache(): void;
  64003. /**
  64004. * Serialize a scene into a JSON compatible object
  64005. * @param scene defines the scene to serialize
  64006. * @returns a JSON compatible object
  64007. */
  64008. static Serialize(scene: Scene): any;
  64009. /**
  64010. * Serialize a mesh into a JSON compatible object
  64011. * @param toSerialize defines the mesh to serialize
  64012. * @param withParents defines if parents must be serialized as well
  64013. * @param withChildren defines if children must be serialized as well
  64014. * @returns a JSON compatible object
  64015. */
  64016. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64017. }
  64018. }
  64019. declare module "babylonjs/Misc/textureTools" {
  64020. import { Texture } from "babylonjs/Materials/Textures/texture";
  64021. /**
  64022. * Class used to host texture specific utilities
  64023. */
  64024. export class TextureTools {
  64025. /**
  64026. * Uses the GPU to create a copy texture rescaled at a given size
  64027. * @param texture Texture to copy from
  64028. * @param width defines the desired width
  64029. * @param height defines the desired height
  64030. * @param useBilinearMode defines if bilinear mode has to be used
  64031. * @return the generated texture
  64032. */
  64033. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64034. }
  64035. }
  64036. declare module "babylonjs/Misc/videoRecorder" {
  64037. import { Nullable } from "babylonjs/types";
  64038. import { Engine } from "babylonjs/Engines/engine";
  64039. /**
  64040. * This represents the different options available for the video capture.
  64041. */
  64042. export interface VideoRecorderOptions {
  64043. /** Defines the mime type of the video. */
  64044. mimeType: string;
  64045. /** Defines the FPS the video should be recorded at. */
  64046. fps: number;
  64047. /** Defines the chunk size for the recording data. */
  64048. recordChunckSize: number;
  64049. /** The audio tracks to attach to the recording. */
  64050. audioTracks?: MediaStreamTrack[];
  64051. }
  64052. /**
  64053. * This can help with recording videos from BabylonJS.
  64054. * This is based on the available WebRTC functionalities of the browser.
  64055. *
  64056. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64057. */
  64058. export class VideoRecorder {
  64059. private static readonly _defaultOptions;
  64060. /**
  64061. * Returns whether or not the VideoRecorder is available in your browser.
  64062. * @param engine Defines the Babylon Engine.
  64063. * @returns true if supported otherwise false.
  64064. */
  64065. static IsSupported(engine: Engine): boolean;
  64066. private readonly _options;
  64067. private _canvas;
  64068. private _mediaRecorder;
  64069. private _recordedChunks;
  64070. private _fileName;
  64071. private _resolve;
  64072. private _reject;
  64073. /**
  64074. * True when a recording is already in progress.
  64075. */
  64076. readonly isRecording: boolean;
  64077. /**
  64078. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64079. * @param engine Defines the BabylonJS Engine you wish to record.
  64080. * @param options Defines options that can be used to customize the capture.
  64081. */
  64082. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64083. /**
  64084. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64085. */
  64086. stopRecording(): void;
  64087. /**
  64088. * Starts recording the canvas for a max duration specified in parameters.
  64089. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64090. * If null no automatic download will start and you can rely on the promise to get the data back.
  64091. * @param maxDuration Defines the maximum recording time in seconds.
  64092. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64093. * @return A promise callback at the end of the recording with the video data in Blob.
  64094. */
  64095. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64096. /**
  64097. * Releases internal resources used during the recording.
  64098. */
  64099. dispose(): void;
  64100. private _handleDataAvailable;
  64101. private _handleError;
  64102. private _handleStop;
  64103. }
  64104. }
  64105. declare module "babylonjs/Misc/screenshotTools" {
  64106. import { Camera } from "babylonjs/Cameras/camera";
  64107. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  64108. import { Engine } from "babylonjs/Engines/engine";
  64109. /**
  64110. * Class containing a set of static utilities functions for screenshots
  64111. */
  64112. export class ScreenshotTools {
  64113. /**
  64114. * Captures a screenshot of the current rendering
  64115. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64116. * @param engine defines the rendering engine
  64117. * @param camera defines the source camera
  64118. * @param size This parameter can be set to a single number or to an object with the
  64119. * following (optional) properties: precision, width, height. If a single number is passed,
  64120. * it will be used for both width and height. If an object is passed, the screenshot size
  64121. * will be derived from the parameters. The precision property is a multiplier allowing
  64122. * rendering at a higher or lower resolution
  64123. * @param successCallback defines the callback receives a single parameter which contains the
  64124. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64125. * src parameter of an <img> to display it
  64126. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64127. * Check your browser for supported MIME types
  64128. */
  64129. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64130. /**
  64131. * Captures a screenshot of the current rendering
  64132. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64133. * @param engine defines the rendering engine
  64134. * @param camera defines the source camera
  64135. * @param size This parameter can be set to a single number or to an object with the
  64136. * following (optional) properties: precision, width, height. If a single number is passed,
  64137. * it will be used for both width and height. If an object is passed, the screenshot size
  64138. * will be derived from the parameters. The precision property is a multiplier allowing
  64139. * rendering at a higher or lower resolution
  64140. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64141. * Check your browser for supported MIME types
  64142. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64143. * to the src parameter of an <img> to display it
  64144. */
  64145. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64146. /**
  64147. * Generates an image screenshot from the specified camera.
  64148. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64149. * @param engine The engine to use for rendering
  64150. * @param camera The camera to use for rendering
  64151. * @param size This parameter can be set to a single number or to an object with the
  64152. * following (optional) properties: precision, width, height. If a single number is passed,
  64153. * it will be used for both width and height. If an object is passed, the screenshot size
  64154. * will be derived from the parameters. The precision property is a multiplier allowing
  64155. * rendering at a higher or lower resolution
  64156. * @param successCallback The callback receives a single parameter which contains the
  64157. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64158. * src parameter of an <img> to display it
  64159. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64160. * Check your browser for supported MIME types
  64161. * @param samples Texture samples (default: 1)
  64162. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64163. * @param fileName A name for for the downloaded file.
  64164. */
  64165. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64166. /**
  64167. * Generates an image screenshot from the specified camera.
  64168. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64169. * @param engine The engine to use for rendering
  64170. * @param camera The camera to use for rendering
  64171. * @param size This parameter can be set to a single number or to an object with the
  64172. * following (optional) properties: precision, width, height. If a single number is passed,
  64173. * it will be used for both width and height. If an object is passed, the screenshot size
  64174. * will be derived from the parameters. The precision property is a multiplier allowing
  64175. * rendering at a higher or lower resolution
  64176. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64177. * Check your browser for supported MIME types
  64178. * @param samples Texture samples (default: 1)
  64179. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64180. * @param fileName A name for for the downloaded file.
  64181. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64182. * to the src parameter of an <img> to display it
  64183. */
  64184. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64185. /**
  64186. * Gets height and width for screenshot size
  64187. * @private
  64188. */
  64189. private static _getScreenshotSize;
  64190. }
  64191. }
  64192. declare module "babylonjs/Misc/index" {
  64193. export * from "babylonjs/Misc/andOrNotEvaluator";
  64194. export * from "babylonjs/Misc/assetsManager";
  64195. export * from "babylonjs/Misc/dds";
  64196. export * from "babylonjs/Misc/decorators";
  64197. export * from "babylonjs/Misc/deferred";
  64198. export * from "babylonjs/Misc/environmentTextureTools";
  64199. export * from "babylonjs/Misc/meshExploder";
  64200. export * from "babylonjs/Misc/filesInput";
  64201. export * from "babylonjs/Misc/HighDynamicRange/index";
  64202. export * from "babylonjs/Misc/khronosTextureContainer";
  64203. export * from "babylonjs/Misc/observable";
  64204. export * from "babylonjs/Misc/performanceMonitor";
  64205. export * from "babylonjs/Misc/promise";
  64206. export * from "babylonjs/Misc/sceneOptimizer";
  64207. export * from "babylonjs/Misc/sceneSerializer";
  64208. export * from "babylonjs/Misc/smartArray";
  64209. export * from "babylonjs/Misc/stringDictionary";
  64210. export * from "babylonjs/Misc/tags";
  64211. export * from "babylonjs/Misc/textureTools";
  64212. export * from "babylonjs/Misc/tga";
  64213. export * from "babylonjs/Misc/tools";
  64214. export * from "babylonjs/Misc/videoRecorder";
  64215. export * from "babylonjs/Misc/virtualJoystick";
  64216. export * from "babylonjs/Misc/workerPool";
  64217. export * from "babylonjs/Misc/logger";
  64218. export * from "babylonjs/Misc/typeStore";
  64219. export * from "babylonjs/Misc/filesInputStore";
  64220. export * from "babylonjs/Misc/deepCopier";
  64221. export * from "babylonjs/Misc/pivotTools";
  64222. export * from "babylonjs/Misc/precisionDate";
  64223. export * from "babylonjs/Misc/screenshotTools";
  64224. export * from "babylonjs/Misc/typeStore";
  64225. export * from "babylonjs/Misc/webRequest";
  64226. export * from "babylonjs/Misc/iInspectable";
  64227. export * from "babylonjs/Misc/brdfTextureTools";
  64228. export * from "babylonjs/Misc/gradients";
  64229. export * from "babylonjs/Misc/perfCounter";
  64230. export * from "babylonjs/Misc/fileRequest";
  64231. export * from "babylonjs/Misc/customAnimationFrameRequester";
  64232. export * from "babylonjs/Misc/retryStrategy";
  64233. export * from "babylonjs/Misc/loadFileError";
  64234. }
  64235. declare module "babylonjs/index" {
  64236. export * from "babylonjs/abstractScene";
  64237. export * from "babylonjs/Actions/index";
  64238. export * from "babylonjs/Animations/index";
  64239. export * from "babylonjs/assetContainer";
  64240. export * from "babylonjs/Audio/index";
  64241. export * from "babylonjs/Behaviors/index";
  64242. export * from "babylonjs/Bones/index";
  64243. export * from "babylonjs/Cameras/index";
  64244. export * from "babylonjs/Collisions/index";
  64245. export * from "babylonjs/Culling/index";
  64246. export * from "babylonjs/Debug/index";
  64247. export * from "babylonjs/Engines/index";
  64248. export * from "babylonjs/Events/index";
  64249. export * from "babylonjs/Gamepads/index";
  64250. export * from "babylonjs/Gizmos/index";
  64251. export * from "babylonjs/Helpers/index";
  64252. export * from "babylonjs/Instrumentation/index";
  64253. export * from "babylonjs/Layers/index";
  64254. export * from "babylonjs/LensFlares/index";
  64255. export * from "babylonjs/Lights/index";
  64256. export * from "babylonjs/Loading/index";
  64257. export * from "babylonjs/Materials/index";
  64258. export * from "babylonjs/Maths/index";
  64259. export * from "babylonjs/Meshes/index";
  64260. export * from "babylonjs/Morph/index";
  64261. export * from "babylonjs/Navigation/index";
  64262. export * from "babylonjs/node";
  64263. export * from "babylonjs/Offline/index";
  64264. export * from "babylonjs/Particles/index";
  64265. export * from "babylonjs/Physics/index";
  64266. export * from "babylonjs/PostProcesses/index";
  64267. export * from "babylonjs/Probes/index";
  64268. export * from "babylonjs/Rendering/index";
  64269. export * from "babylonjs/scene";
  64270. export * from "babylonjs/sceneComponent";
  64271. export * from "babylonjs/Sprites/index";
  64272. export * from "babylonjs/States/index";
  64273. export * from "babylonjs/Misc/index";
  64274. export * from "babylonjs/types";
  64275. }
  64276. declare module "babylonjs/Animations/pathCursor" {
  64277. import { Vector3 } from "babylonjs/Maths/math.vector";
  64278. import { Path2 } from "babylonjs/Maths/math.path";
  64279. /**
  64280. * A cursor which tracks a point on a path
  64281. */
  64282. export class PathCursor {
  64283. private path;
  64284. /**
  64285. * Stores path cursor callbacks for when an onchange event is triggered
  64286. */
  64287. private _onchange;
  64288. /**
  64289. * The value of the path cursor
  64290. */
  64291. value: number;
  64292. /**
  64293. * The animation array of the path cursor
  64294. */
  64295. animations: Animation[];
  64296. /**
  64297. * Initializes the path cursor
  64298. * @param path The path to track
  64299. */
  64300. constructor(path: Path2);
  64301. /**
  64302. * Gets the cursor point on the path
  64303. * @returns A point on the path cursor at the cursor location
  64304. */
  64305. getPoint(): Vector3;
  64306. /**
  64307. * Moves the cursor ahead by the step amount
  64308. * @param step The amount to move the cursor forward
  64309. * @returns This path cursor
  64310. */
  64311. moveAhead(step?: number): PathCursor;
  64312. /**
  64313. * Moves the cursor behind by the step amount
  64314. * @param step The amount to move the cursor back
  64315. * @returns This path cursor
  64316. */
  64317. moveBack(step?: number): PathCursor;
  64318. /**
  64319. * Moves the cursor by the step amount
  64320. * If the step amount is greater than one, an exception is thrown
  64321. * @param step The amount to move the cursor
  64322. * @returns This path cursor
  64323. */
  64324. move(step: number): PathCursor;
  64325. /**
  64326. * Ensures that the value is limited between zero and one
  64327. * @returns This path cursor
  64328. */
  64329. private ensureLimits;
  64330. /**
  64331. * Runs onchange callbacks on change (used by the animation engine)
  64332. * @returns This path cursor
  64333. */
  64334. private raiseOnChange;
  64335. /**
  64336. * Executes a function on change
  64337. * @param f A path cursor onchange callback
  64338. * @returns This path cursor
  64339. */
  64340. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64341. }
  64342. }
  64343. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  64344. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  64345. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  64346. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  64347. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  64348. }
  64349. declare module "babylonjs/Engines/Processors/Expressions/index" {
  64350. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  64351. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  64352. }
  64353. declare module "babylonjs/Engines/Processors/index" {
  64354. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  64355. export * from "babylonjs/Engines/Processors/Expressions/index";
  64356. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  64357. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  64358. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  64359. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  64360. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  64361. export * from "babylonjs/Engines/Processors/shaderProcessor";
  64362. }
  64363. declare module "babylonjs/Legacy/legacy" {
  64364. import * as Babylon from "babylonjs/index";
  64365. export * from "babylonjs/index";
  64366. }
  64367. declare module "babylonjs/Shaders/blur.fragment" {
  64368. /** @hidden */
  64369. export var blurPixelShader: {
  64370. name: string;
  64371. shader: string;
  64372. };
  64373. }
  64374. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  64375. /** @hidden */
  64376. export var pointCloudVertexDeclaration: {
  64377. name: string;
  64378. shader: string;
  64379. };
  64380. }
  64381. declare module "babylonjs" {
  64382. export * from "babylonjs/Legacy/legacy";
  64383. }
  64384. declare module BABYLON {
  64385. /** Alias type for value that can be null */
  64386. export type Nullable<T> = T | null;
  64387. /**
  64388. * Alias type for number that are floats
  64389. * @ignorenaming
  64390. */
  64391. export type float = number;
  64392. /**
  64393. * Alias type for number that are doubles.
  64394. * @ignorenaming
  64395. */
  64396. export type double = number;
  64397. /**
  64398. * Alias type for number that are integer
  64399. * @ignorenaming
  64400. */
  64401. export type int = number;
  64402. /** Alias type for number array or Float32Array */
  64403. export type FloatArray = number[] | Float32Array;
  64404. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  64405. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  64406. /**
  64407. * Alias for types that can be used by a Buffer or VertexBuffer.
  64408. */
  64409. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  64410. /**
  64411. * Alias type for primitive types
  64412. * @ignorenaming
  64413. */
  64414. type Primitive = undefined | null | boolean | string | number | Function;
  64415. /**
  64416. * Type modifier to make all the properties of an object Readonly
  64417. */
  64418. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  64419. /**
  64420. * Type modifier to make all the properties of an object Readonly recursively
  64421. */
  64422. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  64423. /** @hidden */
  64424. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  64425. }
  64426. /** @hidden */
  64427. /** @hidden */
  64428. type DeepImmutableObject<T> = {
  64429. readonly [K in keyof T]: DeepImmutable<T[K]>;
  64430. };
  64431. }
  64432. declare module BABYLON {
  64433. /**
  64434. * A class serves as a medium between the observable and its observers
  64435. */
  64436. export class EventState {
  64437. /**
  64438. * Create a new EventState
  64439. * @param mask defines the mask associated with this state
  64440. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64441. * @param target defines the original target of the state
  64442. * @param currentTarget defines the current target of the state
  64443. */
  64444. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64445. /**
  64446. * Initialize the current event state
  64447. * @param mask defines the mask associated with this state
  64448. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64449. * @param target defines the original target of the state
  64450. * @param currentTarget defines the current target of the state
  64451. * @returns the current event state
  64452. */
  64453. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64454. /**
  64455. * An Observer can set this property to true to prevent subsequent observers of being notified
  64456. */
  64457. skipNextObservers: boolean;
  64458. /**
  64459. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64460. */
  64461. mask: number;
  64462. /**
  64463. * The object that originally notified the event
  64464. */
  64465. target?: any;
  64466. /**
  64467. * The current object in the bubbling phase
  64468. */
  64469. currentTarget?: any;
  64470. /**
  64471. * This will be populated with the return value of the last function that was executed.
  64472. * If it is the first function in the callback chain it will be the event data.
  64473. */
  64474. lastReturnValue?: any;
  64475. }
  64476. /**
  64477. * Represent an Observer registered to a given Observable object.
  64478. */
  64479. export class Observer<T> {
  64480. /**
  64481. * Defines the callback to call when the observer is notified
  64482. */
  64483. callback: (eventData: T, eventState: EventState) => void;
  64484. /**
  64485. * Defines the mask of the observer (used to filter notifications)
  64486. */
  64487. mask: number;
  64488. /**
  64489. * Defines the current scope used to restore the JS context
  64490. */
  64491. scope: any;
  64492. /** @hidden */
  64493. _willBeUnregistered: boolean;
  64494. /**
  64495. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64496. */
  64497. unregisterOnNextCall: boolean;
  64498. /**
  64499. * Creates a new observer
  64500. * @param callback defines the callback to call when the observer is notified
  64501. * @param mask defines the mask of the observer (used to filter notifications)
  64502. * @param scope defines the current scope used to restore the JS context
  64503. */
  64504. constructor(
  64505. /**
  64506. * Defines the callback to call when the observer is notified
  64507. */
  64508. callback: (eventData: T, eventState: EventState) => void,
  64509. /**
  64510. * Defines the mask of the observer (used to filter notifications)
  64511. */
  64512. mask: number,
  64513. /**
  64514. * Defines the current scope used to restore the JS context
  64515. */
  64516. scope?: any);
  64517. }
  64518. /**
  64519. * Represent a list of observers registered to multiple Observables object.
  64520. */
  64521. export class MultiObserver<T> {
  64522. private _observers;
  64523. private _observables;
  64524. /**
  64525. * Release associated resources
  64526. */
  64527. dispose(): void;
  64528. /**
  64529. * Raise a callback when one of the observable will notify
  64530. * @param observables defines a list of observables to watch
  64531. * @param callback defines the callback to call on notification
  64532. * @param mask defines the mask used to filter notifications
  64533. * @param scope defines the current scope used to restore the JS context
  64534. * @returns the new MultiObserver
  64535. */
  64536. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64537. }
  64538. /**
  64539. * The Observable class is a simple implementation of the Observable pattern.
  64540. *
  64541. * 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.
  64542. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64543. * 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).
  64544. * 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.
  64545. */
  64546. export class Observable<T> {
  64547. private _observers;
  64548. private _eventState;
  64549. private _onObserverAdded;
  64550. /**
  64551. * Gets the list of observers
  64552. */
  64553. readonly observers: Array<Observer<T>>;
  64554. /**
  64555. * Creates a new observable
  64556. * @param onObserverAdded defines a callback to call when a new observer is added
  64557. */
  64558. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64559. /**
  64560. * Create a new Observer with the specified callback
  64561. * @param callback the callback that will be executed for that Observer
  64562. * @param mask the mask used to filter observers
  64563. * @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.
  64564. * @param scope optional scope for the callback to be called from
  64565. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64566. * @returns the new observer created for the callback
  64567. */
  64568. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64569. /**
  64570. * Create a new Observer with the specified callback and unregisters after the next notification
  64571. * @param callback the callback that will be executed for that Observer
  64572. * @returns the new observer created for the callback
  64573. */
  64574. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64575. /**
  64576. * Remove an Observer from the Observable object
  64577. * @param observer the instance of the Observer to remove
  64578. * @returns false if it doesn't belong to this Observable
  64579. */
  64580. remove(observer: Nullable<Observer<T>>): boolean;
  64581. /**
  64582. * Remove a callback from the Observable object
  64583. * @param callback the callback to remove
  64584. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64585. * @returns false if it doesn't belong to this Observable
  64586. */
  64587. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64588. private _deferUnregister;
  64589. private _remove;
  64590. /**
  64591. * Moves the observable to the top of the observer list making it get called first when notified
  64592. * @param observer the observer to move
  64593. */
  64594. makeObserverTopPriority(observer: Observer<T>): void;
  64595. /**
  64596. * Moves the observable to the bottom of the observer list making it get called last when notified
  64597. * @param observer the observer to move
  64598. */
  64599. makeObserverBottomPriority(observer: Observer<T>): void;
  64600. /**
  64601. * Notify all Observers by calling their respective callback with the given data
  64602. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64603. * @param eventData defines the data to send to all observers
  64604. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64605. * @param target defines the original target of the state
  64606. * @param currentTarget defines the current target of the state
  64607. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64608. */
  64609. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64610. /**
  64611. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64612. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64613. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64614. * and it is crucial that all callbacks will be executed.
  64615. * The order of the callbacks is kept, callbacks are not executed parallel.
  64616. *
  64617. * @param eventData The data to be sent to each callback
  64618. * @param mask is used to filter observers defaults to -1
  64619. * @param target defines the callback target (see EventState)
  64620. * @param currentTarget defines he current object in the bubbling phase
  64621. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64622. */
  64623. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64624. /**
  64625. * Notify a specific observer
  64626. * @param observer defines the observer to notify
  64627. * @param eventData defines the data to be sent to each callback
  64628. * @param mask is used to filter observers defaults to -1
  64629. */
  64630. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64631. /**
  64632. * Gets a boolean indicating if the observable has at least one observer
  64633. * @returns true is the Observable has at least one Observer registered
  64634. */
  64635. hasObservers(): boolean;
  64636. /**
  64637. * Clear the list of observers
  64638. */
  64639. clear(): void;
  64640. /**
  64641. * Clone the current observable
  64642. * @returns a new observable
  64643. */
  64644. clone(): Observable<T>;
  64645. /**
  64646. * Does this observable handles observer registered with a given mask
  64647. * @param mask defines the mask to be tested
  64648. * @return whether or not one observer registered with the given mask is handeled
  64649. **/
  64650. hasSpecificMask(mask?: number): boolean;
  64651. }
  64652. }
  64653. declare module BABYLON {
  64654. /**
  64655. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64656. * Babylon.js
  64657. */
  64658. export class DomManagement {
  64659. /**
  64660. * Checks if the window object exists
  64661. * @returns true if the window object exists
  64662. */
  64663. static IsWindowObjectExist(): boolean;
  64664. /**
  64665. * Extracts text content from a DOM element hierarchy
  64666. * @param element defines the root element
  64667. * @returns a string
  64668. */
  64669. static GetDOMTextContent(element: HTMLElement): string;
  64670. }
  64671. }
  64672. declare module BABYLON {
  64673. /**
  64674. * Logger used througouht the application to allow configuration of
  64675. * the log level required for the messages.
  64676. */
  64677. export class Logger {
  64678. /**
  64679. * No log
  64680. */
  64681. static readonly NoneLogLevel: number;
  64682. /**
  64683. * Only message logs
  64684. */
  64685. static readonly MessageLogLevel: number;
  64686. /**
  64687. * Only warning logs
  64688. */
  64689. static readonly WarningLogLevel: number;
  64690. /**
  64691. * Only error logs
  64692. */
  64693. static readonly ErrorLogLevel: number;
  64694. /**
  64695. * All logs
  64696. */
  64697. static readonly AllLogLevel: number;
  64698. private static _LogCache;
  64699. /**
  64700. * Gets a value indicating the number of loading errors
  64701. * @ignorenaming
  64702. */
  64703. static errorsCount: number;
  64704. /**
  64705. * Callback called when a new log is added
  64706. */
  64707. static OnNewCacheEntry: (entry: string) => void;
  64708. private static _AddLogEntry;
  64709. private static _FormatMessage;
  64710. private static _LogDisabled;
  64711. private static _LogEnabled;
  64712. private static _WarnDisabled;
  64713. private static _WarnEnabled;
  64714. private static _ErrorDisabled;
  64715. private static _ErrorEnabled;
  64716. /**
  64717. * Log a message to the console
  64718. */
  64719. static Log: (message: string) => void;
  64720. /**
  64721. * Write a warning message to the console
  64722. */
  64723. static Warn: (message: string) => void;
  64724. /**
  64725. * Write an error message to the console
  64726. */
  64727. static Error: (message: string) => void;
  64728. /**
  64729. * Gets current log cache (list of logs)
  64730. */
  64731. static readonly LogCache: string;
  64732. /**
  64733. * Clears the log cache
  64734. */
  64735. static ClearLogCache(): void;
  64736. /**
  64737. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64738. */
  64739. static LogLevels: number;
  64740. }
  64741. }
  64742. declare module BABYLON {
  64743. /** @hidden */
  64744. export class _TypeStore {
  64745. /** @hidden */
  64746. static RegisteredTypes: {
  64747. [key: string]: Object;
  64748. };
  64749. /** @hidden */
  64750. static GetClass(fqdn: string): any;
  64751. }
  64752. }
  64753. declare module BABYLON {
  64754. /**
  64755. * Class containing a set of static utilities functions for deep copy.
  64756. */
  64757. export class DeepCopier {
  64758. /**
  64759. * Tries to copy an object by duplicating every property
  64760. * @param source defines the source object
  64761. * @param destination defines the target object
  64762. * @param doNotCopyList defines a list of properties to avoid
  64763. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64764. */
  64765. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64766. }
  64767. }
  64768. declare module BABYLON {
  64769. /**
  64770. * Class containing a set of static utilities functions for precision date
  64771. */
  64772. export class PrecisionDate {
  64773. /**
  64774. * Gets either window.performance.now() if supported or Date.now() else
  64775. */
  64776. static readonly Now: number;
  64777. }
  64778. }
  64779. declare module BABYLON {
  64780. /** @hidden */
  64781. export class _DevTools {
  64782. static WarnImport(name: string): string;
  64783. }
  64784. }
  64785. declare module BABYLON {
  64786. /**
  64787. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64788. */
  64789. export class WebRequest {
  64790. private _xhr;
  64791. /**
  64792. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64793. * i.e. when loading files, where the server/service expects an Authorization header
  64794. */
  64795. static CustomRequestHeaders: {
  64796. [key: string]: string;
  64797. };
  64798. /**
  64799. * Add callback functions in this array to update all the requests before they get sent to the network
  64800. */
  64801. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64802. private _injectCustomRequestHeaders;
  64803. /**
  64804. * Gets or sets a function to be called when loading progress changes
  64805. */
  64806. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64807. /**
  64808. * Returns client's state
  64809. */
  64810. readonly readyState: number;
  64811. /**
  64812. * Returns client's status
  64813. */
  64814. readonly status: number;
  64815. /**
  64816. * Returns client's status as a text
  64817. */
  64818. readonly statusText: string;
  64819. /**
  64820. * Returns client's response
  64821. */
  64822. readonly response: any;
  64823. /**
  64824. * Returns client's response url
  64825. */
  64826. readonly responseURL: string;
  64827. /**
  64828. * Returns client's response as text
  64829. */
  64830. readonly responseText: string;
  64831. /**
  64832. * Gets or sets the expected response type
  64833. */
  64834. responseType: XMLHttpRequestResponseType;
  64835. /** @hidden */
  64836. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64837. /** @hidden */
  64838. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64839. /**
  64840. * Cancels any network activity
  64841. */
  64842. abort(): void;
  64843. /**
  64844. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64845. * @param body defines an optional request body
  64846. */
  64847. send(body?: Document | BodyInit | null): void;
  64848. /**
  64849. * Sets the request method, request URL
  64850. * @param method defines the method to use (GET, POST, etc..)
  64851. * @param url defines the url to connect with
  64852. */
  64853. open(method: string, url: string): void;
  64854. }
  64855. }
  64856. declare module BABYLON {
  64857. /**
  64858. * File request interface
  64859. */
  64860. export interface IFileRequest {
  64861. /**
  64862. * Raised when the request is complete (success or error).
  64863. */
  64864. onCompleteObservable: Observable<IFileRequest>;
  64865. /**
  64866. * Aborts the request for a file.
  64867. */
  64868. abort: () => void;
  64869. }
  64870. }
  64871. declare module BABYLON {
  64872. /**
  64873. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64874. */
  64875. export class PerformanceMonitor {
  64876. private _enabled;
  64877. private _rollingFrameTime;
  64878. private _lastFrameTimeMs;
  64879. /**
  64880. * constructor
  64881. * @param frameSampleSize The number of samples required to saturate the sliding window
  64882. */
  64883. constructor(frameSampleSize?: number);
  64884. /**
  64885. * Samples current frame
  64886. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64887. */
  64888. sampleFrame(timeMs?: number): void;
  64889. /**
  64890. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64891. */
  64892. readonly averageFrameTime: number;
  64893. /**
  64894. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64895. */
  64896. readonly averageFrameTimeVariance: number;
  64897. /**
  64898. * Returns the frame time of the most recent frame
  64899. */
  64900. readonly instantaneousFrameTime: number;
  64901. /**
  64902. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64903. */
  64904. readonly averageFPS: number;
  64905. /**
  64906. * Returns the average framerate in frames per second using the most recent frame time
  64907. */
  64908. readonly instantaneousFPS: number;
  64909. /**
  64910. * Returns true if enough samples have been taken to completely fill the sliding window
  64911. */
  64912. readonly isSaturated: boolean;
  64913. /**
  64914. * Enables contributions to the sliding window sample set
  64915. */
  64916. enable(): void;
  64917. /**
  64918. * Disables contributions to the sliding window sample set
  64919. * Samples will not be interpolated over the disabled period
  64920. */
  64921. disable(): void;
  64922. /**
  64923. * Returns true if sampling is enabled
  64924. */
  64925. readonly isEnabled: boolean;
  64926. /**
  64927. * Resets performance monitor
  64928. */
  64929. reset(): void;
  64930. }
  64931. /**
  64932. * RollingAverage
  64933. *
  64934. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64935. */
  64936. export class RollingAverage {
  64937. /**
  64938. * Current average
  64939. */
  64940. average: number;
  64941. /**
  64942. * Current variance
  64943. */
  64944. variance: number;
  64945. protected _samples: Array<number>;
  64946. protected _sampleCount: number;
  64947. protected _pos: number;
  64948. protected _m2: number;
  64949. /**
  64950. * constructor
  64951. * @param length The number of samples required to saturate the sliding window
  64952. */
  64953. constructor(length: number);
  64954. /**
  64955. * Adds a sample to the sample set
  64956. * @param v The sample value
  64957. */
  64958. add(v: number): void;
  64959. /**
  64960. * Returns previously added values or null if outside of history or outside the sliding window domain
  64961. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64962. * @return Value previously recorded with add() or null if outside of range
  64963. */
  64964. history(i: number): number;
  64965. /**
  64966. * Returns true if enough samples have been taken to completely fill the sliding window
  64967. * @return true if sample-set saturated
  64968. */
  64969. isSaturated(): boolean;
  64970. /**
  64971. * Resets the rolling average (equivalent to 0 samples taken so far)
  64972. */
  64973. reset(): void;
  64974. /**
  64975. * Wraps a value around the sample range boundaries
  64976. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64977. * @return Wrapped position in sample range
  64978. */
  64979. protected _wrapPosition(i: number): number;
  64980. }
  64981. }
  64982. declare module BABYLON {
  64983. /**
  64984. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64985. * The underlying implementation relies on an associative array to ensure the best performances.
  64986. * The value can be anything including 'null' but except 'undefined'
  64987. */
  64988. export class StringDictionary<T> {
  64989. /**
  64990. * This will clear this dictionary and copy the content from the 'source' one.
  64991. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64992. * @param source the dictionary to take the content from and copy to this dictionary
  64993. */
  64994. copyFrom(source: StringDictionary<T>): void;
  64995. /**
  64996. * Get a value based from its key
  64997. * @param key the given key to get the matching value from
  64998. * @return the value if found, otherwise undefined is returned
  64999. */
  65000. get(key: string): T | undefined;
  65001. /**
  65002. * Get a value from its key or add it if it doesn't exist.
  65003. * This method will ensure you that a given key/data will be present in the dictionary.
  65004. * @param key the given key to get the matching value from
  65005. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65006. * The factory will only be invoked if there's no data for the given key.
  65007. * @return the value corresponding to the key.
  65008. */
  65009. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65010. /**
  65011. * Get a value from its key if present in the dictionary otherwise add it
  65012. * @param key the key to get the value from
  65013. * @param val if there's no such key/value pair in the dictionary add it with this value
  65014. * @return the value corresponding to the key
  65015. */
  65016. getOrAdd(key: string, val: T): T;
  65017. /**
  65018. * Check if there's a given key in the dictionary
  65019. * @param key the key to check for
  65020. * @return true if the key is present, false otherwise
  65021. */
  65022. contains(key: string): boolean;
  65023. /**
  65024. * Add a new key and its corresponding value
  65025. * @param key the key to add
  65026. * @param value the value corresponding to the key
  65027. * @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
  65028. */
  65029. add(key: string, value: T): boolean;
  65030. /**
  65031. * Update a specific value associated to a key
  65032. * @param key defines the key to use
  65033. * @param value defines the value to store
  65034. * @returns true if the value was updated (or false if the key was not found)
  65035. */
  65036. set(key: string, value: T): boolean;
  65037. /**
  65038. * Get the element of the given key and remove it from the dictionary
  65039. * @param key defines the key to search
  65040. * @returns the value associated with the key or null if not found
  65041. */
  65042. getAndRemove(key: string): Nullable<T>;
  65043. /**
  65044. * Remove a key/value from the dictionary.
  65045. * @param key the key to remove
  65046. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65047. */
  65048. remove(key: string): boolean;
  65049. /**
  65050. * Clear the whole content of the dictionary
  65051. */
  65052. clear(): void;
  65053. /**
  65054. * Gets the current count
  65055. */
  65056. readonly count: number;
  65057. /**
  65058. * Execute a callback on each key/val of the dictionary.
  65059. * Note that you can remove any element in this dictionary in the callback implementation
  65060. * @param callback the callback to execute on a given key/value pair
  65061. */
  65062. forEach(callback: (key: string, val: T) => void): void;
  65063. /**
  65064. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65065. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65066. * Note that you can remove any element in this dictionary in the callback implementation
  65067. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65068. * @returns the first item
  65069. */
  65070. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65071. private _count;
  65072. private _data;
  65073. }
  65074. }
  65075. declare module BABYLON {
  65076. /**
  65077. * Class used to store gfx data (like WebGLBuffer)
  65078. */
  65079. export class DataBuffer {
  65080. /**
  65081. * Gets or sets the number of objects referencing this buffer
  65082. */
  65083. references: number;
  65084. /** Gets or sets the size of the underlying buffer */
  65085. capacity: number;
  65086. /**
  65087. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65088. */
  65089. is32Bits: boolean;
  65090. /**
  65091. * Gets the underlying buffer
  65092. */
  65093. readonly underlyingResource: any;
  65094. }
  65095. }
  65096. declare module BABYLON {
  65097. /**
  65098. * Class used to store data that will be store in GPU memory
  65099. */
  65100. export class Buffer {
  65101. private _engine;
  65102. private _buffer;
  65103. /** @hidden */
  65104. _data: Nullable<DataArray>;
  65105. private _updatable;
  65106. private _instanced;
  65107. /**
  65108. * Gets the byte stride.
  65109. */
  65110. readonly byteStride: number;
  65111. /**
  65112. * Constructor
  65113. * @param engine the engine
  65114. * @param data the data to use for this buffer
  65115. * @param updatable whether the data is updatable
  65116. * @param stride the stride (optional)
  65117. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65118. * @param instanced whether the buffer is instanced (optional)
  65119. * @param useBytes set to true if the stride in in bytes (optional)
  65120. */
  65121. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65122. /**
  65123. * Create a new VertexBuffer based on the current buffer
  65124. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65125. * @param offset defines offset in the buffer (0 by default)
  65126. * @param size defines the size in floats of attributes (position is 3 for instance)
  65127. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65128. * @param instanced defines if the vertex buffer contains indexed data
  65129. * @param useBytes defines if the offset and stride are in bytes
  65130. * @returns the new vertex buffer
  65131. */
  65132. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65133. /**
  65134. * Gets a boolean indicating if the Buffer is updatable?
  65135. * @returns true if the buffer is updatable
  65136. */
  65137. isUpdatable(): boolean;
  65138. /**
  65139. * Gets current buffer's data
  65140. * @returns a DataArray or null
  65141. */
  65142. getData(): Nullable<DataArray>;
  65143. /**
  65144. * Gets underlying native buffer
  65145. * @returns underlying native buffer
  65146. */
  65147. getBuffer(): Nullable<DataBuffer>;
  65148. /**
  65149. * Gets the stride in float32 units (i.e. byte stride / 4).
  65150. * May not be an integer if the byte stride is not divisible by 4.
  65151. * DEPRECATED. Use byteStride instead.
  65152. * @returns the stride in float32 units
  65153. */
  65154. getStrideSize(): number;
  65155. /**
  65156. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65157. * @param data defines the data to store
  65158. */
  65159. create(data?: Nullable<DataArray>): void;
  65160. /** @hidden */
  65161. _rebuild(): void;
  65162. /**
  65163. * Update current buffer data
  65164. * @param data defines the data to store
  65165. */
  65166. update(data: DataArray): void;
  65167. /**
  65168. * Updates the data directly.
  65169. * @param data the new data
  65170. * @param offset the new offset
  65171. * @param vertexCount the vertex count (optional)
  65172. * @param useBytes set to true if the offset is in bytes
  65173. */
  65174. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65175. /**
  65176. * Release all resources
  65177. */
  65178. dispose(): void;
  65179. }
  65180. /**
  65181. * Specialized buffer used to store vertex data
  65182. */
  65183. export class VertexBuffer {
  65184. /** @hidden */
  65185. _buffer: Buffer;
  65186. private _kind;
  65187. private _size;
  65188. private _ownsBuffer;
  65189. private _instanced;
  65190. private _instanceDivisor;
  65191. /**
  65192. * The byte type.
  65193. */
  65194. static readonly BYTE: number;
  65195. /**
  65196. * The unsigned byte type.
  65197. */
  65198. static readonly UNSIGNED_BYTE: number;
  65199. /**
  65200. * The short type.
  65201. */
  65202. static readonly SHORT: number;
  65203. /**
  65204. * The unsigned short type.
  65205. */
  65206. static readonly UNSIGNED_SHORT: number;
  65207. /**
  65208. * The integer type.
  65209. */
  65210. static readonly INT: number;
  65211. /**
  65212. * The unsigned integer type.
  65213. */
  65214. static readonly UNSIGNED_INT: number;
  65215. /**
  65216. * The float type.
  65217. */
  65218. static readonly FLOAT: number;
  65219. /**
  65220. * Gets or sets the instance divisor when in instanced mode
  65221. */
  65222. instanceDivisor: number;
  65223. /**
  65224. * Gets the byte stride.
  65225. */
  65226. readonly byteStride: number;
  65227. /**
  65228. * Gets the byte offset.
  65229. */
  65230. readonly byteOffset: number;
  65231. /**
  65232. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65233. */
  65234. readonly normalized: boolean;
  65235. /**
  65236. * Gets the data type of each component in the array.
  65237. */
  65238. readonly type: number;
  65239. /**
  65240. * Constructor
  65241. * @param engine the engine
  65242. * @param data the data to use for this vertex buffer
  65243. * @param kind the vertex buffer kind
  65244. * @param updatable whether the data is updatable
  65245. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65246. * @param stride the stride (optional)
  65247. * @param instanced whether the buffer is instanced (optional)
  65248. * @param offset the offset of the data (optional)
  65249. * @param size the number of components (optional)
  65250. * @param type the type of the component (optional)
  65251. * @param normalized whether the data contains normalized data (optional)
  65252. * @param useBytes set to true if stride and offset are in bytes (optional)
  65253. */
  65254. 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);
  65255. /** @hidden */
  65256. _rebuild(): void;
  65257. /**
  65258. * Returns the kind of the VertexBuffer (string)
  65259. * @returns a string
  65260. */
  65261. getKind(): string;
  65262. /**
  65263. * Gets a boolean indicating if the VertexBuffer is updatable?
  65264. * @returns true if the buffer is updatable
  65265. */
  65266. isUpdatable(): boolean;
  65267. /**
  65268. * Gets current buffer's data
  65269. * @returns a DataArray or null
  65270. */
  65271. getData(): Nullable<DataArray>;
  65272. /**
  65273. * Gets underlying native buffer
  65274. * @returns underlying native buffer
  65275. */
  65276. getBuffer(): Nullable<DataBuffer>;
  65277. /**
  65278. * Gets the stride in float32 units (i.e. byte stride / 4).
  65279. * May not be an integer if the byte stride is not divisible by 4.
  65280. * DEPRECATED. Use byteStride instead.
  65281. * @returns the stride in float32 units
  65282. */
  65283. getStrideSize(): number;
  65284. /**
  65285. * Returns the offset as a multiple of the type byte length.
  65286. * DEPRECATED. Use byteOffset instead.
  65287. * @returns the offset in bytes
  65288. */
  65289. getOffset(): number;
  65290. /**
  65291. * Returns the number of components per vertex attribute (integer)
  65292. * @returns the size in float
  65293. */
  65294. getSize(): number;
  65295. /**
  65296. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65297. * @returns true if this buffer is instanced
  65298. */
  65299. getIsInstanced(): boolean;
  65300. /**
  65301. * Returns the instancing divisor, zero for non-instanced (integer).
  65302. * @returns a number
  65303. */
  65304. getInstanceDivisor(): number;
  65305. /**
  65306. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65307. * @param data defines the data to store
  65308. */
  65309. create(data?: DataArray): void;
  65310. /**
  65311. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65312. * This function will create a new buffer if the current one is not updatable
  65313. * @param data defines the data to store
  65314. */
  65315. update(data: DataArray): void;
  65316. /**
  65317. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65318. * Returns the directly updated WebGLBuffer.
  65319. * @param data the new data
  65320. * @param offset the new offset
  65321. * @param useBytes set to true if the offset is in bytes
  65322. */
  65323. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65324. /**
  65325. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65326. */
  65327. dispose(): void;
  65328. /**
  65329. * Enumerates each value of this vertex buffer as numbers.
  65330. * @param count the number of values to enumerate
  65331. * @param callback the callback function called for each value
  65332. */
  65333. forEach(count: number, callback: (value: number, index: number) => void): void;
  65334. /**
  65335. * Positions
  65336. */
  65337. static readonly PositionKind: string;
  65338. /**
  65339. * Normals
  65340. */
  65341. static readonly NormalKind: string;
  65342. /**
  65343. * Tangents
  65344. */
  65345. static readonly TangentKind: string;
  65346. /**
  65347. * Texture coordinates
  65348. */
  65349. static readonly UVKind: string;
  65350. /**
  65351. * Texture coordinates 2
  65352. */
  65353. static readonly UV2Kind: string;
  65354. /**
  65355. * Texture coordinates 3
  65356. */
  65357. static readonly UV3Kind: string;
  65358. /**
  65359. * Texture coordinates 4
  65360. */
  65361. static readonly UV4Kind: string;
  65362. /**
  65363. * Texture coordinates 5
  65364. */
  65365. static readonly UV5Kind: string;
  65366. /**
  65367. * Texture coordinates 6
  65368. */
  65369. static readonly UV6Kind: string;
  65370. /**
  65371. * Colors
  65372. */
  65373. static readonly ColorKind: string;
  65374. /**
  65375. * Matrix indices (for bones)
  65376. */
  65377. static readonly MatricesIndicesKind: string;
  65378. /**
  65379. * Matrix weights (for bones)
  65380. */
  65381. static readonly MatricesWeightsKind: string;
  65382. /**
  65383. * Additional matrix indices (for bones)
  65384. */
  65385. static readonly MatricesIndicesExtraKind: string;
  65386. /**
  65387. * Additional matrix weights (for bones)
  65388. */
  65389. static readonly MatricesWeightsExtraKind: string;
  65390. /**
  65391. * Deduces the stride given a kind.
  65392. * @param kind The kind string to deduce
  65393. * @returns The deduced stride
  65394. */
  65395. static DeduceStride(kind: string): number;
  65396. /**
  65397. * Gets the byte length of the given type.
  65398. * @param type the type
  65399. * @returns the number of bytes
  65400. */
  65401. static GetTypeByteLength(type: number): number;
  65402. /**
  65403. * Enumerates each value of the given parameters as numbers.
  65404. * @param data the data to enumerate
  65405. * @param byteOffset the byte offset of the data
  65406. * @param byteStride the byte stride of the data
  65407. * @param componentCount the number of components per element
  65408. * @param componentType the type of the component
  65409. * @param count the number of values to enumerate
  65410. * @param normalized whether the data is normalized
  65411. * @param callback the callback function called for each value
  65412. */
  65413. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65414. private static _GetFloatValue;
  65415. }
  65416. }
  65417. declare module BABYLON {
  65418. /**
  65419. * Scalar computation library
  65420. */
  65421. export class Scalar {
  65422. /**
  65423. * Two pi constants convenient for computation.
  65424. */
  65425. static TwoPi: number;
  65426. /**
  65427. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65428. * @param a number
  65429. * @param b number
  65430. * @param epsilon (default = 1.401298E-45)
  65431. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65432. */
  65433. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  65434. /**
  65435. * Returns a string : the upper case translation of the number i to hexadecimal.
  65436. * @param i number
  65437. * @returns the upper case translation of the number i to hexadecimal.
  65438. */
  65439. static ToHex(i: number): string;
  65440. /**
  65441. * Returns -1 if value is negative and +1 is value is positive.
  65442. * @param value the value
  65443. * @returns the value itself if it's equal to zero.
  65444. */
  65445. static Sign(value: number): number;
  65446. /**
  65447. * Returns the value itself if it's between min and max.
  65448. * Returns min if the value is lower than min.
  65449. * Returns max if the value is greater than max.
  65450. * @param value the value to clmap
  65451. * @param min the min value to clamp to (default: 0)
  65452. * @param max the max value to clamp to (default: 1)
  65453. * @returns the clamped value
  65454. */
  65455. static Clamp(value: number, min?: number, max?: number): number;
  65456. /**
  65457. * the log2 of value.
  65458. * @param value the value to compute log2 of
  65459. * @returns the log2 of value.
  65460. */
  65461. static Log2(value: number): number;
  65462. /**
  65463. * Loops the value, so that it is never larger than length and never smaller than 0.
  65464. *
  65465. * This is similar to the modulo operator but it works with floating point numbers.
  65466. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  65467. * With t = 5 and length = 2.5, the result would be 0.0.
  65468. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  65469. * @param value the value
  65470. * @param length the length
  65471. * @returns the looped value
  65472. */
  65473. static Repeat(value: number, length: number): number;
  65474. /**
  65475. * Normalize the value between 0.0 and 1.0 using min and max values
  65476. * @param value value to normalize
  65477. * @param min max to normalize between
  65478. * @param max min to normalize between
  65479. * @returns the normalized value
  65480. */
  65481. static Normalize(value: number, min: number, max: number): number;
  65482. /**
  65483. * Denormalize the value from 0.0 and 1.0 using min and max values
  65484. * @param normalized value to denormalize
  65485. * @param min max to denormalize between
  65486. * @param max min to denormalize between
  65487. * @returns the denormalized value
  65488. */
  65489. static Denormalize(normalized: number, min: number, max: number): number;
  65490. /**
  65491. * Calculates the shortest difference between two given angles given in degrees.
  65492. * @param current current angle in degrees
  65493. * @param target target angle in degrees
  65494. * @returns the delta
  65495. */
  65496. static DeltaAngle(current: number, target: number): number;
  65497. /**
  65498. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  65499. * @param tx value
  65500. * @param length length
  65501. * @returns The returned value will move back and forth between 0 and length
  65502. */
  65503. static PingPong(tx: number, length: number): number;
  65504. /**
  65505. * Interpolates between min and max with smoothing at the limits.
  65506. *
  65507. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  65508. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  65509. * @param from from
  65510. * @param to to
  65511. * @param tx value
  65512. * @returns the smooth stepped value
  65513. */
  65514. static SmoothStep(from: number, to: number, tx: number): number;
  65515. /**
  65516. * Moves a value current towards target.
  65517. *
  65518. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  65519. * Negative values of maxDelta pushes the value away from target.
  65520. * @param current current value
  65521. * @param target target value
  65522. * @param maxDelta max distance to move
  65523. * @returns resulting value
  65524. */
  65525. static MoveTowards(current: number, target: number, maxDelta: number): number;
  65526. /**
  65527. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65528. *
  65529. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  65530. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  65531. * @param current current value
  65532. * @param target target value
  65533. * @param maxDelta max distance to move
  65534. * @returns resulting angle
  65535. */
  65536. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  65537. /**
  65538. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  65539. * @param start start value
  65540. * @param end target value
  65541. * @param amount amount to lerp between
  65542. * @returns the lerped value
  65543. */
  65544. static Lerp(start: number, end: number, amount: number): number;
  65545. /**
  65546. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65547. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  65548. * @param start start value
  65549. * @param end target value
  65550. * @param amount amount to lerp between
  65551. * @returns the lerped value
  65552. */
  65553. static LerpAngle(start: number, end: number, amount: number): number;
  65554. /**
  65555. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  65556. * @param a start value
  65557. * @param b target value
  65558. * @param value value between a and b
  65559. * @returns the inverseLerp value
  65560. */
  65561. static InverseLerp(a: number, b: number, value: number): number;
  65562. /**
  65563. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  65564. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  65565. * @param value1 spline value
  65566. * @param tangent1 spline value
  65567. * @param value2 spline value
  65568. * @param tangent2 spline value
  65569. * @param amount input value
  65570. * @returns hermite result
  65571. */
  65572. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  65573. /**
  65574. * Returns a random float number between and min and max values
  65575. * @param min min value of random
  65576. * @param max max value of random
  65577. * @returns random value
  65578. */
  65579. static RandomRange(min: number, max: number): number;
  65580. /**
  65581. * This function returns percentage of a number in a given range.
  65582. *
  65583. * RangeToPercent(40,20,60) will return 0.5 (50%)
  65584. * RangeToPercent(34,0,100) will return 0.34 (34%)
  65585. * @param number to convert to percentage
  65586. * @param min min range
  65587. * @param max max range
  65588. * @returns the percentage
  65589. */
  65590. static RangeToPercent(number: number, min: number, max: number): number;
  65591. /**
  65592. * This function returns number that corresponds to the percentage in a given range.
  65593. *
  65594. * PercentToRange(0.34,0,100) will return 34.
  65595. * @param percent to convert to number
  65596. * @param min min range
  65597. * @param max max range
  65598. * @returns the number
  65599. */
  65600. static PercentToRange(percent: number, min: number, max: number): number;
  65601. /**
  65602. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  65603. * @param angle The angle to normalize in radian.
  65604. * @return The converted angle.
  65605. */
  65606. static NormalizeRadians(angle: number): number;
  65607. }
  65608. }
  65609. declare module BABYLON {
  65610. /**
  65611. * Constant used to convert a value to gamma space
  65612. * @ignorenaming
  65613. */
  65614. export const ToGammaSpace: number;
  65615. /**
  65616. * Constant used to convert a value to linear space
  65617. * @ignorenaming
  65618. */
  65619. export const ToLinearSpace = 2.2;
  65620. /**
  65621. * Constant used to define the minimal number value in Babylon.js
  65622. * @ignorenaming
  65623. */
  65624. let Epsilon: number;
  65625. }
  65626. declare module BABYLON {
  65627. /**
  65628. * Class used to represent a viewport on screen
  65629. */
  65630. export class Viewport {
  65631. /** viewport left coordinate */
  65632. x: number;
  65633. /** viewport top coordinate */
  65634. y: number;
  65635. /**viewport width */
  65636. width: number;
  65637. /** viewport height */
  65638. height: number;
  65639. /**
  65640. * Creates a Viewport object located at (x, y) and sized (width, height)
  65641. * @param x defines viewport left coordinate
  65642. * @param y defines viewport top coordinate
  65643. * @param width defines the viewport width
  65644. * @param height defines the viewport height
  65645. */
  65646. constructor(
  65647. /** viewport left coordinate */
  65648. x: number,
  65649. /** viewport top coordinate */
  65650. y: number,
  65651. /**viewport width */
  65652. width: number,
  65653. /** viewport height */
  65654. height: number);
  65655. /**
  65656. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65657. * @param renderWidth defines the rendering width
  65658. * @param renderHeight defines the rendering height
  65659. * @returns a new Viewport
  65660. */
  65661. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65662. /**
  65663. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65664. * @param renderWidth defines the rendering width
  65665. * @param renderHeight defines the rendering height
  65666. * @param ref defines the target viewport
  65667. * @returns the current viewport
  65668. */
  65669. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65670. /**
  65671. * Returns a new Viewport copied from the current one
  65672. * @returns a new Viewport
  65673. */
  65674. clone(): Viewport;
  65675. }
  65676. }
  65677. declare module BABYLON {
  65678. /**
  65679. * Class containing a set of static utilities functions for arrays.
  65680. */
  65681. export class ArrayTools {
  65682. /**
  65683. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65684. * @param size the number of element to construct and put in the array
  65685. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65686. * @returns a new array filled with new objects
  65687. */
  65688. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65689. }
  65690. }
  65691. declare module BABYLON {
  65692. /**
  65693. * @hidden
  65694. */
  65695. export interface IColor4Like {
  65696. r: float;
  65697. g: float;
  65698. b: float;
  65699. a: float;
  65700. }
  65701. /**
  65702. * @hidden
  65703. */
  65704. export interface IColor3Like {
  65705. r: float;
  65706. g: float;
  65707. b: float;
  65708. }
  65709. /**
  65710. * @hidden
  65711. */
  65712. export interface IVector4Like {
  65713. x: float;
  65714. y: float;
  65715. z: float;
  65716. w: float;
  65717. }
  65718. /**
  65719. * @hidden
  65720. */
  65721. export interface IVector3Like {
  65722. x: float;
  65723. y: float;
  65724. z: float;
  65725. }
  65726. /**
  65727. * @hidden
  65728. */
  65729. export interface IVector2Like {
  65730. x: float;
  65731. y: float;
  65732. }
  65733. /**
  65734. * @hidden
  65735. */
  65736. export interface IMatrixLike {
  65737. toArray(): DeepImmutable<Float32Array>;
  65738. updateFlag: int;
  65739. }
  65740. /**
  65741. * @hidden
  65742. */
  65743. export interface IViewportLike {
  65744. x: float;
  65745. y: float;
  65746. width: float;
  65747. height: float;
  65748. }
  65749. /**
  65750. * @hidden
  65751. */
  65752. export interface IPlaneLike {
  65753. normal: IVector3Like;
  65754. d: float;
  65755. normalize(): void;
  65756. }
  65757. }
  65758. declare module BABYLON {
  65759. /**
  65760. * Class representing a vector containing 2 coordinates
  65761. */
  65762. export class Vector2 {
  65763. /** defines the first coordinate */
  65764. x: number;
  65765. /** defines the second coordinate */
  65766. y: number;
  65767. /**
  65768. * Creates a new Vector2 from the given x and y coordinates
  65769. * @param x defines the first coordinate
  65770. * @param y defines the second coordinate
  65771. */
  65772. constructor(
  65773. /** defines the first coordinate */
  65774. x?: number,
  65775. /** defines the second coordinate */
  65776. y?: number);
  65777. /**
  65778. * Gets a string with the Vector2 coordinates
  65779. * @returns a string with the Vector2 coordinates
  65780. */
  65781. toString(): string;
  65782. /**
  65783. * Gets class name
  65784. * @returns the string "Vector2"
  65785. */
  65786. getClassName(): string;
  65787. /**
  65788. * Gets current vector hash code
  65789. * @returns the Vector2 hash code as a number
  65790. */
  65791. getHashCode(): number;
  65792. /**
  65793. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65794. * @param array defines the source array
  65795. * @param index defines the offset in source array
  65796. * @returns the current Vector2
  65797. */
  65798. toArray(array: FloatArray, index?: number): Vector2;
  65799. /**
  65800. * Copy the current vector to an array
  65801. * @returns a new array with 2 elements: the Vector2 coordinates.
  65802. */
  65803. asArray(): number[];
  65804. /**
  65805. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65806. * @param source defines the source Vector2
  65807. * @returns the current updated Vector2
  65808. */
  65809. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65810. /**
  65811. * Sets the Vector2 coordinates with the given floats
  65812. * @param x defines the first coordinate
  65813. * @param y defines the second coordinate
  65814. * @returns the current updated Vector2
  65815. */
  65816. copyFromFloats(x: number, y: number): Vector2;
  65817. /**
  65818. * Sets the Vector2 coordinates with the given floats
  65819. * @param x defines the first coordinate
  65820. * @param y defines the second coordinate
  65821. * @returns the current updated Vector2
  65822. */
  65823. set(x: number, y: number): Vector2;
  65824. /**
  65825. * Add another vector with the current one
  65826. * @param otherVector defines the other vector
  65827. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65828. */
  65829. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65830. /**
  65831. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65832. * @param otherVector defines the other vector
  65833. * @param result defines the target vector
  65834. * @returns the unmodified current Vector2
  65835. */
  65836. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65837. /**
  65838. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65839. * @param otherVector defines the other vector
  65840. * @returns the current updated Vector2
  65841. */
  65842. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65843. /**
  65844. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65845. * @param otherVector defines the other vector
  65846. * @returns a new Vector2
  65847. */
  65848. addVector3(otherVector: Vector3): Vector2;
  65849. /**
  65850. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  65851. * @param otherVector defines the other vector
  65852. * @returns a new Vector2
  65853. */
  65854. subtract(otherVector: Vector2): Vector2;
  65855. /**
  65856. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  65857. * @param otherVector defines the other vector
  65858. * @param result defines the target vector
  65859. * @returns the unmodified current Vector2
  65860. */
  65861. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65862. /**
  65863. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  65864. * @param otherVector defines the other vector
  65865. * @returns the current updated Vector2
  65866. */
  65867. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65868. /**
  65869. * Multiplies in place the current Vector2 coordinates by the given ones
  65870. * @param otherVector defines the other vector
  65871. * @returns the current updated Vector2
  65872. */
  65873. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65874. /**
  65875. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  65876. * @param otherVector defines the other vector
  65877. * @returns a new Vector2
  65878. */
  65879. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  65880. /**
  65881. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  65882. * @param otherVector defines the other vector
  65883. * @param result defines the target vector
  65884. * @returns the unmodified current Vector2
  65885. */
  65886. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65887. /**
  65888. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  65889. * @param x defines the first coordinate
  65890. * @param y defines the second coordinate
  65891. * @returns a new Vector2
  65892. */
  65893. multiplyByFloats(x: number, y: number): Vector2;
  65894. /**
  65895. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  65896. * @param otherVector defines the other vector
  65897. * @returns a new Vector2
  65898. */
  65899. divide(otherVector: Vector2): Vector2;
  65900. /**
  65901. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  65902. * @param otherVector defines the other vector
  65903. * @param result defines the target vector
  65904. * @returns the unmodified current Vector2
  65905. */
  65906. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65907. /**
  65908. * Divides the current Vector2 coordinates by the given ones
  65909. * @param otherVector defines the other vector
  65910. * @returns the current updated Vector2
  65911. */
  65912. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65913. /**
  65914. * Gets a new Vector2 with current Vector2 negated coordinates
  65915. * @returns a new Vector2
  65916. */
  65917. negate(): Vector2;
  65918. /**
  65919. * Multiply the Vector2 coordinates by scale
  65920. * @param scale defines the scaling factor
  65921. * @returns the current updated Vector2
  65922. */
  65923. scaleInPlace(scale: number): Vector2;
  65924. /**
  65925. * Returns a new Vector2 scaled by "scale" from the current Vector2
  65926. * @param scale defines the scaling factor
  65927. * @returns a new Vector2
  65928. */
  65929. scale(scale: number): Vector2;
  65930. /**
  65931. * Scale the current Vector2 values by a factor to a given Vector2
  65932. * @param scale defines the scale factor
  65933. * @param result defines the Vector2 object where to store the result
  65934. * @returns the unmodified current Vector2
  65935. */
  65936. scaleToRef(scale: number, result: Vector2): Vector2;
  65937. /**
  65938. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  65939. * @param scale defines the scale factor
  65940. * @param result defines the Vector2 object where to store the result
  65941. * @returns the unmodified current Vector2
  65942. */
  65943. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  65944. /**
  65945. * Gets a boolean if two vectors are equals
  65946. * @param otherVector defines the other vector
  65947. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  65948. */
  65949. equals(otherVector: DeepImmutable<Vector2>): boolean;
  65950. /**
  65951. * Gets a boolean if two vectors are equals (using an epsilon value)
  65952. * @param otherVector defines the other vector
  65953. * @param epsilon defines the minimal distance to consider equality
  65954. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  65955. */
  65956. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  65957. /**
  65958. * Gets a new Vector2 from current Vector2 floored values
  65959. * @returns a new Vector2
  65960. */
  65961. floor(): Vector2;
  65962. /**
  65963. * Gets a new Vector2 from current Vector2 floored values
  65964. * @returns a new Vector2
  65965. */
  65966. fract(): Vector2;
  65967. /**
  65968. * Gets the length of the vector
  65969. * @returns the vector length (float)
  65970. */
  65971. length(): number;
  65972. /**
  65973. * Gets the vector squared length
  65974. * @returns the vector squared length (float)
  65975. */
  65976. lengthSquared(): number;
  65977. /**
  65978. * Normalize the vector
  65979. * @returns the current updated Vector2
  65980. */
  65981. normalize(): Vector2;
  65982. /**
  65983. * Gets a new Vector2 copied from the Vector2
  65984. * @returns a new Vector2
  65985. */
  65986. clone(): Vector2;
  65987. /**
  65988. * Gets a new Vector2(0, 0)
  65989. * @returns a new Vector2
  65990. */
  65991. static Zero(): Vector2;
  65992. /**
  65993. * Gets a new Vector2(1, 1)
  65994. * @returns a new Vector2
  65995. */
  65996. static One(): Vector2;
  65997. /**
  65998. * Gets a new Vector2 set from the given index element of the given array
  65999. * @param array defines the data source
  66000. * @param offset defines the offset in the data source
  66001. * @returns a new Vector2
  66002. */
  66003. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  66004. /**
  66005. * Sets "result" from the given index element of the given array
  66006. * @param array defines the data source
  66007. * @param offset defines the offset in the data source
  66008. * @param result defines the target vector
  66009. */
  66010. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  66011. /**
  66012. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  66013. * @param value1 defines 1st point of control
  66014. * @param value2 defines 2nd point of control
  66015. * @param value3 defines 3rd point of control
  66016. * @param value4 defines 4th point of control
  66017. * @param amount defines the interpolation factor
  66018. * @returns a new Vector2
  66019. */
  66020. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  66021. /**
  66022. * 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".
  66023. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  66024. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  66025. * @param value defines the value to clamp
  66026. * @param min defines the lower limit
  66027. * @param max defines the upper limit
  66028. * @returns a new Vector2
  66029. */
  66030. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  66031. /**
  66032. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  66033. * @param value1 defines the 1st control point
  66034. * @param tangent1 defines the outgoing tangent
  66035. * @param value2 defines the 2nd control point
  66036. * @param tangent2 defines the incoming tangent
  66037. * @param amount defines the interpolation factor
  66038. * @returns a new Vector2
  66039. */
  66040. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  66041. /**
  66042. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  66043. * @param start defines the start vector
  66044. * @param end defines the end vector
  66045. * @param amount defines the interpolation factor
  66046. * @returns a new Vector2
  66047. */
  66048. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  66049. /**
  66050. * Gets the dot product of the vector "left" and the vector "right"
  66051. * @param left defines first vector
  66052. * @param right defines second vector
  66053. * @returns the dot product (float)
  66054. */
  66055. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  66056. /**
  66057. * Returns a new Vector2 equal to the normalized given vector
  66058. * @param vector defines the vector to normalize
  66059. * @returns a new Vector2
  66060. */
  66061. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  66062. /**
  66063. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  66064. * @param left defines 1st vector
  66065. * @param right defines 2nd vector
  66066. * @returns a new Vector2
  66067. */
  66068. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66069. /**
  66070. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  66071. * @param left defines 1st vector
  66072. * @param right defines 2nd vector
  66073. * @returns a new Vector2
  66074. */
  66075. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66076. /**
  66077. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  66078. * @param vector defines the vector to transform
  66079. * @param transformation defines the matrix to apply
  66080. * @returns a new Vector2
  66081. */
  66082. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  66083. /**
  66084. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  66085. * @param vector defines the vector to transform
  66086. * @param transformation defines the matrix to apply
  66087. * @param result defines the target vector
  66088. */
  66089. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  66090. /**
  66091. * Determines if a given vector is included in a triangle
  66092. * @param p defines the vector to test
  66093. * @param p0 defines 1st triangle point
  66094. * @param p1 defines 2nd triangle point
  66095. * @param p2 defines 3rd triangle point
  66096. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  66097. */
  66098. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  66099. /**
  66100. * Gets the distance between the vectors "value1" and "value2"
  66101. * @param value1 defines first vector
  66102. * @param value2 defines second vector
  66103. * @returns the distance between vectors
  66104. */
  66105. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66106. /**
  66107. * Returns the squared distance between the vectors "value1" and "value2"
  66108. * @param value1 defines first vector
  66109. * @param value2 defines second vector
  66110. * @returns the squared distance between vectors
  66111. */
  66112. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66113. /**
  66114. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  66115. * @param value1 defines first vector
  66116. * @param value2 defines second vector
  66117. * @returns a new Vector2
  66118. */
  66119. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  66120. /**
  66121. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  66122. * @param p defines the middle point
  66123. * @param segA defines one point of the segment
  66124. * @param segB defines the other point of the segment
  66125. * @returns the shortest distance
  66126. */
  66127. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  66128. }
  66129. /**
  66130. * Classed used to store (x,y,z) vector representation
  66131. * A Vector3 is the main object used in 3D geometry
  66132. * It can represent etiher the coordinates of a point the space, either a direction
  66133. * Reminder: js uses a left handed forward facing system
  66134. */
  66135. export class Vector3 {
  66136. /**
  66137. * Defines the first coordinates (on X axis)
  66138. */
  66139. x: number;
  66140. /**
  66141. * Defines the second coordinates (on Y axis)
  66142. */
  66143. y: number;
  66144. /**
  66145. * Defines the third coordinates (on Z axis)
  66146. */
  66147. z: number;
  66148. private static _UpReadOnly;
  66149. private static _ZeroReadOnly;
  66150. /**
  66151. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  66152. * @param x defines the first coordinates (on X axis)
  66153. * @param y defines the second coordinates (on Y axis)
  66154. * @param z defines the third coordinates (on Z axis)
  66155. */
  66156. constructor(
  66157. /**
  66158. * Defines the first coordinates (on X axis)
  66159. */
  66160. x?: number,
  66161. /**
  66162. * Defines the second coordinates (on Y axis)
  66163. */
  66164. y?: number,
  66165. /**
  66166. * Defines the third coordinates (on Z axis)
  66167. */
  66168. z?: number);
  66169. /**
  66170. * Creates a string representation of the Vector3
  66171. * @returns a string with the Vector3 coordinates.
  66172. */
  66173. toString(): string;
  66174. /**
  66175. * Gets the class name
  66176. * @returns the string "Vector3"
  66177. */
  66178. getClassName(): string;
  66179. /**
  66180. * Creates the Vector3 hash code
  66181. * @returns a number which tends to be unique between Vector3 instances
  66182. */
  66183. getHashCode(): number;
  66184. /**
  66185. * Creates an array containing three elements : the coordinates of the Vector3
  66186. * @returns a new array of numbers
  66187. */
  66188. asArray(): number[];
  66189. /**
  66190. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  66191. * @param array defines the destination array
  66192. * @param index defines the offset in the destination array
  66193. * @returns the current Vector3
  66194. */
  66195. toArray(array: FloatArray, index?: number): Vector3;
  66196. /**
  66197. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  66198. * @returns a new Quaternion object, computed from the Vector3 coordinates
  66199. */
  66200. toQuaternion(): Quaternion;
  66201. /**
  66202. * Adds the given vector to the current Vector3
  66203. * @param otherVector defines the second operand
  66204. * @returns the current updated Vector3
  66205. */
  66206. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66207. /**
  66208. * Adds the given coordinates to the current Vector3
  66209. * @param x defines the x coordinate of the operand
  66210. * @param y defines the y coordinate of the operand
  66211. * @param z defines the z coordinate of the operand
  66212. * @returns the current updated Vector3
  66213. */
  66214. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66215. /**
  66216. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  66217. * @param otherVector defines the second operand
  66218. * @returns the resulting Vector3
  66219. */
  66220. add(otherVector: DeepImmutable<Vector3>): Vector3;
  66221. /**
  66222. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  66223. * @param otherVector defines the second operand
  66224. * @param result defines the Vector3 object where to store the result
  66225. * @returns the current Vector3
  66226. */
  66227. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66228. /**
  66229. * Subtract the given vector from the current Vector3
  66230. * @param otherVector defines the second operand
  66231. * @returns the current updated Vector3
  66232. */
  66233. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66234. /**
  66235. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  66236. * @param otherVector defines the second operand
  66237. * @returns the resulting Vector3
  66238. */
  66239. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  66240. /**
  66241. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  66242. * @param otherVector defines the second operand
  66243. * @param result defines the Vector3 object where to store the result
  66244. * @returns the current Vector3
  66245. */
  66246. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66247. /**
  66248. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  66249. * @param x defines the x coordinate of the operand
  66250. * @param y defines the y coordinate of the operand
  66251. * @param z defines the z coordinate of the operand
  66252. * @returns the resulting Vector3
  66253. */
  66254. subtractFromFloats(x: number, y: number, z: number): Vector3;
  66255. /**
  66256. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  66257. * @param x defines the x coordinate of the operand
  66258. * @param y defines the y coordinate of the operand
  66259. * @param z defines the z coordinate of the operand
  66260. * @param result defines the Vector3 object where to store the result
  66261. * @returns the current Vector3
  66262. */
  66263. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  66264. /**
  66265. * Gets a new Vector3 set with the current Vector3 negated coordinates
  66266. * @returns a new Vector3
  66267. */
  66268. negate(): Vector3;
  66269. /**
  66270. * Multiplies the Vector3 coordinates by the float "scale"
  66271. * @param scale defines the multiplier factor
  66272. * @returns the current updated Vector3
  66273. */
  66274. scaleInPlace(scale: number): Vector3;
  66275. /**
  66276. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  66277. * @param scale defines the multiplier factor
  66278. * @returns a new Vector3
  66279. */
  66280. scale(scale: number): Vector3;
  66281. /**
  66282. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  66283. * @param scale defines the multiplier factor
  66284. * @param result defines the Vector3 object where to store the result
  66285. * @returns the current Vector3
  66286. */
  66287. scaleToRef(scale: number, result: Vector3): Vector3;
  66288. /**
  66289. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  66290. * @param scale defines the scale factor
  66291. * @param result defines the Vector3 object where to store the result
  66292. * @returns the unmodified current Vector3
  66293. */
  66294. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  66295. /**
  66296. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  66297. * @param otherVector defines the second operand
  66298. * @returns true if both vectors are equals
  66299. */
  66300. equals(otherVector: DeepImmutable<Vector3>): boolean;
  66301. /**
  66302. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  66303. * @param otherVector defines the second operand
  66304. * @param epsilon defines the minimal distance to define values as equals
  66305. * @returns true if both vectors are distant less than epsilon
  66306. */
  66307. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  66308. /**
  66309. * Returns true if the current Vector3 coordinates equals the given floats
  66310. * @param x defines the x coordinate of the operand
  66311. * @param y defines the y coordinate of the operand
  66312. * @param z defines the z coordinate of the operand
  66313. * @returns true if both vectors are equals
  66314. */
  66315. equalsToFloats(x: number, y: number, z: number): boolean;
  66316. /**
  66317. * Multiplies the current Vector3 coordinates by the given ones
  66318. * @param otherVector defines the second operand
  66319. * @returns the current updated Vector3
  66320. */
  66321. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66322. /**
  66323. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  66324. * @param otherVector defines the second operand
  66325. * @returns the new Vector3
  66326. */
  66327. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  66328. /**
  66329. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  66330. * @param otherVector defines the second operand
  66331. * @param result defines the Vector3 object where to store the result
  66332. * @returns the current Vector3
  66333. */
  66334. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66335. /**
  66336. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  66337. * @param x defines the x coordinate of the operand
  66338. * @param y defines the y coordinate of the operand
  66339. * @param z defines the z coordinate of the operand
  66340. * @returns the new Vector3
  66341. */
  66342. multiplyByFloats(x: number, y: number, z: number): Vector3;
  66343. /**
  66344. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  66345. * @param otherVector defines the second operand
  66346. * @returns the new Vector3
  66347. */
  66348. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  66349. /**
  66350. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  66351. * @param otherVector defines the second operand
  66352. * @param result defines the Vector3 object where to store the result
  66353. * @returns the current Vector3
  66354. */
  66355. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66356. /**
  66357. * Divides the current Vector3 coordinates by the given ones.
  66358. * @param otherVector defines the second operand
  66359. * @returns the current updated Vector3
  66360. */
  66361. divideInPlace(otherVector: Vector3): Vector3;
  66362. /**
  66363. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  66364. * @param other defines the second operand
  66365. * @returns the current updated Vector3
  66366. */
  66367. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66368. /**
  66369. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  66370. * @param other defines the second operand
  66371. * @returns the current updated Vector3
  66372. */
  66373. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66374. /**
  66375. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  66376. * @param x defines the x coordinate of the operand
  66377. * @param y defines the y coordinate of the operand
  66378. * @param z defines the z coordinate of the operand
  66379. * @returns the current updated Vector3
  66380. */
  66381. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66382. /**
  66383. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  66384. * @param x defines the x coordinate of the operand
  66385. * @param y defines the y coordinate of the operand
  66386. * @param z defines the z coordinate of the operand
  66387. * @returns the current updated Vector3
  66388. */
  66389. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66390. /**
  66391. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  66392. * Check if is non uniform within a certain amount of decimal places to account for this
  66393. * @param epsilon the amount the values can differ
  66394. * @returns if the the vector is non uniform to a certain number of decimal places
  66395. */
  66396. isNonUniformWithinEpsilon(epsilon: number): boolean;
  66397. /**
  66398. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  66399. */
  66400. readonly isNonUniform: boolean;
  66401. /**
  66402. * Gets a new Vector3 from current Vector3 floored values
  66403. * @returns a new Vector3
  66404. */
  66405. floor(): Vector3;
  66406. /**
  66407. * Gets a new Vector3 from current Vector3 floored values
  66408. * @returns a new Vector3
  66409. */
  66410. fract(): Vector3;
  66411. /**
  66412. * Gets the length of the Vector3
  66413. * @returns the length of the Vector3
  66414. */
  66415. length(): number;
  66416. /**
  66417. * Gets the squared length of the Vector3
  66418. * @returns squared length of the Vector3
  66419. */
  66420. lengthSquared(): number;
  66421. /**
  66422. * Normalize the current Vector3.
  66423. * Please note that this is an in place operation.
  66424. * @returns the current updated Vector3
  66425. */
  66426. normalize(): Vector3;
  66427. /**
  66428. * Reorders the x y z properties of the vector in place
  66429. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  66430. * @returns the current updated vector
  66431. */
  66432. reorderInPlace(order: string): this;
  66433. /**
  66434. * Rotates the vector around 0,0,0 by a quaternion
  66435. * @param quaternion the rotation quaternion
  66436. * @param result vector to store the result
  66437. * @returns the resulting vector
  66438. */
  66439. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  66440. /**
  66441. * Rotates a vector around a given point
  66442. * @param quaternion the rotation quaternion
  66443. * @param point the point to rotate around
  66444. * @param result vector to store the result
  66445. * @returns the resulting vector
  66446. */
  66447. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  66448. /**
  66449. * Normalize the current Vector3 with the given input length.
  66450. * Please note that this is an in place operation.
  66451. * @param len the length of the vector
  66452. * @returns the current updated Vector3
  66453. */
  66454. normalizeFromLength(len: number): Vector3;
  66455. /**
  66456. * Normalize the current Vector3 to a new vector
  66457. * @returns the new Vector3
  66458. */
  66459. normalizeToNew(): Vector3;
  66460. /**
  66461. * Normalize the current Vector3 to the reference
  66462. * @param reference define the Vector3 to update
  66463. * @returns the updated Vector3
  66464. */
  66465. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  66466. /**
  66467. * Creates a new Vector3 copied from the current Vector3
  66468. * @returns the new Vector3
  66469. */
  66470. clone(): Vector3;
  66471. /**
  66472. * Copies the given vector coordinates to the current Vector3 ones
  66473. * @param source defines the source Vector3
  66474. * @returns the current updated Vector3
  66475. */
  66476. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  66477. /**
  66478. * Copies the given floats to the current Vector3 coordinates
  66479. * @param x defines the x coordinate of the operand
  66480. * @param y defines the y coordinate of the operand
  66481. * @param z defines the z coordinate of the operand
  66482. * @returns the current updated Vector3
  66483. */
  66484. copyFromFloats(x: number, y: number, z: number): Vector3;
  66485. /**
  66486. * Copies the given floats to the current Vector3 coordinates
  66487. * @param x defines the x coordinate of the operand
  66488. * @param y defines the y coordinate of the operand
  66489. * @param z defines the z coordinate of the operand
  66490. * @returns the current updated Vector3
  66491. */
  66492. set(x: number, y: number, z: number): Vector3;
  66493. /**
  66494. * Copies the given float to the current Vector3 coordinates
  66495. * @param v defines the x, y and z coordinates of the operand
  66496. * @returns the current updated Vector3
  66497. */
  66498. setAll(v: number): Vector3;
  66499. /**
  66500. * Get the clip factor between two vectors
  66501. * @param vector0 defines the first operand
  66502. * @param vector1 defines the second operand
  66503. * @param axis defines the axis to use
  66504. * @param size defines the size along the axis
  66505. * @returns the clip factor
  66506. */
  66507. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  66508. /**
  66509. * Get angle between two vectors
  66510. * @param vector0 angle between vector0 and vector1
  66511. * @param vector1 angle between vector0 and vector1
  66512. * @param normal direction of the normal
  66513. * @return the angle between vector0 and vector1
  66514. */
  66515. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  66516. /**
  66517. * Returns a new Vector3 set from the index "offset" of the given array
  66518. * @param array defines the source array
  66519. * @param offset defines the offset in the source array
  66520. * @returns the new Vector3
  66521. */
  66522. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  66523. /**
  66524. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  66525. * This function is deprecated. Use FromArray instead
  66526. * @param array defines the source array
  66527. * @param offset defines the offset in the source array
  66528. * @returns the new Vector3
  66529. */
  66530. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  66531. /**
  66532. * Sets the given vector "result" with the element values from the index "offset" of the given array
  66533. * @param array defines the source array
  66534. * @param offset defines the offset in the source array
  66535. * @param result defines the Vector3 where to store the result
  66536. */
  66537. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  66538. /**
  66539. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  66540. * This function is deprecated. Use FromArrayToRef instead.
  66541. * @param array defines the source array
  66542. * @param offset defines the offset in the source array
  66543. * @param result defines the Vector3 where to store the result
  66544. */
  66545. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  66546. /**
  66547. * Sets the given vector "result" with the given floats.
  66548. * @param x defines the x coordinate of the source
  66549. * @param y defines the y coordinate of the source
  66550. * @param z defines the z coordinate of the source
  66551. * @param result defines the Vector3 where to store the result
  66552. */
  66553. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  66554. /**
  66555. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  66556. * @returns a new empty Vector3
  66557. */
  66558. static Zero(): Vector3;
  66559. /**
  66560. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  66561. * @returns a new unit Vector3
  66562. */
  66563. static One(): Vector3;
  66564. /**
  66565. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  66566. * @returns a new up Vector3
  66567. */
  66568. static Up(): Vector3;
  66569. /**
  66570. * Gets a up Vector3 that must not be updated
  66571. */
  66572. static readonly UpReadOnly: DeepImmutable<Vector3>;
  66573. /**
  66574. * Gets a zero Vector3 that must not be updated
  66575. */
  66576. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  66577. /**
  66578. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  66579. * @returns a new down Vector3
  66580. */
  66581. static Down(): Vector3;
  66582. /**
  66583. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  66584. * @returns a new forward Vector3
  66585. */
  66586. static Forward(): Vector3;
  66587. /**
  66588. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  66589. * @returns a new forward Vector3
  66590. */
  66591. static Backward(): Vector3;
  66592. /**
  66593. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  66594. * @returns a new right Vector3
  66595. */
  66596. static Right(): Vector3;
  66597. /**
  66598. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  66599. * @returns a new left Vector3
  66600. */
  66601. static Left(): Vector3;
  66602. /**
  66603. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  66604. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66605. * @param vector defines the Vector3 to transform
  66606. * @param transformation defines the transformation matrix
  66607. * @returns the transformed Vector3
  66608. */
  66609. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66610. /**
  66611. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  66612. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66613. * @param vector defines the Vector3 to transform
  66614. * @param transformation defines the transformation matrix
  66615. * @param result defines the Vector3 where to store the result
  66616. */
  66617. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66618. /**
  66619. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  66620. * This method computes tranformed coordinates only, not transformed direction vectors
  66621. * @param x define the x coordinate of the source vector
  66622. * @param y define the y coordinate of the source vector
  66623. * @param z define the z coordinate of the source vector
  66624. * @param transformation defines the transformation matrix
  66625. * @param result defines the Vector3 where to store the result
  66626. */
  66627. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66628. /**
  66629. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  66630. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66631. * @param vector defines the Vector3 to transform
  66632. * @param transformation defines the transformation matrix
  66633. * @returns the new Vector3
  66634. */
  66635. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66636. /**
  66637. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66638. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66639. * @param vector defines the Vector3 to transform
  66640. * @param transformation defines the transformation matrix
  66641. * @param result defines the Vector3 where to store the result
  66642. */
  66643. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66644. /**
  66645. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66646. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66647. * @param x define the x coordinate of the source vector
  66648. * @param y define the y coordinate of the source vector
  66649. * @param z define the z coordinate of the source vector
  66650. * @param transformation defines the transformation matrix
  66651. * @param result defines the Vector3 where to store the result
  66652. */
  66653. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66654. /**
  66655. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66656. * @param value1 defines the first control point
  66657. * @param value2 defines the second control point
  66658. * @param value3 defines the third control point
  66659. * @param value4 defines the fourth control point
  66660. * @param amount defines the amount on the spline to use
  66661. * @returns the new Vector3
  66662. */
  66663. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66664. /**
  66665. * 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"
  66666. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66667. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66668. * @param value defines the current value
  66669. * @param min defines the lower range value
  66670. * @param max defines the upper range value
  66671. * @returns the new Vector3
  66672. */
  66673. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66674. /**
  66675. * 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"
  66676. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66677. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66678. * @param value defines the current value
  66679. * @param min defines the lower range value
  66680. * @param max defines the upper range value
  66681. * @param result defines the Vector3 where to store the result
  66682. */
  66683. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66684. /**
  66685. * Checks if a given vector is inside a specific range
  66686. * @param v defines the vector to test
  66687. * @param min defines the minimum range
  66688. * @param max defines the maximum range
  66689. */
  66690. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66691. /**
  66692. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66693. * @param value1 defines the first control point
  66694. * @param tangent1 defines the first tangent vector
  66695. * @param value2 defines the second control point
  66696. * @param tangent2 defines the second tangent vector
  66697. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66698. * @returns the new Vector3
  66699. */
  66700. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66701. /**
  66702. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66703. * @param start defines the start value
  66704. * @param end defines the end value
  66705. * @param amount max defines amount between both (between 0 and 1)
  66706. * @returns the new Vector3
  66707. */
  66708. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66709. /**
  66710. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66711. * @param start defines the start value
  66712. * @param end defines the end value
  66713. * @param amount max defines amount between both (between 0 and 1)
  66714. * @param result defines the Vector3 where to store the result
  66715. */
  66716. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66717. /**
  66718. * Returns the dot product (float) between the vectors "left" and "right"
  66719. * @param left defines the left operand
  66720. * @param right defines the right operand
  66721. * @returns the dot product
  66722. */
  66723. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  66724. /**
  66725. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66726. * The cross product is then orthogonal to both "left" and "right"
  66727. * @param left defines the left operand
  66728. * @param right defines the right operand
  66729. * @returns the cross product
  66730. */
  66731. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66732. /**
  66733. * Sets the given vector "result" with the cross product of "left" and "right"
  66734. * The cross product is then orthogonal to both "left" and "right"
  66735. * @param left defines the left operand
  66736. * @param right defines the right operand
  66737. * @param result defines the Vector3 where to store the result
  66738. */
  66739. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66740. /**
  66741. * Returns a new Vector3 as the normalization of the given vector
  66742. * @param vector defines the Vector3 to normalize
  66743. * @returns the new Vector3
  66744. */
  66745. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66746. /**
  66747. * Sets the given vector "result" with the normalization of the given first vector
  66748. * @param vector defines the Vector3 to normalize
  66749. * @param result defines the Vector3 where to store the result
  66750. */
  66751. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66752. /**
  66753. * Project a Vector3 onto screen space
  66754. * @param vector defines the Vector3 to project
  66755. * @param world defines the world matrix to use
  66756. * @param transform defines the transform (view x projection) matrix to use
  66757. * @param viewport defines the screen viewport to use
  66758. * @returns the new Vector3
  66759. */
  66760. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66761. /** @hidden */
  66762. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66763. /**
  66764. * Unproject from screen space to object space
  66765. * @param source defines the screen space Vector3 to use
  66766. * @param viewportWidth defines the current width of the viewport
  66767. * @param viewportHeight defines the current height of the viewport
  66768. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66769. * @param transform defines the transform (view x projection) matrix to use
  66770. * @returns the new Vector3
  66771. */
  66772. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66773. /**
  66774. * Unproject from screen space to object space
  66775. * @param source defines the screen space Vector3 to use
  66776. * @param viewportWidth defines the current width of the viewport
  66777. * @param viewportHeight defines the current height of the viewport
  66778. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66779. * @param view defines the view matrix to use
  66780. * @param projection defines the projection matrix to use
  66781. * @returns the new Vector3
  66782. */
  66783. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66784. /**
  66785. * Unproject from screen space to object space
  66786. * @param source defines the screen space Vector3 to use
  66787. * @param viewportWidth defines the current width of the viewport
  66788. * @param viewportHeight defines the current height of the viewport
  66789. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66790. * @param view defines the view matrix to use
  66791. * @param projection defines the projection matrix to use
  66792. * @param result defines the Vector3 where to store the result
  66793. */
  66794. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66795. /**
  66796. * Unproject from screen space to object space
  66797. * @param sourceX defines the screen space x coordinate to use
  66798. * @param sourceY defines the screen space y coordinate to use
  66799. * @param sourceZ defines the screen space z coordinate to use
  66800. * @param viewportWidth defines the current width of the viewport
  66801. * @param viewportHeight defines the current height of the viewport
  66802. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66803. * @param view defines the view matrix to use
  66804. * @param projection defines the projection matrix to use
  66805. * @param result defines the Vector3 where to store the result
  66806. */
  66807. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66808. /**
  66809. * Gets the minimal coordinate values between two Vector3
  66810. * @param left defines the first operand
  66811. * @param right defines the second operand
  66812. * @returns the new Vector3
  66813. */
  66814. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66815. /**
  66816. * Gets the maximal coordinate values between two Vector3
  66817. * @param left defines the first operand
  66818. * @param right defines the second operand
  66819. * @returns the new Vector3
  66820. */
  66821. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66822. /**
  66823. * Returns the distance between the vectors "value1" and "value2"
  66824. * @param value1 defines the first operand
  66825. * @param value2 defines the second operand
  66826. * @returns the distance
  66827. */
  66828. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66829. /**
  66830. * Returns the squared distance between the vectors "value1" and "value2"
  66831. * @param value1 defines the first operand
  66832. * @param value2 defines the second operand
  66833. * @returns the squared distance
  66834. */
  66835. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66836. /**
  66837. * Returns a new Vector3 located at the center between "value1" and "value2"
  66838. * @param value1 defines the first operand
  66839. * @param value2 defines the second operand
  66840. * @returns the new Vector3
  66841. */
  66842. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66843. /**
  66844. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66845. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66846. * to something in order to rotate it from its local system to the given target system
  66847. * Note: axis1, axis2 and axis3 are normalized during this operation
  66848. * @param axis1 defines the first axis
  66849. * @param axis2 defines the second axis
  66850. * @param axis3 defines the third axis
  66851. * @returns a new Vector3
  66852. */
  66853. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  66854. /**
  66855. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  66856. * @param axis1 defines the first axis
  66857. * @param axis2 defines the second axis
  66858. * @param axis3 defines the third axis
  66859. * @param ref defines the Vector3 where to store the result
  66860. */
  66861. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  66862. }
  66863. /**
  66864. * Vector4 class created for EulerAngle class conversion to Quaternion
  66865. */
  66866. export class Vector4 {
  66867. /** x value of the vector */
  66868. x: number;
  66869. /** y value of the vector */
  66870. y: number;
  66871. /** z value of the vector */
  66872. z: number;
  66873. /** w value of the vector */
  66874. w: number;
  66875. /**
  66876. * Creates a Vector4 object from the given floats.
  66877. * @param x x value of the vector
  66878. * @param y y value of the vector
  66879. * @param z z value of the vector
  66880. * @param w w value of the vector
  66881. */
  66882. constructor(
  66883. /** x value of the vector */
  66884. x: number,
  66885. /** y value of the vector */
  66886. y: number,
  66887. /** z value of the vector */
  66888. z: number,
  66889. /** w value of the vector */
  66890. w: number);
  66891. /**
  66892. * Returns the string with the Vector4 coordinates.
  66893. * @returns a string containing all the vector values
  66894. */
  66895. toString(): string;
  66896. /**
  66897. * Returns the string "Vector4".
  66898. * @returns "Vector4"
  66899. */
  66900. getClassName(): string;
  66901. /**
  66902. * Returns the Vector4 hash code.
  66903. * @returns a unique hash code
  66904. */
  66905. getHashCode(): number;
  66906. /**
  66907. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  66908. * @returns the resulting array
  66909. */
  66910. asArray(): number[];
  66911. /**
  66912. * Populates the given array from the given index with the Vector4 coordinates.
  66913. * @param array array to populate
  66914. * @param index index of the array to start at (default: 0)
  66915. * @returns the Vector4.
  66916. */
  66917. toArray(array: FloatArray, index?: number): Vector4;
  66918. /**
  66919. * Adds the given vector to the current Vector4.
  66920. * @param otherVector the vector to add
  66921. * @returns the updated Vector4.
  66922. */
  66923. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66924. /**
  66925. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  66926. * @param otherVector the vector to add
  66927. * @returns the resulting vector
  66928. */
  66929. add(otherVector: DeepImmutable<Vector4>): Vector4;
  66930. /**
  66931. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  66932. * @param otherVector the vector to add
  66933. * @param result the vector to store the result
  66934. * @returns the current Vector4.
  66935. */
  66936. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66937. /**
  66938. * Subtract in place the given vector from the current Vector4.
  66939. * @param otherVector the vector to subtract
  66940. * @returns the updated Vector4.
  66941. */
  66942. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66943. /**
  66944. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  66945. * @param otherVector the vector to add
  66946. * @returns the new vector with the result
  66947. */
  66948. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  66949. /**
  66950. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  66951. * @param otherVector the vector to subtract
  66952. * @param result the vector to store the result
  66953. * @returns the current Vector4.
  66954. */
  66955. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66956. /**
  66957. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66958. */
  66959. /**
  66960. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66961. * @param x value to subtract
  66962. * @param y value to subtract
  66963. * @param z value to subtract
  66964. * @param w value to subtract
  66965. * @returns new vector containing the result
  66966. */
  66967. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66968. /**
  66969. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66970. * @param x value to subtract
  66971. * @param y value to subtract
  66972. * @param z value to subtract
  66973. * @param w value to subtract
  66974. * @param result the vector to store the result in
  66975. * @returns the current Vector4.
  66976. */
  66977. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  66978. /**
  66979. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  66980. * @returns a new vector with the negated values
  66981. */
  66982. negate(): Vector4;
  66983. /**
  66984. * Multiplies the current Vector4 coordinates by scale (float).
  66985. * @param scale the number to scale with
  66986. * @returns the updated Vector4.
  66987. */
  66988. scaleInPlace(scale: number): Vector4;
  66989. /**
  66990. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  66991. * @param scale the number to scale with
  66992. * @returns a new vector with the result
  66993. */
  66994. scale(scale: number): Vector4;
  66995. /**
  66996. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  66997. * @param scale the number to scale with
  66998. * @param result a vector to store the result in
  66999. * @returns the current Vector4.
  67000. */
  67001. scaleToRef(scale: number, result: Vector4): Vector4;
  67002. /**
  67003. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  67004. * @param scale defines the scale factor
  67005. * @param result defines the Vector4 object where to store the result
  67006. * @returns the unmodified current Vector4
  67007. */
  67008. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  67009. /**
  67010. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  67011. * @param otherVector the vector to compare against
  67012. * @returns true if they are equal
  67013. */
  67014. equals(otherVector: DeepImmutable<Vector4>): boolean;
  67015. /**
  67016. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  67017. * @param otherVector vector to compare against
  67018. * @param epsilon (Default: very small number)
  67019. * @returns true if they are equal
  67020. */
  67021. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  67022. /**
  67023. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  67024. * @param x x value to compare against
  67025. * @param y y value to compare against
  67026. * @param z z value to compare against
  67027. * @param w w value to compare against
  67028. * @returns true if equal
  67029. */
  67030. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  67031. /**
  67032. * Multiplies in place the current Vector4 by the given one.
  67033. * @param otherVector vector to multiple with
  67034. * @returns the updated Vector4.
  67035. */
  67036. multiplyInPlace(otherVector: Vector4): Vector4;
  67037. /**
  67038. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  67039. * @param otherVector vector to multiple with
  67040. * @returns resulting new vector
  67041. */
  67042. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  67043. /**
  67044. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  67045. * @param otherVector vector to multiple with
  67046. * @param result vector to store the result
  67047. * @returns the current Vector4.
  67048. */
  67049. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67050. /**
  67051. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  67052. * @param x x value multiply with
  67053. * @param y y value multiply with
  67054. * @param z z value multiply with
  67055. * @param w w value multiply with
  67056. * @returns resulting new vector
  67057. */
  67058. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  67059. /**
  67060. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  67061. * @param otherVector vector to devide with
  67062. * @returns resulting new vector
  67063. */
  67064. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  67065. /**
  67066. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  67067. * @param otherVector vector to devide with
  67068. * @param result vector to store the result
  67069. * @returns the current Vector4.
  67070. */
  67071. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67072. /**
  67073. * Divides the current Vector3 coordinates by the given ones.
  67074. * @param otherVector vector to devide with
  67075. * @returns the updated Vector3.
  67076. */
  67077. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67078. /**
  67079. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  67080. * @param other defines the second operand
  67081. * @returns the current updated Vector4
  67082. */
  67083. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67084. /**
  67085. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  67086. * @param other defines the second operand
  67087. * @returns the current updated Vector4
  67088. */
  67089. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67090. /**
  67091. * Gets a new Vector4 from current Vector4 floored values
  67092. * @returns a new Vector4
  67093. */
  67094. floor(): Vector4;
  67095. /**
  67096. * Gets a new Vector4 from current Vector3 floored values
  67097. * @returns a new Vector4
  67098. */
  67099. fract(): Vector4;
  67100. /**
  67101. * Returns the Vector4 length (float).
  67102. * @returns the length
  67103. */
  67104. length(): number;
  67105. /**
  67106. * Returns the Vector4 squared length (float).
  67107. * @returns the length squared
  67108. */
  67109. lengthSquared(): number;
  67110. /**
  67111. * Normalizes in place the Vector4.
  67112. * @returns the updated Vector4.
  67113. */
  67114. normalize(): Vector4;
  67115. /**
  67116. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  67117. * @returns this converted to a new vector3
  67118. */
  67119. toVector3(): Vector3;
  67120. /**
  67121. * Returns a new Vector4 copied from the current one.
  67122. * @returns the new cloned vector
  67123. */
  67124. clone(): Vector4;
  67125. /**
  67126. * Updates the current Vector4 with the given one coordinates.
  67127. * @param source the source vector to copy from
  67128. * @returns the updated Vector4.
  67129. */
  67130. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  67131. /**
  67132. * Updates the current Vector4 coordinates with the given floats.
  67133. * @param x float to copy from
  67134. * @param y float to copy from
  67135. * @param z float to copy from
  67136. * @param w float to copy from
  67137. * @returns the updated Vector4.
  67138. */
  67139. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67140. /**
  67141. * Updates the current Vector4 coordinates with the given floats.
  67142. * @param x float to set from
  67143. * @param y float to set from
  67144. * @param z float to set from
  67145. * @param w float to set from
  67146. * @returns the updated Vector4.
  67147. */
  67148. set(x: number, y: number, z: number, w: number): Vector4;
  67149. /**
  67150. * Copies the given float to the current Vector3 coordinates
  67151. * @param v defines the x, y, z and w coordinates of the operand
  67152. * @returns the current updated Vector3
  67153. */
  67154. setAll(v: number): Vector4;
  67155. /**
  67156. * Returns a new Vector4 set from the starting index of the given array.
  67157. * @param array the array to pull values from
  67158. * @param offset the offset into the array to start at
  67159. * @returns the new vector
  67160. */
  67161. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  67162. /**
  67163. * Updates the given vector "result" from the starting index of the given array.
  67164. * @param array the array to pull values from
  67165. * @param offset the offset into the array to start at
  67166. * @param result the vector to store the result in
  67167. */
  67168. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  67169. /**
  67170. * Updates the given vector "result" from the starting index of the given Float32Array.
  67171. * @param array the array to pull values from
  67172. * @param offset the offset into the array to start at
  67173. * @param result the vector to store the result in
  67174. */
  67175. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  67176. /**
  67177. * Updates the given vector "result" coordinates from the given floats.
  67178. * @param x float to set from
  67179. * @param y float to set from
  67180. * @param z float to set from
  67181. * @param w float to set from
  67182. * @param result the vector to the floats in
  67183. */
  67184. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  67185. /**
  67186. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  67187. * @returns the new vector
  67188. */
  67189. static Zero(): Vector4;
  67190. /**
  67191. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  67192. * @returns the new vector
  67193. */
  67194. static One(): Vector4;
  67195. /**
  67196. * Returns a new normalized Vector4 from the given one.
  67197. * @param vector the vector to normalize
  67198. * @returns the vector
  67199. */
  67200. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  67201. /**
  67202. * Updates the given vector "result" from the normalization of the given one.
  67203. * @param vector the vector to normalize
  67204. * @param result the vector to store the result in
  67205. */
  67206. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  67207. /**
  67208. * Returns a vector with the minimum values from the left and right vectors
  67209. * @param left left vector to minimize
  67210. * @param right right vector to minimize
  67211. * @returns a new vector with the minimum of the left and right vector values
  67212. */
  67213. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67214. /**
  67215. * Returns a vector with the maximum values from the left and right vectors
  67216. * @param left left vector to maximize
  67217. * @param right right vector to maximize
  67218. * @returns a new vector with the maximum of the left and right vector values
  67219. */
  67220. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67221. /**
  67222. * Returns the distance (float) between the vectors "value1" and "value2".
  67223. * @param value1 value to calulate the distance between
  67224. * @param value2 value to calulate the distance between
  67225. * @return the distance between the two vectors
  67226. */
  67227. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67228. /**
  67229. * Returns the squared distance (float) between the vectors "value1" and "value2".
  67230. * @param value1 value to calulate the distance between
  67231. * @param value2 value to calulate the distance between
  67232. * @return the distance between the two vectors squared
  67233. */
  67234. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67235. /**
  67236. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  67237. * @param value1 value to calulate the center between
  67238. * @param value2 value to calulate the center between
  67239. * @return the center between the two vectors
  67240. */
  67241. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  67242. /**
  67243. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  67244. * This methods computes transformed normalized direction vectors only.
  67245. * @param vector the vector to transform
  67246. * @param transformation the transformation matrix to apply
  67247. * @returns the new vector
  67248. */
  67249. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  67250. /**
  67251. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  67252. * This methods computes transformed normalized direction vectors only.
  67253. * @param vector the vector to transform
  67254. * @param transformation the transformation matrix to apply
  67255. * @param result the vector to store the result in
  67256. */
  67257. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67258. /**
  67259. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  67260. * This methods computes transformed normalized direction vectors only.
  67261. * @param x value to transform
  67262. * @param y value to transform
  67263. * @param z value to transform
  67264. * @param w value to transform
  67265. * @param transformation the transformation matrix to apply
  67266. * @param result the vector to store the results in
  67267. */
  67268. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67269. /**
  67270. * Creates a new Vector4 from a Vector3
  67271. * @param source defines the source data
  67272. * @param w defines the 4th component (default is 0)
  67273. * @returns a new Vector4
  67274. */
  67275. static FromVector3(source: Vector3, w?: number): Vector4;
  67276. }
  67277. /**
  67278. * Class used to store quaternion data
  67279. * @see https://en.wikipedia.org/wiki/Quaternion
  67280. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  67281. */
  67282. export class Quaternion {
  67283. /** defines the first component (0 by default) */
  67284. x: number;
  67285. /** defines the second component (0 by default) */
  67286. y: number;
  67287. /** defines the third component (0 by default) */
  67288. z: number;
  67289. /** defines the fourth component (1.0 by default) */
  67290. w: number;
  67291. /**
  67292. * Creates a new Quaternion from the given floats
  67293. * @param x defines the first component (0 by default)
  67294. * @param y defines the second component (0 by default)
  67295. * @param z defines the third component (0 by default)
  67296. * @param w defines the fourth component (1.0 by default)
  67297. */
  67298. constructor(
  67299. /** defines the first component (0 by default) */
  67300. x?: number,
  67301. /** defines the second component (0 by default) */
  67302. y?: number,
  67303. /** defines the third component (0 by default) */
  67304. z?: number,
  67305. /** defines the fourth component (1.0 by default) */
  67306. w?: number);
  67307. /**
  67308. * Gets a string representation for the current quaternion
  67309. * @returns a string with the Quaternion coordinates
  67310. */
  67311. toString(): string;
  67312. /**
  67313. * Gets the class name of the quaternion
  67314. * @returns the string "Quaternion"
  67315. */
  67316. getClassName(): string;
  67317. /**
  67318. * Gets a hash code for this quaternion
  67319. * @returns the quaternion hash code
  67320. */
  67321. getHashCode(): number;
  67322. /**
  67323. * Copy the quaternion to an array
  67324. * @returns a new array populated with 4 elements from the quaternion coordinates
  67325. */
  67326. asArray(): number[];
  67327. /**
  67328. * Check if two quaternions are equals
  67329. * @param otherQuaternion defines the second operand
  67330. * @return true if the current quaternion and the given one coordinates are strictly equals
  67331. */
  67332. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  67333. /**
  67334. * Clone the current quaternion
  67335. * @returns a new quaternion copied from the current one
  67336. */
  67337. clone(): Quaternion;
  67338. /**
  67339. * Copy a quaternion to the current one
  67340. * @param other defines the other quaternion
  67341. * @returns the updated current quaternion
  67342. */
  67343. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  67344. /**
  67345. * Updates the current quaternion with the given float coordinates
  67346. * @param x defines the x coordinate
  67347. * @param y defines the y coordinate
  67348. * @param z defines the z coordinate
  67349. * @param w defines the w coordinate
  67350. * @returns the updated current quaternion
  67351. */
  67352. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  67353. /**
  67354. * Updates the current quaternion from the given float coordinates
  67355. * @param x defines the x coordinate
  67356. * @param y defines the y coordinate
  67357. * @param z defines the z coordinate
  67358. * @param w defines the w coordinate
  67359. * @returns the updated current quaternion
  67360. */
  67361. set(x: number, y: number, z: number, w: number): Quaternion;
  67362. /**
  67363. * Adds two quaternions
  67364. * @param other defines the second operand
  67365. * @returns a new quaternion as the addition result of the given one and the current quaternion
  67366. */
  67367. add(other: DeepImmutable<Quaternion>): Quaternion;
  67368. /**
  67369. * Add a quaternion to the current one
  67370. * @param other defines the quaternion to add
  67371. * @returns the current quaternion
  67372. */
  67373. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  67374. /**
  67375. * Subtract two quaternions
  67376. * @param other defines the second operand
  67377. * @returns a new quaternion as the subtraction result of the given one from the current one
  67378. */
  67379. subtract(other: Quaternion): Quaternion;
  67380. /**
  67381. * Multiplies the current quaternion by a scale factor
  67382. * @param value defines the scale factor
  67383. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  67384. */
  67385. scale(value: number): Quaternion;
  67386. /**
  67387. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  67388. * @param scale defines the scale factor
  67389. * @param result defines the Quaternion object where to store the result
  67390. * @returns the unmodified current quaternion
  67391. */
  67392. scaleToRef(scale: number, result: Quaternion): Quaternion;
  67393. /**
  67394. * Multiplies in place the current quaternion by a scale factor
  67395. * @param value defines the scale factor
  67396. * @returns the current modified quaternion
  67397. */
  67398. scaleInPlace(value: number): Quaternion;
  67399. /**
  67400. * Scale the current quaternion values by a factor and add the result to a given quaternion
  67401. * @param scale defines the scale factor
  67402. * @param result defines the Quaternion object where to store the result
  67403. * @returns the unmodified current quaternion
  67404. */
  67405. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  67406. /**
  67407. * Multiplies two quaternions
  67408. * @param q1 defines the second operand
  67409. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  67410. */
  67411. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  67412. /**
  67413. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  67414. * @param q1 defines the second operand
  67415. * @param result defines the target quaternion
  67416. * @returns the current quaternion
  67417. */
  67418. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  67419. /**
  67420. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  67421. * @param q1 defines the second operand
  67422. * @returns the currentupdated quaternion
  67423. */
  67424. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  67425. /**
  67426. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  67427. * @param ref defines the target quaternion
  67428. * @returns the current quaternion
  67429. */
  67430. conjugateToRef(ref: Quaternion): Quaternion;
  67431. /**
  67432. * Conjugates in place (1-q) the current quaternion
  67433. * @returns the current updated quaternion
  67434. */
  67435. conjugateInPlace(): Quaternion;
  67436. /**
  67437. * Conjugates in place (1-q) the current quaternion
  67438. * @returns a new quaternion
  67439. */
  67440. conjugate(): Quaternion;
  67441. /**
  67442. * Gets length of current quaternion
  67443. * @returns the quaternion length (float)
  67444. */
  67445. length(): number;
  67446. /**
  67447. * Normalize in place the current quaternion
  67448. * @returns the current updated quaternion
  67449. */
  67450. normalize(): Quaternion;
  67451. /**
  67452. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  67453. * @param order is a reserved parameter and is ignore for now
  67454. * @returns a new Vector3 containing the Euler angles
  67455. */
  67456. toEulerAngles(order?: string): Vector3;
  67457. /**
  67458. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  67459. * @param result defines the vector which will be filled with the Euler angles
  67460. * @param order is a reserved parameter and is ignore for now
  67461. * @returns the current unchanged quaternion
  67462. */
  67463. toEulerAnglesToRef(result: Vector3): Quaternion;
  67464. /**
  67465. * Updates the given rotation matrix with the current quaternion values
  67466. * @param result defines the target matrix
  67467. * @returns the current unchanged quaternion
  67468. */
  67469. toRotationMatrix(result: Matrix): Quaternion;
  67470. /**
  67471. * Updates the current quaternion from the given rotation matrix values
  67472. * @param matrix defines the source matrix
  67473. * @returns the current updated quaternion
  67474. */
  67475. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67476. /**
  67477. * Creates a new quaternion from a rotation matrix
  67478. * @param matrix defines the source matrix
  67479. * @returns a new quaternion created from the given rotation matrix values
  67480. */
  67481. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67482. /**
  67483. * Updates the given quaternion with the given rotation matrix values
  67484. * @param matrix defines the source matrix
  67485. * @param result defines the target quaternion
  67486. */
  67487. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  67488. /**
  67489. * Returns the dot product (float) between the quaternions "left" and "right"
  67490. * @param left defines the left operand
  67491. * @param right defines the right operand
  67492. * @returns the dot product
  67493. */
  67494. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  67495. /**
  67496. * Checks if the two quaternions are close to each other
  67497. * @param quat0 defines the first quaternion to check
  67498. * @param quat1 defines the second quaternion to check
  67499. * @returns true if the two quaternions are close to each other
  67500. */
  67501. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  67502. /**
  67503. * Creates an empty quaternion
  67504. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  67505. */
  67506. static Zero(): Quaternion;
  67507. /**
  67508. * Inverse a given quaternion
  67509. * @param q defines the source quaternion
  67510. * @returns a new quaternion as the inverted current quaternion
  67511. */
  67512. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  67513. /**
  67514. * Inverse a given quaternion
  67515. * @param q defines the source quaternion
  67516. * @param result the quaternion the result will be stored in
  67517. * @returns the result quaternion
  67518. */
  67519. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  67520. /**
  67521. * Creates an identity quaternion
  67522. * @returns the identity quaternion
  67523. */
  67524. static Identity(): Quaternion;
  67525. /**
  67526. * Gets a boolean indicating if the given quaternion is identity
  67527. * @param quaternion defines the quaternion to check
  67528. * @returns true if the quaternion is identity
  67529. */
  67530. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  67531. /**
  67532. * Creates a quaternion from a rotation around an axis
  67533. * @param axis defines the axis to use
  67534. * @param angle defines the angle to use
  67535. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  67536. */
  67537. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  67538. /**
  67539. * Creates a rotation around an axis and stores it into the given quaternion
  67540. * @param axis defines the axis to use
  67541. * @param angle defines the angle to use
  67542. * @param result defines the target quaternion
  67543. * @returns the target quaternion
  67544. */
  67545. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  67546. /**
  67547. * Creates a new quaternion from data stored into an array
  67548. * @param array defines the data source
  67549. * @param offset defines the offset in the source array where the data starts
  67550. * @returns a new quaternion
  67551. */
  67552. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  67553. /**
  67554. * Create a quaternion from Euler rotation angles
  67555. * @param x Pitch
  67556. * @param y Yaw
  67557. * @param z Roll
  67558. * @returns the new Quaternion
  67559. */
  67560. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  67561. /**
  67562. * Updates a quaternion from Euler rotation angles
  67563. * @param x Pitch
  67564. * @param y Yaw
  67565. * @param z Roll
  67566. * @param result the quaternion to store the result
  67567. * @returns the updated quaternion
  67568. */
  67569. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  67570. /**
  67571. * Create a quaternion from Euler rotation vector
  67572. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67573. * @returns the new Quaternion
  67574. */
  67575. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  67576. /**
  67577. * Updates a quaternion from Euler rotation vector
  67578. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67579. * @param result the quaternion to store the result
  67580. * @returns the updated quaternion
  67581. */
  67582. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  67583. /**
  67584. * Creates a new quaternion from the given Euler float angles (y, x, z)
  67585. * @param yaw defines the rotation around Y axis
  67586. * @param pitch defines the rotation around X axis
  67587. * @param roll defines the rotation around Z axis
  67588. * @returns the new quaternion
  67589. */
  67590. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  67591. /**
  67592. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  67593. * @param yaw defines the rotation around Y axis
  67594. * @param pitch defines the rotation around X axis
  67595. * @param roll defines the rotation around Z axis
  67596. * @param result defines the target quaternion
  67597. */
  67598. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  67599. /**
  67600. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  67601. * @param alpha defines the rotation around first axis
  67602. * @param beta defines the rotation around second axis
  67603. * @param gamma defines the rotation around third axis
  67604. * @returns the new quaternion
  67605. */
  67606. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  67607. /**
  67608. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  67609. * @param alpha defines the rotation around first axis
  67610. * @param beta defines the rotation around second axis
  67611. * @param gamma defines the rotation around third axis
  67612. * @param result defines the target quaternion
  67613. */
  67614. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  67615. /**
  67616. * 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)
  67617. * @param axis1 defines the first axis
  67618. * @param axis2 defines the second axis
  67619. * @param axis3 defines the third axis
  67620. * @returns the new quaternion
  67621. */
  67622. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  67623. /**
  67624. * 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
  67625. * @param axis1 defines the first axis
  67626. * @param axis2 defines the second axis
  67627. * @param axis3 defines the third axis
  67628. * @param ref defines the target quaternion
  67629. */
  67630. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67631. /**
  67632. * Interpolates between two quaternions
  67633. * @param left defines first quaternion
  67634. * @param right defines second quaternion
  67635. * @param amount defines the gradient to use
  67636. * @returns the new interpolated quaternion
  67637. */
  67638. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67639. /**
  67640. * Interpolates between two quaternions and stores it into a target quaternion
  67641. * @param left defines first quaternion
  67642. * @param right defines second quaternion
  67643. * @param amount defines the gradient to use
  67644. * @param result defines the target quaternion
  67645. */
  67646. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67647. /**
  67648. * Interpolate between two quaternions using Hermite interpolation
  67649. * @param value1 defines first quaternion
  67650. * @param tangent1 defines the incoming tangent
  67651. * @param value2 defines second quaternion
  67652. * @param tangent2 defines the outgoing tangent
  67653. * @param amount defines the target quaternion
  67654. * @returns the new interpolated quaternion
  67655. */
  67656. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67657. }
  67658. /**
  67659. * Class used to store matrix data (4x4)
  67660. */
  67661. export class Matrix {
  67662. private static _updateFlagSeed;
  67663. private static _identityReadOnly;
  67664. private _isIdentity;
  67665. private _isIdentityDirty;
  67666. private _isIdentity3x2;
  67667. private _isIdentity3x2Dirty;
  67668. /**
  67669. * Gets the update flag of the matrix which is an unique number for the matrix.
  67670. * It will be incremented every time the matrix data change.
  67671. * You can use it to speed the comparison between two versions of the same matrix.
  67672. */
  67673. updateFlag: number;
  67674. private readonly _m;
  67675. /**
  67676. * Gets the internal data of the matrix
  67677. */
  67678. readonly m: DeepImmutable<Float32Array>;
  67679. /** @hidden */
  67680. _markAsUpdated(): void;
  67681. /** @hidden */
  67682. private _updateIdentityStatus;
  67683. /**
  67684. * Creates an empty matrix (filled with zeros)
  67685. */
  67686. constructor();
  67687. /**
  67688. * Check if the current matrix is identity
  67689. * @returns true is the matrix is the identity matrix
  67690. */
  67691. isIdentity(): boolean;
  67692. /**
  67693. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67694. * @returns true is the matrix is the identity matrix
  67695. */
  67696. isIdentityAs3x2(): boolean;
  67697. /**
  67698. * Gets the determinant of the matrix
  67699. * @returns the matrix determinant
  67700. */
  67701. determinant(): number;
  67702. /**
  67703. * Returns the matrix as a Float32Array
  67704. * @returns the matrix underlying array
  67705. */
  67706. toArray(): DeepImmutable<Float32Array>;
  67707. /**
  67708. * Returns the matrix as a Float32Array
  67709. * @returns the matrix underlying array.
  67710. */
  67711. asArray(): DeepImmutable<Float32Array>;
  67712. /**
  67713. * Inverts the current matrix in place
  67714. * @returns the current inverted matrix
  67715. */
  67716. invert(): Matrix;
  67717. /**
  67718. * Sets all the matrix elements to zero
  67719. * @returns the current matrix
  67720. */
  67721. reset(): Matrix;
  67722. /**
  67723. * Adds the current matrix with a second one
  67724. * @param other defines the matrix to add
  67725. * @returns a new matrix as the addition of the current matrix and the given one
  67726. */
  67727. add(other: DeepImmutable<Matrix>): Matrix;
  67728. /**
  67729. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67730. * @param other defines the matrix to add
  67731. * @param result defines the target matrix
  67732. * @returns the current matrix
  67733. */
  67734. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67735. /**
  67736. * Adds in place the given matrix to the current matrix
  67737. * @param other defines the second operand
  67738. * @returns the current updated matrix
  67739. */
  67740. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67741. /**
  67742. * Sets the given matrix to the current inverted Matrix
  67743. * @param other defines the target matrix
  67744. * @returns the unmodified current matrix
  67745. */
  67746. invertToRef(other: Matrix): Matrix;
  67747. /**
  67748. * add a value at the specified position in the current Matrix
  67749. * @param index the index of the value within the matrix. between 0 and 15.
  67750. * @param value the value to be added
  67751. * @returns the current updated matrix
  67752. */
  67753. addAtIndex(index: number, value: number): Matrix;
  67754. /**
  67755. * mutiply the specified position in the current Matrix by a value
  67756. * @param index the index of the value within the matrix. between 0 and 15.
  67757. * @param value the value to be added
  67758. * @returns the current updated matrix
  67759. */
  67760. multiplyAtIndex(index: number, value: number): Matrix;
  67761. /**
  67762. * Inserts the translation vector (using 3 floats) in the current matrix
  67763. * @param x defines the 1st component of the translation
  67764. * @param y defines the 2nd component of the translation
  67765. * @param z defines the 3rd component of the translation
  67766. * @returns the current updated matrix
  67767. */
  67768. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67769. /**
  67770. * Adds the translation vector (using 3 floats) in the current matrix
  67771. * @param x defines the 1st component of the translation
  67772. * @param y defines the 2nd component of the translation
  67773. * @param z defines the 3rd component of the translation
  67774. * @returns the current updated matrix
  67775. */
  67776. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67777. /**
  67778. * Inserts the translation vector in the current matrix
  67779. * @param vector3 defines the translation to insert
  67780. * @returns the current updated matrix
  67781. */
  67782. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67783. /**
  67784. * Gets the translation value of the current matrix
  67785. * @returns a new Vector3 as the extracted translation from the matrix
  67786. */
  67787. getTranslation(): Vector3;
  67788. /**
  67789. * Fill a Vector3 with the extracted translation from the matrix
  67790. * @param result defines the Vector3 where to store the translation
  67791. * @returns the current matrix
  67792. */
  67793. getTranslationToRef(result: Vector3): Matrix;
  67794. /**
  67795. * Remove rotation and scaling part from the matrix
  67796. * @returns the updated matrix
  67797. */
  67798. removeRotationAndScaling(): Matrix;
  67799. /**
  67800. * Multiply two matrices
  67801. * @param other defines the second operand
  67802. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67803. */
  67804. multiply(other: DeepImmutable<Matrix>): Matrix;
  67805. /**
  67806. * Copy the current matrix from the given one
  67807. * @param other defines the source matrix
  67808. * @returns the current updated matrix
  67809. */
  67810. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67811. /**
  67812. * Populates the given array from the starting index with the current matrix values
  67813. * @param array defines the target array
  67814. * @param offset defines the offset in the target array where to start storing values
  67815. * @returns the current matrix
  67816. */
  67817. copyToArray(array: Float32Array, offset?: number): Matrix;
  67818. /**
  67819. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67820. * @param other defines the second operand
  67821. * @param result defines the matrix where to store the multiplication
  67822. * @returns the current matrix
  67823. */
  67824. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67825. /**
  67826. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67827. * @param other defines the second operand
  67828. * @param result defines the array where to store the multiplication
  67829. * @param offset defines the offset in the target array where to start storing values
  67830. * @returns the current matrix
  67831. */
  67832. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67833. /**
  67834. * Check equality between this matrix and a second one
  67835. * @param value defines the second matrix to compare
  67836. * @returns true is the current matrix and the given one values are strictly equal
  67837. */
  67838. equals(value: DeepImmutable<Matrix>): boolean;
  67839. /**
  67840. * Clone the current matrix
  67841. * @returns a new matrix from the current matrix
  67842. */
  67843. clone(): Matrix;
  67844. /**
  67845. * Returns the name of the current matrix class
  67846. * @returns the string "Matrix"
  67847. */
  67848. getClassName(): string;
  67849. /**
  67850. * Gets the hash code of the current matrix
  67851. * @returns the hash code
  67852. */
  67853. getHashCode(): number;
  67854. /**
  67855. * Decomposes the current Matrix into a translation, rotation and scaling components
  67856. * @param scale defines the scale vector3 given as a reference to update
  67857. * @param rotation defines the rotation quaternion given as a reference to update
  67858. * @param translation defines the translation vector3 given as a reference to update
  67859. * @returns true if operation was successful
  67860. */
  67861. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  67862. /**
  67863. * Gets specific row of the matrix
  67864. * @param index defines the number of the row to get
  67865. * @returns the index-th row of the current matrix as a new Vector4
  67866. */
  67867. getRow(index: number): Nullable<Vector4>;
  67868. /**
  67869. * Sets the index-th row of the current matrix to the vector4 values
  67870. * @param index defines the number of the row to set
  67871. * @param row defines the target vector4
  67872. * @returns the updated current matrix
  67873. */
  67874. setRow(index: number, row: Vector4): Matrix;
  67875. /**
  67876. * Compute the transpose of the matrix
  67877. * @returns the new transposed matrix
  67878. */
  67879. transpose(): Matrix;
  67880. /**
  67881. * Compute the transpose of the matrix and store it in a given matrix
  67882. * @param result defines the target matrix
  67883. * @returns the current matrix
  67884. */
  67885. transposeToRef(result: Matrix): Matrix;
  67886. /**
  67887. * Sets the index-th row of the current matrix with the given 4 x float values
  67888. * @param index defines the row index
  67889. * @param x defines the x component to set
  67890. * @param y defines the y component to set
  67891. * @param z defines the z component to set
  67892. * @param w defines the w component to set
  67893. * @returns the updated current matrix
  67894. */
  67895. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  67896. /**
  67897. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  67898. * @param scale defines the scale factor
  67899. * @returns a new matrix
  67900. */
  67901. scale(scale: number): Matrix;
  67902. /**
  67903. * Scale the current matrix values by a factor to a given result matrix
  67904. * @param scale defines the scale factor
  67905. * @param result defines the matrix to store the result
  67906. * @returns the current matrix
  67907. */
  67908. scaleToRef(scale: number, result: Matrix): Matrix;
  67909. /**
  67910. * Scale the current matrix values by a factor and add the result to a given matrix
  67911. * @param scale defines the scale factor
  67912. * @param result defines the Matrix to store the result
  67913. * @returns the current matrix
  67914. */
  67915. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  67916. /**
  67917. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  67918. * @param ref matrix to store the result
  67919. */
  67920. toNormalMatrix(ref: Matrix): void;
  67921. /**
  67922. * Gets only rotation part of the current matrix
  67923. * @returns a new matrix sets to the extracted rotation matrix from the current one
  67924. */
  67925. getRotationMatrix(): Matrix;
  67926. /**
  67927. * Extracts the rotation matrix from the current one and sets it as the given "result"
  67928. * @param result defines the target matrix to store data to
  67929. * @returns the current matrix
  67930. */
  67931. getRotationMatrixToRef(result: Matrix): Matrix;
  67932. /**
  67933. * Toggles model matrix from being right handed to left handed in place and vice versa
  67934. */
  67935. toggleModelMatrixHandInPlace(): void;
  67936. /**
  67937. * Toggles projection matrix from being right handed to left handed in place and vice versa
  67938. */
  67939. toggleProjectionMatrixHandInPlace(): void;
  67940. /**
  67941. * Creates a matrix from an array
  67942. * @param array defines the source array
  67943. * @param offset defines an offset in the source array
  67944. * @returns a new Matrix set from the starting index of the given array
  67945. */
  67946. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  67947. /**
  67948. * Copy the content of an array into a given matrix
  67949. * @param array defines the source array
  67950. * @param offset defines an offset in the source array
  67951. * @param result defines the target matrix
  67952. */
  67953. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  67954. /**
  67955. * Stores an array into a matrix after having multiplied each component by a given factor
  67956. * @param array defines the source array
  67957. * @param offset defines the offset in the source array
  67958. * @param scale defines the scaling factor
  67959. * @param result defines the target matrix
  67960. */
  67961. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  67962. /**
  67963. * Gets an identity matrix that must not be updated
  67964. */
  67965. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  67966. /**
  67967. * Stores a list of values (16) inside a given matrix
  67968. * @param initialM11 defines 1st value of 1st row
  67969. * @param initialM12 defines 2nd value of 1st row
  67970. * @param initialM13 defines 3rd value of 1st row
  67971. * @param initialM14 defines 4th value of 1st row
  67972. * @param initialM21 defines 1st value of 2nd row
  67973. * @param initialM22 defines 2nd value of 2nd row
  67974. * @param initialM23 defines 3rd value of 2nd row
  67975. * @param initialM24 defines 4th value of 2nd row
  67976. * @param initialM31 defines 1st value of 3rd row
  67977. * @param initialM32 defines 2nd value of 3rd row
  67978. * @param initialM33 defines 3rd value of 3rd row
  67979. * @param initialM34 defines 4th value of 3rd row
  67980. * @param initialM41 defines 1st value of 4th row
  67981. * @param initialM42 defines 2nd value of 4th row
  67982. * @param initialM43 defines 3rd value of 4th row
  67983. * @param initialM44 defines 4th value of 4th row
  67984. * @param result defines the target matrix
  67985. */
  67986. 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;
  67987. /**
  67988. * Creates new matrix from a list of values (16)
  67989. * @param initialM11 defines 1st value of 1st row
  67990. * @param initialM12 defines 2nd value of 1st row
  67991. * @param initialM13 defines 3rd value of 1st row
  67992. * @param initialM14 defines 4th value of 1st row
  67993. * @param initialM21 defines 1st value of 2nd row
  67994. * @param initialM22 defines 2nd value of 2nd row
  67995. * @param initialM23 defines 3rd value of 2nd row
  67996. * @param initialM24 defines 4th value of 2nd row
  67997. * @param initialM31 defines 1st value of 3rd row
  67998. * @param initialM32 defines 2nd value of 3rd row
  67999. * @param initialM33 defines 3rd value of 3rd row
  68000. * @param initialM34 defines 4th value of 3rd row
  68001. * @param initialM41 defines 1st value of 4th row
  68002. * @param initialM42 defines 2nd value of 4th row
  68003. * @param initialM43 defines 3rd value of 4th row
  68004. * @param initialM44 defines 4th value of 4th row
  68005. * @returns the new matrix
  68006. */
  68007. 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;
  68008. /**
  68009. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68010. * @param scale defines the scale vector3
  68011. * @param rotation defines the rotation quaternion
  68012. * @param translation defines the translation vector3
  68013. * @returns a new matrix
  68014. */
  68015. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  68016. /**
  68017. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68018. * @param scale defines the scale vector3
  68019. * @param rotation defines the rotation quaternion
  68020. * @param translation defines the translation vector3
  68021. * @param result defines the target matrix
  68022. */
  68023. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  68024. /**
  68025. * Creates a new identity matrix
  68026. * @returns a new identity matrix
  68027. */
  68028. static Identity(): Matrix;
  68029. /**
  68030. * Creates a new identity matrix and stores the result in a given matrix
  68031. * @param result defines the target matrix
  68032. */
  68033. static IdentityToRef(result: Matrix): void;
  68034. /**
  68035. * Creates a new zero matrix
  68036. * @returns a new zero matrix
  68037. */
  68038. static Zero(): Matrix;
  68039. /**
  68040. * Creates a new rotation matrix for "angle" radians around the X axis
  68041. * @param angle defines the angle (in radians) to use
  68042. * @return the new matrix
  68043. */
  68044. static RotationX(angle: number): Matrix;
  68045. /**
  68046. * Creates a new matrix as the invert of a given matrix
  68047. * @param source defines the source matrix
  68048. * @returns the new matrix
  68049. */
  68050. static Invert(source: DeepImmutable<Matrix>): Matrix;
  68051. /**
  68052. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  68053. * @param angle defines the angle (in radians) to use
  68054. * @param result defines the target matrix
  68055. */
  68056. static RotationXToRef(angle: number, result: Matrix): void;
  68057. /**
  68058. * Creates a new rotation matrix for "angle" radians around the Y axis
  68059. * @param angle defines the angle (in radians) to use
  68060. * @return the new matrix
  68061. */
  68062. static RotationY(angle: number): Matrix;
  68063. /**
  68064. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  68065. * @param angle defines the angle (in radians) to use
  68066. * @param result defines the target matrix
  68067. */
  68068. static RotationYToRef(angle: number, result: Matrix): void;
  68069. /**
  68070. * Creates a new rotation matrix for "angle" radians around the Z axis
  68071. * @param angle defines the angle (in radians) to use
  68072. * @return the new matrix
  68073. */
  68074. static RotationZ(angle: number): Matrix;
  68075. /**
  68076. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  68077. * @param angle defines the angle (in radians) to use
  68078. * @param result defines the target matrix
  68079. */
  68080. static RotationZToRef(angle: number, result: Matrix): void;
  68081. /**
  68082. * Creates a new rotation matrix for "angle" radians around the given axis
  68083. * @param axis defines the axis to use
  68084. * @param angle defines the angle (in radians) to use
  68085. * @return the new matrix
  68086. */
  68087. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  68088. /**
  68089. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  68090. * @param axis defines the axis to use
  68091. * @param angle defines the angle (in radians) to use
  68092. * @param result defines the target matrix
  68093. */
  68094. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  68095. /**
  68096. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  68097. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  68098. * @param from defines the vector to align
  68099. * @param to defines the vector to align to
  68100. * @param result defines the target matrix
  68101. */
  68102. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  68103. /**
  68104. * Creates a rotation matrix
  68105. * @param yaw defines the yaw angle in radians (Y axis)
  68106. * @param pitch defines the pitch angle in radians (X axis)
  68107. * @param roll defines the roll angle in radians (X axis)
  68108. * @returns the new rotation matrix
  68109. */
  68110. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  68111. /**
  68112. * Creates a rotation matrix and stores it in a given matrix
  68113. * @param yaw defines the yaw angle in radians (Y axis)
  68114. * @param pitch defines the pitch angle in radians (X axis)
  68115. * @param roll defines the roll angle in radians (X axis)
  68116. * @param result defines the target matrix
  68117. */
  68118. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  68119. /**
  68120. * Creates a scaling matrix
  68121. * @param x defines the scale factor on X axis
  68122. * @param y defines the scale factor on Y axis
  68123. * @param z defines the scale factor on Z axis
  68124. * @returns the new matrix
  68125. */
  68126. static Scaling(x: number, y: number, z: number): Matrix;
  68127. /**
  68128. * Creates a scaling matrix and stores it in a given matrix
  68129. * @param x defines the scale factor on X axis
  68130. * @param y defines the scale factor on Y axis
  68131. * @param z defines the scale factor on Z axis
  68132. * @param result defines the target matrix
  68133. */
  68134. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  68135. /**
  68136. * Creates a translation matrix
  68137. * @param x defines the translation on X axis
  68138. * @param y defines the translation on Y axis
  68139. * @param z defines the translationon Z axis
  68140. * @returns the new matrix
  68141. */
  68142. static Translation(x: number, y: number, z: number): Matrix;
  68143. /**
  68144. * Creates a translation matrix and stores it in a given matrix
  68145. * @param x defines the translation on X axis
  68146. * @param y defines the translation on Y axis
  68147. * @param z defines the translationon Z axis
  68148. * @param result defines the target matrix
  68149. */
  68150. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  68151. /**
  68152. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68153. * @param startValue defines the start value
  68154. * @param endValue defines the end value
  68155. * @param gradient defines the gradient factor
  68156. * @returns the new matrix
  68157. */
  68158. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68159. /**
  68160. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68161. * @param startValue defines the start value
  68162. * @param endValue defines the end value
  68163. * @param gradient defines the gradient factor
  68164. * @param result defines the Matrix object where to store data
  68165. */
  68166. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68167. /**
  68168. * Builds a new matrix whose values are computed by:
  68169. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68170. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68171. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68172. * @param startValue defines the first matrix
  68173. * @param endValue defines the second matrix
  68174. * @param gradient defines the gradient between the two matrices
  68175. * @returns the new matrix
  68176. */
  68177. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68178. /**
  68179. * Update a matrix to values which are computed by:
  68180. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68181. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68182. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68183. * @param startValue defines the first matrix
  68184. * @param endValue defines the second matrix
  68185. * @param gradient defines the gradient between the two matrices
  68186. * @param result defines the target matrix
  68187. */
  68188. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68189. /**
  68190. * 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"
  68191. * This function works in left handed mode
  68192. * @param eye defines the final position of the entity
  68193. * @param target defines where the entity should look at
  68194. * @param up defines the up vector for the entity
  68195. * @returns the new matrix
  68196. */
  68197. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68198. /**
  68199. * 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".
  68200. * This function works in left handed mode
  68201. * @param eye defines the final position of the entity
  68202. * @param target defines where the entity should look at
  68203. * @param up defines the up vector for the entity
  68204. * @param result defines the target matrix
  68205. */
  68206. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68207. /**
  68208. * 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"
  68209. * This function works in right handed mode
  68210. * @param eye defines the final position of the entity
  68211. * @param target defines where the entity should look at
  68212. * @param up defines the up vector for the entity
  68213. * @returns the new matrix
  68214. */
  68215. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68216. /**
  68217. * 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".
  68218. * This function works in right handed mode
  68219. * @param eye defines the final position of the entity
  68220. * @param target defines where the entity should look at
  68221. * @param up defines the up vector for the entity
  68222. * @param result defines the target matrix
  68223. */
  68224. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68225. /**
  68226. * Create a left-handed orthographic projection matrix
  68227. * @param width defines the viewport width
  68228. * @param height defines the viewport height
  68229. * @param znear defines the near clip plane
  68230. * @param zfar defines the far clip plane
  68231. * @returns a new matrix as a left-handed orthographic projection matrix
  68232. */
  68233. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68234. /**
  68235. * Store a left-handed orthographic projection to a given matrix
  68236. * @param width defines the viewport width
  68237. * @param height defines the viewport height
  68238. * @param znear defines the near clip plane
  68239. * @param zfar defines the far clip plane
  68240. * @param result defines the target matrix
  68241. */
  68242. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  68243. /**
  68244. * Create a left-handed orthographic projection matrix
  68245. * @param left defines the viewport left coordinate
  68246. * @param right defines the viewport right coordinate
  68247. * @param bottom defines the viewport bottom coordinate
  68248. * @param top defines the viewport top coordinate
  68249. * @param znear defines the near clip plane
  68250. * @param zfar defines the far clip plane
  68251. * @returns a new matrix as a left-handed orthographic projection matrix
  68252. */
  68253. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68254. /**
  68255. * Stores a left-handed orthographic projection into a given matrix
  68256. * @param left defines the viewport left coordinate
  68257. * @param right defines the viewport right coordinate
  68258. * @param bottom defines the viewport bottom coordinate
  68259. * @param top defines the viewport top coordinate
  68260. * @param znear defines the near clip plane
  68261. * @param zfar defines the far clip plane
  68262. * @param result defines the target matrix
  68263. */
  68264. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68265. /**
  68266. * Creates a right-handed orthographic projection matrix
  68267. * @param left defines the viewport left coordinate
  68268. * @param right defines the viewport right coordinate
  68269. * @param bottom defines the viewport bottom coordinate
  68270. * @param top defines the viewport top coordinate
  68271. * @param znear defines the near clip plane
  68272. * @param zfar defines the far clip plane
  68273. * @returns a new matrix as a right-handed orthographic projection matrix
  68274. */
  68275. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68276. /**
  68277. * Stores a right-handed orthographic projection into a given matrix
  68278. * @param left defines the viewport left coordinate
  68279. * @param right defines the viewport right coordinate
  68280. * @param bottom defines the viewport bottom coordinate
  68281. * @param top defines the viewport top coordinate
  68282. * @param znear defines the near clip plane
  68283. * @param zfar defines the far clip plane
  68284. * @param result defines the target matrix
  68285. */
  68286. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68287. /**
  68288. * Creates a left-handed perspective projection matrix
  68289. * @param width defines the viewport width
  68290. * @param height defines the viewport height
  68291. * @param znear defines the near clip plane
  68292. * @param zfar defines the far clip plane
  68293. * @returns a new matrix as a left-handed perspective projection matrix
  68294. */
  68295. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68296. /**
  68297. * Creates a left-handed perspective projection matrix
  68298. * @param fov defines the horizontal field of view
  68299. * @param aspect defines the aspect ratio
  68300. * @param znear defines the near clip plane
  68301. * @param zfar defines the far clip plane
  68302. * @returns a new matrix as a left-handed perspective projection matrix
  68303. */
  68304. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68305. /**
  68306. * Stores a left-handed perspective projection into a given matrix
  68307. * @param fov defines the horizontal field of view
  68308. * @param aspect defines the aspect ratio
  68309. * @param znear defines the near clip plane
  68310. * @param zfar defines the far clip plane
  68311. * @param result defines the target matrix
  68312. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68313. */
  68314. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68315. /**
  68316. * Creates a right-handed perspective projection matrix
  68317. * @param fov defines the horizontal field of view
  68318. * @param aspect defines the aspect ratio
  68319. * @param znear defines the near clip plane
  68320. * @param zfar defines the far clip plane
  68321. * @returns a new matrix as a right-handed perspective projection matrix
  68322. */
  68323. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68324. /**
  68325. * Stores a right-handed perspective projection into a given matrix
  68326. * @param fov defines the horizontal field of view
  68327. * @param aspect defines the aspect ratio
  68328. * @param znear defines the near clip plane
  68329. * @param zfar defines the far clip plane
  68330. * @param result defines the target matrix
  68331. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68332. */
  68333. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68334. /**
  68335. * Stores a perspective projection for WebVR info a given matrix
  68336. * @param fov defines the field of view
  68337. * @param znear defines the near clip plane
  68338. * @param zfar defines the far clip plane
  68339. * @param result defines the target matrix
  68340. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  68341. */
  68342. static PerspectiveFovWebVRToRef(fov: {
  68343. upDegrees: number;
  68344. downDegrees: number;
  68345. leftDegrees: number;
  68346. rightDegrees: number;
  68347. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  68348. /**
  68349. * Computes a complete transformation matrix
  68350. * @param viewport defines the viewport to use
  68351. * @param world defines the world matrix
  68352. * @param view defines the view matrix
  68353. * @param projection defines the projection matrix
  68354. * @param zmin defines the near clip plane
  68355. * @param zmax defines the far clip plane
  68356. * @returns the transformation matrix
  68357. */
  68358. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  68359. /**
  68360. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  68361. * @param matrix defines the matrix to use
  68362. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  68363. */
  68364. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  68365. /**
  68366. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  68367. * @param matrix defines the matrix to use
  68368. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  68369. */
  68370. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  68371. /**
  68372. * Compute the transpose of a given matrix
  68373. * @param matrix defines the matrix to transpose
  68374. * @returns the new matrix
  68375. */
  68376. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  68377. /**
  68378. * Compute the transpose of a matrix and store it in a target matrix
  68379. * @param matrix defines the matrix to transpose
  68380. * @param result defines the target matrix
  68381. */
  68382. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  68383. /**
  68384. * Computes a reflection matrix from a plane
  68385. * @param plane defines the reflection plane
  68386. * @returns a new matrix
  68387. */
  68388. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  68389. /**
  68390. * Computes a reflection matrix from a plane
  68391. * @param plane defines the reflection plane
  68392. * @param result defines the target matrix
  68393. */
  68394. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  68395. /**
  68396. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  68397. * @param xaxis defines the value of the 1st axis
  68398. * @param yaxis defines the value of the 2nd axis
  68399. * @param zaxis defines the value of the 3rd axis
  68400. * @param result defines the target matrix
  68401. */
  68402. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  68403. /**
  68404. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  68405. * @param quat defines the quaternion to use
  68406. * @param result defines the target matrix
  68407. */
  68408. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  68409. }
  68410. /**
  68411. * @hidden
  68412. */
  68413. export class TmpVectors {
  68414. static Vector2: Vector2[];
  68415. static Vector3: Vector3[];
  68416. static Vector4: Vector4[];
  68417. static Quaternion: Quaternion[];
  68418. static Matrix: Matrix[];
  68419. }
  68420. }
  68421. declare module BABYLON {
  68422. /** Defines the cross module used constants to avoid circular dependncies */
  68423. export class Constants {
  68424. /** Defines that alpha blending is disabled */
  68425. static readonly ALPHA_DISABLE: number;
  68426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68427. static readonly ALPHA_ADD: number;
  68428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68429. static readonly ALPHA_COMBINE: number;
  68430. /** Defines that alpha blending to DEST - SRC * DEST */
  68431. static readonly ALPHA_SUBTRACT: number;
  68432. /** Defines that alpha blending to SRC * DEST */
  68433. static readonly ALPHA_MULTIPLY: number;
  68434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68435. static readonly ALPHA_MAXIMIZED: number;
  68436. /** Defines that alpha blending to SRC + DEST */
  68437. static readonly ALPHA_ONEONE: number;
  68438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68439. static readonly ALPHA_PREMULTIPLIED: number;
  68440. /**
  68441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68443. */
  68444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68446. static readonly ALPHA_INTERPOLATE: number;
  68447. /**
  68448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68450. */
  68451. static readonly ALPHA_SCREENMODE: number;
  68452. /** Defines that the ressource is not delayed*/
  68453. static readonly DELAYLOADSTATE_NONE: number;
  68454. /** Defines that the ressource was successfully delay loaded */
  68455. static readonly DELAYLOADSTATE_LOADED: number;
  68456. /** Defines that the ressource is currently delay loading */
  68457. static readonly DELAYLOADSTATE_LOADING: number;
  68458. /** Defines that the ressource is delayed and has not started loading */
  68459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68461. static readonly NEVER: number;
  68462. /** 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 */
  68463. static readonly ALWAYS: number;
  68464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68465. static readonly LESS: number;
  68466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68467. static readonly EQUAL: number;
  68468. /** 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 */
  68469. static readonly LEQUAL: number;
  68470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68471. static readonly GREATER: number;
  68472. /** 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 */
  68473. static readonly GEQUAL: number;
  68474. /** 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 */
  68475. static readonly NOTEQUAL: number;
  68476. /** Passed to stencilOperation to specify that stencil value must be kept */
  68477. static readonly KEEP: number;
  68478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68479. static readonly REPLACE: number;
  68480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68481. static readonly INCR: number;
  68482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68483. static readonly DECR: number;
  68484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68485. static readonly INVERT: number;
  68486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68487. static readonly INCR_WRAP: number;
  68488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68489. static readonly DECR_WRAP: number;
  68490. /** Texture is not repeating outside of 0..1 UVs */
  68491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68492. /** Texture is repeating outside of 0..1 UVs */
  68493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68494. /** Texture is repeating and mirrored */
  68495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68496. /** ALPHA */
  68497. static readonly TEXTUREFORMAT_ALPHA: number;
  68498. /** LUMINANCE */
  68499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68500. /** LUMINANCE_ALPHA */
  68501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68502. /** RGB */
  68503. static readonly TEXTUREFORMAT_RGB: number;
  68504. /** RGBA */
  68505. static readonly TEXTUREFORMAT_RGBA: number;
  68506. /** RED */
  68507. static readonly TEXTUREFORMAT_RED: number;
  68508. /** RED (2nd reference) */
  68509. static readonly TEXTUREFORMAT_R: number;
  68510. /** RG */
  68511. static readonly TEXTUREFORMAT_RG: number;
  68512. /** RED_INTEGER */
  68513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68514. /** RED_INTEGER (2nd reference) */
  68515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68516. /** RG_INTEGER */
  68517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68518. /** RGB_INTEGER */
  68519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68520. /** RGBA_INTEGER */
  68521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68522. /** UNSIGNED_BYTE */
  68523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68524. /** UNSIGNED_BYTE (2nd reference) */
  68525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68526. /** FLOAT */
  68527. static readonly TEXTURETYPE_FLOAT: number;
  68528. /** HALF_FLOAT */
  68529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68530. /** BYTE */
  68531. static readonly TEXTURETYPE_BYTE: number;
  68532. /** SHORT */
  68533. static readonly TEXTURETYPE_SHORT: number;
  68534. /** UNSIGNED_SHORT */
  68535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68536. /** INT */
  68537. static readonly TEXTURETYPE_INT: number;
  68538. /** UNSIGNED_INT */
  68539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68540. /** UNSIGNED_SHORT_4_4_4_4 */
  68541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68542. /** UNSIGNED_SHORT_5_5_5_1 */
  68543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68544. /** UNSIGNED_SHORT_5_6_5 */
  68545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68546. /** UNSIGNED_INT_2_10_10_10_REV */
  68547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68548. /** UNSIGNED_INT_24_8 */
  68549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68550. /** UNSIGNED_INT_10F_11F_11F_REV */
  68551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68552. /** UNSIGNED_INT_5_9_9_9_REV */
  68553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68556. /** nearest is mag = nearest and min = nearest and mip = linear */
  68557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68560. /** Trilinear is mag = linear and min = linear and mip = linear */
  68561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68562. /** nearest is mag = nearest and min = nearest and mip = linear */
  68563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68566. /** Trilinear is mag = linear and min = linear and mip = linear */
  68567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68568. /** mag = nearest and min = nearest and mip = nearest */
  68569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68570. /** mag = nearest and min = linear and mip = nearest */
  68571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68572. /** mag = nearest and min = linear and mip = linear */
  68573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68574. /** mag = nearest and min = linear and mip = none */
  68575. static readonly TEXTURE_NEAREST_LINEAR: number;
  68576. /** mag = nearest and min = nearest and mip = none */
  68577. static readonly TEXTURE_NEAREST_NEAREST: number;
  68578. /** mag = linear and min = nearest and mip = nearest */
  68579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68580. /** mag = linear and min = nearest and mip = linear */
  68581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68582. /** mag = linear and min = linear and mip = none */
  68583. static readonly TEXTURE_LINEAR_LINEAR: number;
  68584. /** mag = linear and min = nearest and mip = none */
  68585. static readonly TEXTURE_LINEAR_NEAREST: number;
  68586. /** Explicit coordinates mode */
  68587. static readonly TEXTURE_EXPLICIT_MODE: number;
  68588. /** Spherical coordinates mode */
  68589. static readonly TEXTURE_SPHERICAL_MODE: number;
  68590. /** Planar coordinates mode */
  68591. static readonly TEXTURE_PLANAR_MODE: number;
  68592. /** Cubic coordinates mode */
  68593. static readonly TEXTURE_CUBIC_MODE: number;
  68594. /** Projection coordinates mode */
  68595. static readonly TEXTURE_PROJECTION_MODE: number;
  68596. /** Skybox coordinates mode */
  68597. static readonly TEXTURE_SKYBOX_MODE: number;
  68598. /** Inverse Cubic coordinates mode */
  68599. static readonly TEXTURE_INVCUBIC_MODE: number;
  68600. /** Equirectangular coordinates mode */
  68601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68602. /** Equirectangular Fixed coordinates mode */
  68603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68604. /** Equirectangular Fixed Mirrored coordinates mode */
  68605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68607. static readonly SCALEMODE_FLOOR: number;
  68608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68609. static readonly SCALEMODE_NEAREST: number;
  68610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68611. static readonly SCALEMODE_CEILING: number;
  68612. /**
  68613. * The dirty texture flag value
  68614. */
  68615. static readonly MATERIAL_TextureDirtyFlag: number;
  68616. /**
  68617. * The dirty light flag value
  68618. */
  68619. static readonly MATERIAL_LightDirtyFlag: number;
  68620. /**
  68621. * The dirty fresnel flag value
  68622. */
  68623. static readonly MATERIAL_FresnelDirtyFlag: number;
  68624. /**
  68625. * The dirty attribute flag value
  68626. */
  68627. static readonly MATERIAL_AttributesDirtyFlag: number;
  68628. /**
  68629. * The dirty misc flag value
  68630. */
  68631. static readonly MATERIAL_MiscDirtyFlag: number;
  68632. /**
  68633. * The all dirty flag value
  68634. */
  68635. static readonly MATERIAL_AllDirtyFlag: number;
  68636. /**
  68637. * Returns the triangle fill mode
  68638. */
  68639. static readonly MATERIAL_TriangleFillMode: number;
  68640. /**
  68641. * Returns the wireframe mode
  68642. */
  68643. static readonly MATERIAL_WireFrameFillMode: number;
  68644. /**
  68645. * Returns the point fill mode
  68646. */
  68647. static readonly MATERIAL_PointFillMode: number;
  68648. /**
  68649. * Returns the point list draw mode
  68650. */
  68651. static readonly MATERIAL_PointListDrawMode: number;
  68652. /**
  68653. * Returns the line list draw mode
  68654. */
  68655. static readonly MATERIAL_LineListDrawMode: number;
  68656. /**
  68657. * Returns the line loop draw mode
  68658. */
  68659. static readonly MATERIAL_LineLoopDrawMode: number;
  68660. /**
  68661. * Returns the line strip draw mode
  68662. */
  68663. static readonly MATERIAL_LineStripDrawMode: number;
  68664. /**
  68665. * Returns the triangle strip draw mode
  68666. */
  68667. static readonly MATERIAL_TriangleStripDrawMode: number;
  68668. /**
  68669. * Returns the triangle fan draw mode
  68670. */
  68671. static readonly MATERIAL_TriangleFanDrawMode: number;
  68672. /**
  68673. * Stores the clock-wise side orientation
  68674. */
  68675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68676. /**
  68677. * Stores the counter clock-wise side orientation
  68678. */
  68679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68680. /**
  68681. * Nothing
  68682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68683. */
  68684. static readonly ACTION_NothingTrigger: number;
  68685. /**
  68686. * On pick
  68687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68688. */
  68689. static readonly ACTION_OnPickTrigger: number;
  68690. /**
  68691. * On left pick
  68692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68693. */
  68694. static readonly ACTION_OnLeftPickTrigger: number;
  68695. /**
  68696. * On right pick
  68697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68698. */
  68699. static readonly ACTION_OnRightPickTrigger: number;
  68700. /**
  68701. * On center pick
  68702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68703. */
  68704. static readonly ACTION_OnCenterPickTrigger: number;
  68705. /**
  68706. * On pick down
  68707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68708. */
  68709. static readonly ACTION_OnPickDownTrigger: number;
  68710. /**
  68711. * On double pick
  68712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68713. */
  68714. static readonly ACTION_OnDoublePickTrigger: number;
  68715. /**
  68716. * On pick up
  68717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68718. */
  68719. static readonly ACTION_OnPickUpTrigger: number;
  68720. /**
  68721. * On pick out.
  68722. * This trigger will only be raised if you also declared a OnPickDown
  68723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68724. */
  68725. static readonly ACTION_OnPickOutTrigger: number;
  68726. /**
  68727. * On long press
  68728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68729. */
  68730. static readonly ACTION_OnLongPressTrigger: number;
  68731. /**
  68732. * On pointer over
  68733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68734. */
  68735. static readonly ACTION_OnPointerOverTrigger: number;
  68736. /**
  68737. * On pointer out
  68738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68739. */
  68740. static readonly ACTION_OnPointerOutTrigger: number;
  68741. /**
  68742. * On every frame
  68743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68744. */
  68745. static readonly ACTION_OnEveryFrameTrigger: number;
  68746. /**
  68747. * On intersection enter
  68748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68749. */
  68750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68751. /**
  68752. * On intersection exit
  68753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68754. */
  68755. static readonly ACTION_OnIntersectionExitTrigger: number;
  68756. /**
  68757. * On key down
  68758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68759. */
  68760. static readonly ACTION_OnKeyDownTrigger: number;
  68761. /**
  68762. * On key up
  68763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68764. */
  68765. static readonly ACTION_OnKeyUpTrigger: number;
  68766. /**
  68767. * Billboard mode will only apply to Y axis
  68768. */
  68769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68770. /**
  68771. * Billboard mode will apply to all axes
  68772. */
  68773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68774. /**
  68775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68776. */
  68777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68778. /**
  68779. * Gets or sets base Assets URL
  68780. */
  68781. static PARTICLES_BaseAssetsUrl: string;
  68782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68783. * Test order :
  68784. * Is the bounding sphere outside the frustum ?
  68785. * If not, are the bounding box vertices outside the frustum ?
  68786. * It not, then the cullable object is in the frustum.
  68787. */
  68788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68789. /** Culling strategy : Bounding Sphere Only.
  68790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68791. * It's also less accurate than the standard because some not visible objects can still be selected.
  68792. * Test : is the bounding sphere outside the frustum ?
  68793. * If not, then the cullable object is in the frustum.
  68794. */
  68795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68796. /** Culling strategy : Optimistic Inclusion.
  68797. * This in an inclusion test first, then the standard exclusion test.
  68798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68799. * 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.
  68800. * Anyway, it's as accurate as the standard strategy.
  68801. * Test :
  68802. * Is the cullable object bounding sphere center in the frustum ?
  68803. * If not, apply the default culling strategy.
  68804. */
  68805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68809. * 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.
  68810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68811. * Test :
  68812. * Is the cullable object bounding sphere center in the frustum ?
  68813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68814. */
  68815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68816. /**
  68817. * No logging while loading
  68818. */
  68819. static readonly SCENELOADER_NO_LOGGING: number;
  68820. /**
  68821. * Minimal logging while loading
  68822. */
  68823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68824. /**
  68825. * Summary logging while loading
  68826. */
  68827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68828. /**
  68829. * Detailled logging while loading
  68830. */
  68831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68832. }
  68833. }
  68834. declare module BABYLON {
  68835. /**
  68836. * Class used to store and describe the pipeline context associated with an effect
  68837. */
  68838. export interface IPipelineContext {
  68839. /**
  68840. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68841. */
  68842. isAsync: boolean;
  68843. /**
  68844. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68845. */
  68846. isReady: boolean;
  68847. /** @hidden */
  68848. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68849. }
  68850. }
  68851. declare module BABYLON {
  68852. /** @hidden */
  68853. export interface IShaderProcessor {
  68854. attributeProcessor?: (attribute: string) => string;
  68855. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68856. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68857. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68858. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68859. lineProcessor?: (line: string, isFragment: boolean) => string;
  68860. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68861. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68862. }
  68863. }
  68864. declare module BABYLON {
  68865. /** @hidden */
  68866. export interface ProcessingOptions {
  68867. defines: string[];
  68868. indexParameters: any;
  68869. isFragment: boolean;
  68870. shouldUseHighPrecisionShader: boolean;
  68871. supportsUniformBuffers: boolean;
  68872. shadersRepository: string;
  68873. includesShadersStore: {
  68874. [key: string]: string;
  68875. };
  68876. processor?: IShaderProcessor;
  68877. version: string;
  68878. platformName: string;
  68879. lookForClosingBracketForUniformBuffer?: boolean;
  68880. }
  68881. }
  68882. declare module BABYLON {
  68883. /**
  68884. * Helper to manipulate strings
  68885. */
  68886. export class StringTools {
  68887. /**
  68888. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68889. * @param str Source string
  68890. * @param suffix Suffix to search for in the source string
  68891. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68892. */
  68893. static EndsWith(str: string, suffix: string): boolean;
  68894. /**
  68895. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68896. * @param str Source string
  68897. * @param suffix Suffix to search for in the source string
  68898. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68899. */
  68900. static StartsWith(str: string, suffix: string): boolean;
  68901. }
  68902. }
  68903. declare module BABYLON {
  68904. /** @hidden */
  68905. export class ShaderCodeNode {
  68906. line: string;
  68907. children: ShaderCodeNode[];
  68908. additionalDefineKey?: string;
  68909. additionalDefineValue?: string;
  68910. isValid(preprocessors: {
  68911. [key: string]: string;
  68912. }): boolean;
  68913. process(preprocessors: {
  68914. [key: string]: string;
  68915. }, options: ProcessingOptions): string;
  68916. }
  68917. }
  68918. declare module BABYLON {
  68919. /** @hidden */
  68920. export class ShaderCodeCursor {
  68921. private _lines;
  68922. lineIndex: number;
  68923. readonly currentLine: string;
  68924. readonly canRead: boolean;
  68925. lines: string[];
  68926. }
  68927. }
  68928. declare module BABYLON {
  68929. /** @hidden */
  68930. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68931. process(preprocessors: {
  68932. [key: string]: string;
  68933. }, options: ProcessingOptions): string;
  68934. }
  68935. }
  68936. declare module BABYLON {
  68937. /** @hidden */
  68938. export class ShaderDefineExpression {
  68939. isTrue(preprocessors: {
  68940. [key: string]: string;
  68941. }): boolean;
  68942. }
  68943. }
  68944. declare module BABYLON {
  68945. /** @hidden */
  68946. export class ShaderCodeTestNode extends ShaderCodeNode {
  68947. testExpression: ShaderDefineExpression;
  68948. isValid(preprocessors: {
  68949. [key: string]: string;
  68950. }): boolean;
  68951. }
  68952. }
  68953. declare module BABYLON {
  68954. /** @hidden */
  68955. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68956. define: string;
  68957. not: boolean;
  68958. constructor(define: string, not?: boolean);
  68959. isTrue(preprocessors: {
  68960. [key: string]: string;
  68961. }): boolean;
  68962. }
  68963. }
  68964. declare module BABYLON {
  68965. /** @hidden */
  68966. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68967. leftOperand: ShaderDefineExpression;
  68968. rightOperand: ShaderDefineExpression;
  68969. isTrue(preprocessors: {
  68970. [key: string]: string;
  68971. }): boolean;
  68972. }
  68973. }
  68974. declare module BABYLON {
  68975. /** @hidden */
  68976. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68977. leftOperand: ShaderDefineExpression;
  68978. rightOperand: ShaderDefineExpression;
  68979. isTrue(preprocessors: {
  68980. [key: string]: string;
  68981. }): boolean;
  68982. }
  68983. }
  68984. declare module BABYLON {
  68985. /** @hidden */
  68986. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68987. define: string;
  68988. operand: string;
  68989. testValue: string;
  68990. constructor(define: string, operand: string, testValue: string);
  68991. isTrue(preprocessors: {
  68992. [key: string]: string;
  68993. }): boolean;
  68994. }
  68995. }
  68996. declare module BABYLON {
  68997. /**
  68998. * @ignore
  68999. * Application error to support additional information when loading a file
  69000. */
  69001. export class LoadFileError extends Error {
  69002. /** defines the optional web request */
  69003. request?: WebRequest | undefined;
  69004. private static _setPrototypeOf;
  69005. /**
  69006. * Creates a new LoadFileError
  69007. * @param message defines the message of the error
  69008. * @param request defines the optional web request
  69009. */
  69010. constructor(message: string,
  69011. /** defines the optional web request */
  69012. request?: WebRequest | undefined);
  69013. }
  69014. }
  69015. declare module BABYLON {
  69016. /**
  69017. * Class used to enable access to offline support
  69018. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69019. */
  69020. export interface IOfflineProvider {
  69021. /**
  69022. * Gets a boolean indicating if scene must be saved in the database
  69023. */
  69024. enableSceneOffline: boolean;
  69025. /**
  69026. * Gets a boolean indicating if textures must be saved in the database
  69027. */
  69028. enableTexturesOffline: boolean;
  69029. /**
  69030. * Open the offline support and make it available
  69031. * @param successCallback defines the callback to call on success
  69032. * @param errorCallback defines the callback to call on error
  69033. */
  69034. open(successCallback: () => void, errorCallback: () => void): void;
  69035. /**
  69036. * Loads an image from the offline support
  69037. * @param url defines the url to load from
  69038. * @param image defines the target DOM image
  69039. */
  69040. loadImage(url: string, image: HTMLImageElement): void;
  69041. /**
  69042. * Loads a file from offline support
  69043. * @param url defines the URL to load from
  69044. * @param sceneLoaded defines a callback to call on success
  69045. * @param progressCallBack defines a callback to call when progress changed
  69046. * @param errorCallback defines a callback to call on error
  69047. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69048. */
  69049. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69050. }
  69051. }
  69052. declare module BABYLON {
  69053. /**
  69054. * Class used to help managing file picking and drag'n'drop
  69055. * File Storage
  69056. */
  69057. export class FilesInputStore {
  69058. /**
  69059. * List of files ready to be loaded
  69060. */
  69061. static FilesToLoad: {
  69062. [key: string]: File;
  69063. };
  69064. }
  69065. }
  69066. declare module BABYLON {
  69067. /**
  69068. * Class used to define a retry strategy when error happens while loading assets
  69069. */
  69070. export class RetryStrategy {
  69071. /**
  69072. * Function used to defines an exponential back off strategy
  69073. * @param maxRetries defines the maximum number of retries (3 by default)
  69074. * @param baseInterval defines the interval between retries
  69075. * @returns the strategy function to use
  69076. */
  69077. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69078. }
  69079. }
  69080. declare module BABYLON {
  69081. /**
  69082. * @hidden
  69083. */
  69084. export class FileTools {
  69085. /**
  69086. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69087. */
  69088. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69089. /**
  69090. * Gets or sets the base URL to use to load assets
  69091. */
  69092. static BaseUrl: string;
  69093. /**
  69094. * Default behaviour for cors in the application.
  69095. * It can be a string if the expected behavior is identical in the entire app.
  69096. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69097. */
  69098. static CorsBehavior: string | ((url: string | string[]) => string);
  69099. /**
  69100. * Gets or sets a function used to pre-process url before using them to load assets
  69101. */
  69102. static PreprocessUrl: (url: string) => string;
  69103. /**
  69104. * Removes unwanted characters from an url
  69105. * @param url defines the url to clean
  69106. * @returns the cleaned url
  69107. */
  69108. private static _CleanUrl;
  69109. /**
  69110. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69111. * @param url define the url we are trying
  69112. * @param element define the dom element where to configure the cors policy
  69113. */
  69114. static SetCorsBehavior(url: string | string[], element: {
  69115. crossOrigin: string | null;
  69116. }): void;
  69117. /**
  69118. * Loads an image as an HTMLImageElement.
  69119. * @param input url string, ArrayBuffer, or Blob to load
  69120. * @param onLoad callback called when the image successfully loads
  69121. * @param onError callback called when the image fails to load
  69122. * @param offlineProvider offline provider for caching
  69123. * @returns the HTMLImageElement of the loaded image
  69124. */
  69125. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  69126. /**
  69127. * Loads a file
  69128. * @param fileToLoad defines the file to load
  69129. * @param callback defines the callback to call when data is loaded
  69130. * @param progressCallBack defines the callback to call during loading process
  69131. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69132. * @returns a file request object
  69133. */
  69134. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  69135. /**
  69136. * Loads a file
  69137. * @param url url string, ArrayBuffer, or Blob to load
  69138. * @param onSuccess callback called when the file successfully loads
  69139. * @param onProgress callback called while file is loading (if the server supports this mode)
  69140. * @param offlineProvider defines the offline provider for caching
  69141. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69142. * @param onError callback called when the file fails to load
  69143. * @returns a file request object
  69144. */
  69145. 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;
  69146. /**
  69147. * Checks if the loaded document was accessed via `file:`-Protocol.
  69148. * @returns boolean
  69149. */
  69150. static IsFileURL(): boolean;
  69151. }
  69152. }
  69153. declare module BABYLON {
  69154. /** @hidden */
  69155. export class ShaderProcessor {
  69156. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69157. private static _ProcessPrecision;
  69158. private static _ExtractOperation;
  69159. private static _BuildSubExpression;
  69160. private static _BuildExpression;
  69161. private static _MoveCursorWithinIf;
  69162. private static _MoveCursor;
  69163. private static _EvaluatePreProcessors;
  69164. private static _PreparePreProcessors;
  69165. private static _ProcessShaderConversion;
  69166. private static _ProcessIncludes;
  69167. }
  69168. }
  69169. declare module BABYLON {
  69170. /**
  69171. * Class used to hold a RBG color
  69172. */
  69173. export class Color3 {
  69174. /**
  69175. * Defines the red component (between 0 and 1, default is 0)
  69176. */
  69177. r: number;
  69178. /**
  69179. * Defines the green component (between 0 and 1, default is 0)
  69180. */
  69181. g: number;
  69182. /**
  69183. * Defines the blue component (between 0 and 1, default is 0)
  69184. */
  69185. b: number;
  69186. /**
  69187. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69188. * @param r defines the red component (between 0 and 1, default is 0)
  69189. * @param g defines the green component (between 0 and 1, default is 0)
  69190. * @param b defines the blue component (between 0 and 1, default is 0)
  69191. */
  69192. constructor(
  69193. /**
  69194. * Defines the red component (between 0 and 1, default is 0)
  69195. */
  69196. r?: number,
  69197. /**
  69198. * Defines the green component (between 0 and 1, default is 0)
  69199. */
  69200. g?: number,
  69201. /**
  69202. * Defines the blue component (between 0 and 1, default is 0)
  69203. */
  69204. b?: number);
  69205. /**
  69206. * Creates a string with the Color3 current values
  69207. * @returns the string representation of the Color3 object
  69208. */
  69209. toString(): string;
  69210. /**
  69211. * Returns the string "Color3"
  69212. * @returns "Color3"
  69213. */
  69214. getClassName(): string;
  69215. /**
  69216. * Compute the Color3 hash code
  69217. * @returns an unique number that can be used to hash Color3 objects
  69218. */
  69219. getHashCode(): number;
  69220. /**
  69221. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69222. * @param array defines the array where to store the r,g,b components
  69223. * @param index defines an optional index in the target array to define where to start storing values
  69224. * @returns the current Color3 object
  69225. */
  69226. toArray(array: FloatArray, index?: number): Color3;
  69227. /**
  69228. * Returns a new Color4 object from the current Color3 and the given alpha
  69229. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69230. * @returns a new Color4 object
  69231. */
  69232. toColor4(alpha?: number): Color4;
  69233. /**
  69234. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69235. * @returns the new array
  69236. */
  69237. asArray(): number[];
  69238. /**
  69239. * Returns the luminance value
  69240. * @returns a float value
  69241. */
  69242. toLuminance(): number;
  69243. /**
  69244. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69245. * @param otherColor defines the second operand
  69246. * @returns the new Color3 object
  69247. */
  69248. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69249. /**
  69250. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69251. * @param otherColor defines the second operand
  69252. * @param result defines the Color3 object where to store the result
  69253. * @returns the current Color3
  69254. */
  69255. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69256. /**
  69257. * Determines equality between Color3 objects
  69258. * @param otherColor defines the second operand
  69259. * @returns true if the rgb values are equal to the given ones
  69260. */
  69261. equals(otherColor: DeepImmutable<Color3>): boolean;
  69262. /**
  69263. * Determines equality between the current Color3 object and a set of r,b,g values
  69264. * @param r defines the red component to check
  69265. * @param g defines the green component to check
  69266. * @param b defines the blue component to check
  69267. * @returns true if the rgb values are equal to the given ones
  69268. */
  69269. equalsFloats(r: number, g: number, b: number): boolean;
  69270. /**
  69271. * Multiplies in place each rgb value by scale
  69272. * @param scale defines the scaling factor
  69273. * @returns the updated Color3
  69274. */
  69275. scale(scale: number): Color3;
  69276. /**
  69277. * Multiplies the rgb values by scale and stores the result into "result"
  69278. * @param scale defines the scaling factor
  69279. * @param result defines the Color3 object where to store the result
  69280. * @returns the unmodified current Color3
  69281. */
  69282. scaleToRef(scale: number, result: Color3): Color3;
  69283. /**
  69284. * Scale the current Color3 values by a factor and add the result to a given Color3
  69285. * @param scale defines the scale factor
  69286. * @param result defines color to store the result into
  69287. * @returns the unmodified current Color3
  69288. */
  69289. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69290. /**
  69291. * Clamps the rgb values by the min and max values and stores the result into "result"
  69292. * @param min defines minimum clamping value (default is 0)
  69293. * @param max defines maximum clamping value (default is 1)
  69294. * @param result defines color to store the result into
  69295. * @returns the original Color3
  69296. */
  69297. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69298. /**
  69299. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69300. * @param otherColor defines the second operand
  69301. * @returns the new Color3
  69302. */
  69303. add(otherColor: DeepImmutable<Color3>): Color3;
  69304. /**
  69305. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69306. * @param otherColor defines the second operand
  69307. * @param result defines Color3 object to store the result into
  69308. * @returns the unmodified current Color3
  69309. */
  69310. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69311. /**
  69312. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69313. * @param otherColor defines the second operand
  69314. * @returns the new Color3
  69315. */
  69316. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69317. /**
  69318. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69319. * @param otherColor defines the second operand
  69320. * @param result defines Color3 object to store the result into
  69321. * @returns the unmodified current Color3
  69322. */
  69323. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69324. /**
  69325. * Copy the current object
  69326. * @returns a new Color3 copied the current one
  69327. */
  69328. clone(): Color3;
  69329. /**
  69330. * Copies the rgb values from the source in the current Color3
  69331. * @param source defines the source Color3 object
  69332. * @returns the updated Color3 object
  69333. */
  69334. copyFrom(source: DeepImmutable<Color3>): Color3;
  69335. /**
  69336. * Updates the Color3 rgb values from the given floats
  69337. * @param r defines the red component to read from
  69338. * @param g defines the green component to read from
  69339. * @param b defines the blue component to read from
  69340. * @returns the current Color3 object
  69341. */
  69342. copyFromFloats(r: number, g: number, b: number): Color3;
  69343. /**
  69344. * Updates the Color3 rgb values from the given floats
  69345. * @param r defines the red component to read from
  69346. * @param g defines the green component to read from
  69347. * @param b defines the blue component to read from
  69348. * @returns the current Color3 object
  69349. */
  69350. set(r: number, g: number, b: number): Color3;
  69351. /**
  69352. * Compute the Color3 hexadecimal code as a string
  69353. * @returns a string containing the hexadecimal representation of the Color3 object
  69354. */
  69355. toHexString(): string;
  69356. /**
  69357. * Computes a new Color3 converted from the current one to linear space
  69358. * @returns a new Color3 object
  69359. */
  69360. toLinearSpace(): Color3;
  69361. /**
  69362. * Converts current color in rgb space to HSV values
  69363. * @returns a new color3 representing the HSV values
  69364. */
  69365. toHSV(): Color3;
  69366. /**
  69367. * Converts current color in rgb space to HSV values
  69368. * @param result defines the Color3 where to store the HSV values
  69369. */
  69370. toHSVToRef(result: Color3): void;
  69371. /**
  69372. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69373. * @param convertedColor defines the Color3 object where to store the linear space version
  69374. * @returns the unmodified Color3
  69375. */
  69376. toLinearSpaceToRef(convertedColor: Color3): Color3;
  69377. /**
  69378. * Computes a new Color3 converted from the current one to gamma space
  69379. * @returns a new Color3 object
  69380. */
  69381. toGammaSpace(): Color3;
  69382. /**
  69383. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69384. * @param convertedColor defines the Color3 object where to store the gamma space version
  69385. * @returns the unmodified Color3
  69386. */
  69387. toGammaSpaceToRef(convertedColor: Color3): Color3;
  69388. private static _BlackReadOnly;
  69389. /**
  69390. * Convert Hue, saturation and value to a Color3 (RGB)
  69391. * @param hue defines the hue
  69392. * @param saturation defines the saturation
  69393. * @param value defines the value
  69394. * @param result defines the Color3 where to store the RGB values
  69395. */
  69396. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  69397. /**
  69398. * Creates a new Color3 from the string containing valid hexadecimal values
  69399. * @param hex defines a string containing valid hexadecimal values
  69400. * @returns a new Color3 object
  69401. */
  69402. static FromHexString(hex: string): Color3;
  69403. /**
  69404. * Creates a new Color3 from the starting index of the given array
  69405. * @param array defines the source array
  69406. * @param offset defines an offset in the source array
  69407. * @returns a new Color3 object
  69408. */
  69409. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  69410. /**
  69411. * Creates a new Color3 from integer values (< 256)
  69412. * @param r defines the red component to read from (value between 0 and 255)
  69413. * @param g defines the green component to read from (value between 0 and 255)
  69414. * @param b defines the blue component to read from (value between 0 and 255)
  69415. * @returns a new Color3 object
  69416. */
  69417. static FromInts(r: number, g: number, b: number): Color3;
  69418. /**
  69419. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69420. * @param start defines the start Color3 value
  69421. * @param end defines the end Color3 value
  69422. * @param amount defines the gradient value between start and end
  69423. * @returns a new Color3 object
  69424. */
  69425. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  69426. /**
  69427. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69428. * @param left defines the start value
  69429. * @param right defines the end value
  69430. * @param amount defines the gradient factor
  69431. * @param result defines the Color3 object where to store the result
  69432. */
  69433. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  69434. /**
  69435. * Returns a Color3 value containing a red color
  69436. * @returns a new Color3 object
  69437. */
  69438. static Red(): Color3;
  69439. /**
  69440. * Returns a Color3 value containing a green color
  69441. * @returns a new Color3 object
  69442. */
  69443. static Green(): Color3;
  69444. /**
  69445. * Returns a Color3 value containing a blue color
  69446. * @returns a new Color3 object
  69447. */
  69448. static Blue(): Color3;
  69449. /**
  69450. * Returns a Color3 value containing a black color
  69451. * @returns a new Color3 object
  69452. */
  69453. static Black(): Color3;
  69454. /**
  69455. * Gets a Color3 value containing a black color that must not be updated
  69456. */
  69457. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69458. /**
  69459. * Returns a Color3 value containing a white color
  69460. * @returns a new Color3 object
  69461. */
  69462. static White(): Color3;
  69463. /**
  69464. * Returns a Color3 value containing a purple color
  69465. * @returns a new Color3 object
  69466. */
  69467. static Purple(): Color3;
  69468. /**
  69469. * Returns a Color3 value containing a magenta color
  69470. * @returns a new Color3 object
  69471. */
  69472. static Magenta(): Color3;
  69473. /**
  69474. * Returns a Color3 value containing a yellow color
  69475. * @returns a new Color3 object
  69476. */
  69477. static Yellow(): Color3;
  69478. /**
  69479. * Returns a Color3 value containing a gray color
  69480. * @returns a new Color3 object
  69481. */
  69482. static Gray(): Color3;
  69483. /**
  69484. * Returns a Color3 value containing a teal color
  69485. * @returns a new Color3 object
  69486. */
  69487. static Teal(): Color3;
  69488. /**
  69489. * Returns a Color3 value containing a random color
  69490. * @returns a new Color3 object
  69491. */
  69492. static Random(): Color3;
  69493. }
  69494. /**
  69495. * Class used to hold a RBGA color
  69496. */
  69497. export class Color4 {
  69498. /**
  69499. * Defines the red component (between 0 and 1, default is 0)
  69500. */
  69501. r: number;
  69502. /**
  69503. * Defines the green component (between 0 and 1, default is 0)
  69504. */
  69505. g: number;
  69506. /**
  69507. * Defines the blue component (between 0 and 1, default is 0)
  69508. */
  69509. b: number;
  69510. /**
  69511. * Defines the alpha component (between 0 and 1, default is 1)
  69512. */
  69513. a: number;
  69514. /**
  69515. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69516. * @param r defines the red component (between 0 and 1, default is 0)
  69517. * @param g defines the green component (between 0 and 1, default is 0)
  69518. * @param b defines the blue component (between 0 and 1, default is 0)
  69519. * @param a defines the alpha component (between 0 and 1, default is 1)
  69520. */
  69521. constructor(
  69522. /**
  69523. * Defines the red component (between 0 and 1, default is 0)
  69524. */
  69525. r?: number,
  69526. /**
  69527. * Defines the green component (between 0 and 1, default is 0)
  69528. */
  69529. g?: number,
  69530. /**
  69531. * Defines the blue component (between 0 and 1, default is 0)
  69532. */
  69533. b?: number,
  69534. /**
  69535. * Defines the alpha component (between 0 and 1, default is 1)
  69536. */
  69537. a?: number);
  69538. /**
  69539. * Adds in place the given Color4 values to the current Color4 object
  69540. * @param right defines the second operand
  69541. * @returns the current updated Color4 object
  69542. */
  69543. addInPlace(right: DeepImmutable<Color4>): Color4;
  69544. /**
  69545. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69546. * @returns the new array
  69547. */
  69548. asArray(): number[];
  69549. /**
  69550. * Stores from the starting index in the given array the Color4 successive values
  69551. * @param array defines the array where to store the r,g,b components
  69552. * @param index defines an optional index in the target array to define where to start storing values
  69553. * @returns the current Color4 object
  69554. */
  69555. toArray(array: number[], index?: number): Color4;
  69556. /**
  69557. * Determines equality between Color4 objects
  69558. * @param otherColor defines the second operand
  69559. * @returns true if the rgba values are equal to the given ones
  69560. */
  69561. equals(otherColor: DeepImmutable<Color4>): boolean;
  69562. /**
  69563. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69564. * @param right defines the second operand
  69565. * @returns a new Color4 object
  69566. */
  69567. add(right: DeepImmutable<Color4>): Color4;
  69568. /**
  69569. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  69570. * @param right defines the second operand
  69571. * @returns a new Color4 object
  69572. */
  69573. subtract(right: DeepImmutable<Color4>): Color4;
  69574. /**
  69575. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  69576. * @param right defines the second operand
  69577. * @param result defines the Color4 object where to store the result
  69578. * @returns the current Color4 object
  69579. */
  69580. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  69581. /**
  69582. * Creates a new Color4 with the current Color4 values multiplied by scale
  69583. * @param scale defines the scaling factor to apply
  69584. * @returns a new Color4 object
  69585. */
  69586. scale(scale: number): Color4;
  69587. /**
  69588. * Multiplies the current Color4 values by scale and stores the result in "result"
  69589. * @param scale defines the scaling factor to apply
  69590. * @param result defines the Color4 object where to store the result
  69591. * @returns the current unmodified Color4
  69592. */
  69593. scaleToRef(scale: number, result: Color4): Color4;
  69594. /**
  69595. * Scale the current Color4 values by a factor and add the result to a given Color4
  69596. * @param scale defines the scale factor
  69597. * @param result defines the Color4 object where to store the result
  69598. * @returns the unmodified current Color4
  69599. */
  69600. scaleAndAddToRef(scale: number, result: Color4): Color4;
  69601. /**
  69602. * Clamps the rgb values by the min and max values and stores the result into "result"
  69603. * @param min defines minimum clamping value (default is 0)
  69604. * @param max defines maximum clamping value (default is 1)
  69605. * @param result defines color to store the result into.
  69606. * @returns the cuurent Color4
  69607. */
  69608. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  69609. /**
  69610. * Multipy an Color4 value by another and return a new Color4 object
  69611. * @param color defines the Color4 value to multiply by
  69612. * @returns a new Color4 object
  69613. */
  69614. multiply(color: Color4): Color4;
  69615. /**
  69616. * Multipy a Color4 value by another and push the result in a reference value
  69617. * @param color defines the Color4 value to multiply by
  69618. * @param result defines the Color4 to fill the result in
  69619. * @returns the result Color4
  69620. */
  69621. multiplyToRef(color: Color4, result: Color4): Color4;
  69622. /**
  69623. * Creates a string with the Color4 current values
  69624. * @returns the string representation of the Color4 object
  69625. */
  69626. toString(): string;
  69627. /**
  69628. * Returns the string "Color4"
  69629. * @returns "Color4"
  69630. */
  69631. getClassName(): string;
  69632. /**
  69633. * Compute the Color4 hash code
  69634. * @returns an unique number that can be used to hash Color4 objects
  69635. */
  69636. getHashCode(): number;
  69637. /**
  69638. * Creates a new Color4 copied from the current one
  69639. * @returns a new Color4 object
  69640. */
  69641. clone(): Color4;
  69642. /**
  69643. * Copies the given Color4 values into the current one
  69644. * @param source defines the source Color4 object
  69645. * @returns the current updated Color4 object
  69646. */
  69647. copyFrom(source: Color4): Color4;
  69648. /**
  69649. * Copies the given float values into the current one
  69650. * @param r defines the red component to read from
  69651. * @param g defines the green component to read from
  69652. * @param b defines the blue component to read from
  69653. * @param a defines the alpha component to read from
  69654. * @returns the current updated Color4 object
  69655. */
  69656. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69657. /**
  69658. * Copies the given float values into the current one
  69659. * @param r defines the red component to read from
  69660. * @param g defines the green component to read from
  69661. * @param b defines the blue component to read from
  69662. * @param a defines the alpha component to read from
  69663. * @returns the current updated Color4 object
  69664. */
  69665. set(r: number, g: number, b: number, a: number): Color4;
  69666. /**
  69667. * Compute the Color4 hexadecimal code as a string
  69668. * @returns a string containing the hexadecimal representation of the Color4 object
  69669. */
  69670. toHexString(): string;
  69671. /**
  69672. * Computes a new Color4 converted from the current one to linear space
  69673. * @returns a new Color4 object
  69674. */
  69675. toLinearSpace(): Color4;
  69676. /**
  69677. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69678. * @param convertedColor defines the Color4 object where to store the linear space version
  69679. * @returns the unmodified Color4
  69680. */
  69681. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69682. /**
  69683. * Computes a new Color4 converted from the current one to gamma space
  69684. * @returns a new Color4 object
  69685. */
  69686. toGammaSpace(): Color4;
  69687. /**
  69688. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69689. * @param convertedColor defines the Color4 object where to store the gamma space version
  69690. * @returns the unmodified Color4
  69691. */
  69692. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69693. /**
  69694. * Creates a new Color4 from the string containing valid hexadecimal values
  69695. * @param hex defines a string containing valid hexadecimal values
  69696. * @returns a new Color4 object
  69697. */
  69698. static FromHexString(hex: string): Color4;
  69699. /**
  69700. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69701. * @param left defines the start value
  69702. * @param right defines the end value
  69703. * @param amount defines the gradient factor
  69704. * @returns a new Color4 object
  69705. */
  69706. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69707. /**
  69708. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69709. * @param left defines the start value
  69710. * @param right defines the end value
  69711. * @param amount defines the gradient factor
  69712. * @param result defines the Color4 object where to store data
  69713. */
  69714. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69715. /**
  69716. * Creates a new Color4 from a Color3 and an alpha value
  69717. * @param color3 defines the source Color3 to read from
  69718. * @param alpha defines the alpha component (1.0 by default)
  69719. * @returns a new Color4 object
  69720. */
  69721. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  69722. /**
  69723. * Creates a new Color4 from the starting index element of the given array
  69724. * @param array defines the source array to read from
  69725. * @param offset defines the offset in the source array
  69726. * @returns a new Color4 object
  69727. */
  69728. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69729. /**
  69730. * Creates a new Color3 from integer values (< 256)
  69731. * @param r defines the red component to read from (value between 0 and 255)
  69732. * @param g defines the green component to read from (value between 0 and 255)
  69733. * @param b defines the blue component to read from (value between 0 and 255)
  69734. * @param a defines the alpha component to read from (value between 0 and 255)
  69735. * @returns a new Color3 object
  69736. */
  69737. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69738. /**
  69739. * Check the content of a given array and convert it to an array containing RGBA data
  69740. * If the original array was already containing count * 4 values then it is returned directly
  69741. * @param colors defines the array to check
  69742. * @param count defines the number of RGBA data to expect
  69743. * @returns an array containing count * 4 values (RGBA)
  69744. */
  69745. static CheckColors4(colors: number[], count: number): number[];
  69746. }
  69747. /**
  69748. * @hidden
  69749. */
  69750. export class TmpColors {
  69751. static Color3: Color3[];
  69752. static Color4: Color4[];
  69753. }
  69754. }
  69755. declare module BABYLON {
  69756. /**
  69757. * Class representing spherical harmonics coefficients to the 3rd degree
  69758. */
  69759. export class SphericalHarmonics {
  69760. /**
  69761. * Defines whether or not the harmonics have been prescaled for rendering.
  69762. */
  69763. preScaled: boolean;
  69764. /**
  69765. * The l0,0 coefficients of the spherical harmonics
  69766. */
  69767. l00: Vector3;
  69768. /**
  69769. * The l1,-1 coefficients of the spherical harmonics
  69770. */
  69771. l1_1: Vector3;
  69772. /**
  69773. * The l1,0 coefficients of the spherical harmonics
  69774. */
  69775. l10: Vector3;
  69776. /**
  69777. * The l1,1 coefficients of the spherical harmonics
  69778. */
  69779. l11: Vector3;
  69780. /**
  69781. * The l2,-2 coefficients of the spherical harmonics
  69782. */
  69783. l2_2: Vector3;
  69784. /**
  69785. * The l2,-1 coefficients of the spherical harmonics
  69786. */
  69787. l2_1: Vector3;
  69788. /**
  69789. * The l2,0 coefficients of the spherical harmonics
  69790. */
  69791. l20: Vector3;
  69792. /**
  69793. * The l2,1 coefficients of the spherical harmonics
  69794. */
  69795. l21: Vector3;
  69796. /**
  69797. * The l2,2 coefficients of the spherical harmonics
  69798. */
  69799. l22: Vector3;
  69800. /**
  69801. * Adds a light to the spherical harmonics
  69802. * @param direction the direction of the light
  69803. * @param color the color of the light
  69804. * @param deltaSolidAngle the delta solid angle of the light
  69805. */
  69806. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69807. /**
  69808. * Scales the spherical harmonics by the given amount
  69809. * @param scale the amount to scale
  69810. */
  69811. scaleInPlace(scale: number): void;
  69812. /**
  69813. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69814. *
  69815. * ```
  69816. * E_lm = A_l * L_lm
  69817. * ```
  69818. *
  69819. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69820. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69821. * the scaling factors are given in equation 9.
  69822. */
  69823. convertIncidentRadianceToIrradiance(): void;
  69824. /**
  69825. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69826. *
  69827. * ```
  69828. * L = (1/pi) * E * rho
  69829. * ```
  69830. *
  69831. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69832. */
  69833. convertIrradianceToLambertianRadiance(): void;
  69834. /**
  69835. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69836. * required operations at run time.
  69837. *
  69838. * This is simply done by scaling back the SH with Ylm constants parameter.
  69839. * The trigonometric part being applied by the shader at run time.
  69840. */
  69841. preScaleForRendering(): void;
  69842. /**
  69843. * Constructs a spherical harmonics from an array.
  69844. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69845. * @returns the spherical harmonics
  69846. */
  69847. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69848. /**
  69849. * Gets the spherical harmonics from polynomial
  69850. * @param polynomial the spherical polynomial
  69851. * @returns the spherical harmonics
  69852. */
  69853. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69854. }
  69855. /**
  69856. * Class representing spherical polynomial coefficients to the 3rd degree
  69857. */
  69858. export class SphericalPolynomial {
  69859. private _harmonics;
  69860. /**
  69861. * The spherical harmonics used to create the polynomials.
  69862. */
  69863. readonly preScaledHarmonics: SphericalHarmonics;
  69864. /**
  69865. * The x coefficients of the spherical polynomial
  69866. */
  69867. x: Vector3;
  69868. /**
  69869. * The y coefficients of the spherical polynomial
  69870. */
  69871. y: Vector3;
  69872. /**
  69873. * The z coefficients of the spherical polynomial
  69874. */
  69875. z: Vector3;
  69876. /**
  69877. * The xx coefficients of the spherical polynomial
  69878. */
  69879. xx: Vector3;
  69880. /**
  69881. * The yy coefficients of the spherical polynomial
  69882. */
  69883. yy: Vector3;
  69884. /**
  69885. * The zz coefficients of the spherical polynomial
  69886. */
  69887. zz: Vector3;
  69888. /**
  69889. * The xy coefficients of the spherical polynomial
  69890. */
  69891. xy: Vector3;
  69892. /**
  69893. * The yz coefficients of the spherical polynomial
  69894. */
  69895. yz: Vector3;
  69896. /**
  69897. * The zx coefficients of the spherical polynomial
  69898. */
  69899. zx: Vector3;
  69900. /**
  69901. * Adds an ambient color to the spherical polynomial
  69902. * @param color the color to add
  69903. */
  69904. addAmbient(color: Color3): void;
  69905. /**
  69906. * Scales the spherical polynomial by the given amount
  69907. * @param scale the amount to scale
  69908. */
  69909. scaleInPlace(scale: number): void;
  69910. /**
  69911. * Gets the spherical polynomial from harmonics
  69912. * @param harmonics the spherical harmonics
  69913. * @returns the spherical polynomial
  69914. */
  69915. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69916. /**
  69917. * Constructs a spherical polynomial from an array.
  69918. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69919. * @returns the spherical polynomial
  69920. */
  69921. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69922. }
  69923. }
  69924. declare module BABYLON {
  69925. /**
  69926. * Define options used to create a render target texture
  69927. */
  69928. export class RenderTargetCreationOptions {
  69929. /**
  69930. * Specifies is mipmaps must be generated
  69931. */
  69932. generateMipMaps?: boolean;
  69933. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69934. generateDepthBuffer?: boolean;
  69935. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69936. generateStencilBuffer?: boolean;
  69937. /** Defines texture type (int by default) */
  69938. type?: number;
  69939. /** Defines sampling mode (trilinear by default) */
  69940. samplingMode?: number;
  69941. /** Defines format (RGBA by default) */
  69942. format?: number;
  69943. }
  69944. }
  69945. declare module BABYLON {
  69946. /**
  69947. * @hidden
  69948. **/
  69949. export class _AlphaState {
  69950. private _isAlphaBlendDirty;
  69951. private _isBlendFunctionParametersDirty;
  69952. private _isBlendEquationParametersDirty;
  69953. private _isBlendConstantsDirty;
  69954. private _alphaBlend;
  69955. private _blendFunctionParameters;
  69956. private _blendEquationParameters;
  69957. private _blendConstants;
  69958. /**
  69959. * Initializes the state.
  69960. */
  69961. constructor();
  69962. readonly isDirty: boolean;
  69963. alphaBlend: boolean;
  69964. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69965. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69966. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69967. reset(): void;
  69968. apply(gl: WebGLRenderingContext): void;
  69969. }
  69970. }
  69971. declare module BABYLON {
  69972. /**
  69973. * @hidden
  69974. **/
  69975. export class _DepthCullingState {
  69976. private _isDepthTestDirty;
  69977. private _isDepthMaskDirty;
  69978. private _isDepthFuncDirty;
  69979. private _isCullFaceDirty;
  69980. private _isCullDirty;
  69981. private _isZOffsetDirty;
  69982. private _isFrontFaceDirty;
  69983. private _depthTest;
  69984. private _depthMask;
  69985. private _depthFunc;
  69986. private _cull;
  69987. private _cullFace;
  69988. private _zOffset;
  69989. private _frontFace;
  69990. /**
  69991. * Initializes the state.
  69992. */
  69993. constructor();
  69994. readonly isDirty: boolean;
  69995. zOffset: number;
  69996. cullFace: Nullable<number>;
  69997. cull: Nullable<boolean>;
  69998. depthFunc: Nullable<number>;
  69999. depthMask: boolean;
  70000. depthTest: boolean;
  70001. frontFace: Nullable<number>;
  70002. reset(): void;
  70003. apply(gl: WebGLRenderingContext): void;
  70004. }
  70005. }
  70006. declare module BABYLON {
  70007. /**
  70008. * @hidden
  70009. **/
  70010. export class _StencilState {
  70011. /** 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 */
  70012. static readonly ALWAYS: number;
  70013. /** Passed to stencilOperation to specify that stencil value must be kept */
  70014. static readonly KEEP: number;
  70015. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70016. static readonly REPLACE: number;
  70017. private _isStencilTestDirty;
  70018. private _isStencilMaskDirty;
  70019. private _isStencilFuncDirty;
  70020. private _isStencilOpDirty;
  70021. private _stencilTest;
  70022. private _stencilMask;
  70023. private _stencilFunc;
  70024. private _stencilFuncRef;
  70025. private _stencilFuncMask;
  70026. private _stencilOpStencilFail;
  70027. private _stencilOpDepthFail;
  70028. private _stencilOpStencilDepthPass;
  70029. readonly isDirty: boolean;
  70030. stencilFunc: number;
  70031. stencilFuncRef: number;
  70032. stencilFuncMask: number;
  70033. stencilOpStencilFail: number;
  70034. stencilOpDepthFail: number;
  70035. stencilOpStencilDepthPass: number;
  70036. stencilMask: number;
  70037. stencilTest: boolean;
  70038. constructor();
  70039. reset(): void;
  70040. apply(gl: WebGLRenderingContext): void;
  70041. }
  70042. }
  70043. declare module BABYLON {
  70044. /**
  70045. * @hidden
  70046. **/
  70047. export class _TimeToken {
  70048. _startTimeQuery: Nullable<WebGLQuery>;
  70049. _endTimeQuery: Nullable<WebGLQuery>;
  70050. _timeElapsedQuery: Nullable<WebGLQuery>;
  70051. _timeElapsedQueryEnded: boolean;
  70052. }
  70053. }
  70054. declare module BABYLON {
  70055. /**
  70056. * Class used to evalaute queries containing `and` and `or` operators
  70057. */
  70058. export class AndOrNotEvaluator {
  70059. /**
  70060. * Evaluate a query
  70061. * @param query defines the query to evaluate
  70062. * @param evaluateCallback defines the callback used to filter result
  70063. * @returns true if the query matches
  70064. */
  70065. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70066. private static _HandleParenthesisContent;
  70067. private static _SimplifyNegation;
  70068. }
  70069. }
  70070. declare module BABYLON {
  70071. /**
  70072. * Class used to store custom tags
  70073. */
  70074. export class Tags {
  70075. /**
  70076. * Adds support for tags on the given object
  70077. * @param obj defines the object to use
  70078. */
  70079. static EnableFor(obj: any): void;
  70080. /**
  70081. * Removes tags support
  70082. * @param obj defines the object to use
  70083. */
  70084. static DisableFor(obj: any): void;
  70085. /**
  70086. * Gets a boolean indicating if the given object has tags
  70087. * @param obj defines the object to use
  70088. * @returns a boolean
  70089. */
  70090. static HasTags(obj: any): boolean;
  70091. /**
  70092. * Gets the tags available on a given object
  70093. * @param obj defines the object to use
  70094. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70095. * @returns the tags
  70096. */
  70097. static GetTags(obj: any, asString?: boolean): any;
  70098. /**
  70099. * Adds tags to an object
  70100. * @param obj defines the object to use
  70101. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70102. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70103. */
  70104. static AddTagsTo(obj: any, tagsString: string): void;
  70105. /**
  70106. * @hidden
  70107. */
  70108. static _AddTagTo(obj: any, tag: string): void;
  70109. /**
  70110. * Removes specific tags from a specific object
  70111. * @param obj defines the object to use
  70112. * @param tagsString defines the tags to remove
  70113. */
  70114. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70115. /**
  70116. * @hidden
  70117. */
  70118. static _RemoveTagFrom(obj: any, tag: string): void;
  70119. /**
  70120. * Defines if tags hosted on an object match a given query
  70121. * @param obj defines the object to use
  70122. * @param tagsQuery defines the tag query
  70123. * @returns a boolean
  70124. */
  70125. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70126. }
  70127. }
  70128. declare module BABYLON {
  70129. /**
  70130. * Defines potential orientation for back face culling
  70131. */
  70132. export enum Orientation {
  70133. /**
  70134. * Clockwise
  70135. */
  70136. CW = 0,
  70137. /** Counter clockwise */
  70138. CCW = 1
  70139. }
  70140. /** Class used to represent a Bezier curve */
  70141. export class BezierCurve {
  70142. /**
  70143. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  70144. * @param t defines the time
  70145. * @param x1 defines the left coordinate on X axis
  70146. * @param y1 defines the left coordinate on Y axis
  70147. * @param x2 defines the right coordinate on X axis
  70148. * @param y2 defines the right coordinate on Y axis
  70149. * @returns the interpolated value
  70150. */
  70151. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  70152. }
  70153. /**
  70154. * Defines angle representation
  70155. */
  70156. export class Angle {
  70157. private _radians;
  70158. /**
  70159. * Creates an Angle object of "radians" radians (float).
  70160. * @param radians the angle in radians
  70161. */
  70162. constructor(radians: number);
  70163. /**
  70164. * Get value in degrees
  70165. * @returns the Angle value in degrees (float)
  70166. */
  70167. degrees(): number;
  70168. /**
  70169. * Get value in radians
  70170. * @returns the Angle value in radians (float)
  70171. */
  70172. radians(): number;
  70173. /**
  70174. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  70175. * @param a defines first vector
  70176. * @param b defines second vector
  70177. * @returns a new Angle
  70178. */
  70179. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  70180. /**
  70181. * Gets a new Angle object from the given float in radians
  70182. * @param radians defines the angle value in radians
  70183. * @returns a new Angle
  70184. */
  70185. static FromRadians(radians: number): Angle;
  70186. /**
  70187. * Gets a new Angle object from the given float in degrees
  70188. * @param degrees defines the angle value in degrees
  70189. * @returns a new Angle
  70190. */
  70191. static FromDegrees(degrees: number): Angle;
  70192. }
  70193. /**
  70194. * This represents an arc in a 2d space.
  70195. */
  70196. export class Arc2 {
  70197. /** Defines the start point of the arc */
  70198. startPoint: Vector2;
  70199. /** Defines the mid point of the arc */
  70200. midPoint: Vector2;
  70201. /** Defines the end point of the arc */
  70202. endPoint: Vector2;
  70203. /**
  70204. * Defines the center point of the arc.
  70205. */
  70206. centerPoint: Vector2;
  70207. /**
  70208. * Defines the radius of the arc.
  70209. */
  70210. radius: number;
  70211. /**
  70212. * Defines the angle of the arc (from mid point to end point).
  70213. */
  70214. angle: Angle;
  70215. /**
  70216. * Defines the start angle of the arc (from start point to middle point).
  70217. */
  70218. startAngle: Angle;
  70219. /**
  70220. * Defines the orientation of the arc (clock wise/counter clock wise).
  70221. */
  70222. orientation: Orientation;
  70223. /**
  70224. * Creates an Arc object from the three given points : start, middle and end.
  70225. * @param startPoint Defines the start point of the arc
  70226. * @param midPoint Defines the midlle point of the arc
  70227. * @param endPoint Defines the end point of the arc
  70228. */
  70229. constructor(
  70230. /** Defines the start point of the arc */
  70231. startPoint: Vector2,
  70232. /** Defines the mid point of the arc */
  70233. midPoint: Vector2,
  70234. /** Defines the end point of the arc */
  70235. endPoint: Vector2);
  70236. }
  70237. /**
  70238. * Represents a 2D path made up of multiple 2D points
  70239. */
  70240. export class Path2 {
  70241. private _points;
  70242. private _length;
  70243. /**
  70244. * If the path start and end point are the same
  70245. */
  70246. closed: boolean;
  70247. /**
  70248. * Creates a Path2 object from the starting 2D coordinates x and y.
  70249. * @param x the starting points x value
  70250. * @param y the starting points y value
  70251. */
  70252. constructor(x: number, y: number);
  70253. /**
  70254. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  70255. * @param x the added points x value
  70256. * @param y the added points y value
  70257. * @returns the updated Path2.
  70258. */
  70259. addLineTo(x: number, y: number): Path2;
  70260. /**
  70261. * 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.
  70262. * @param midX middle point x value
  70263. * @param midY middle point y value
  70264. * @param endX end point x value
  70265. * @param endY end point y value
  70266. * @param numberOfSegments (default: 36)
  70267. * @returns the updated Path2.
  70268. */
  70269. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  70270. /**
  70271. * Closes the Path2.
  70272. * @returns the Path2.
  70273. */
  70274. close(): Path2;
  70275. /**
  70276. * Gets the sum of the distance between each sequential point in the path
  70277. * @returns the Path2 total length (float).
  70278. */
  70279. length(): number;
  70280. /**
  70281. * Gets the points which construct the path
  70282. * @returns the Path2 internal array of points.
  70283. */
  70284. getPoints(): Vector2[];
  70285. /**
  70286. * Retreives the point at the distance aways from the starting point
  70287. * @param normalizedLengthPosition the length along the path to retreive the point from
  70288. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  70289. */
  70290. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  70291. /**
  70292. * Creates a new path starting from an x and y position
  70293. * @param x starting x value
  70294. * @param y starting y value
  70295. * @returns a new Path2 starting at the coordinates (x, y).
  70296. */
  70297. static StartingAt(x: number, y: number): Path2;
  70298. }
  70299. /**
  70300. * Represents a 3D path made up of multiple 3D points
  70301. */
  70302. export class Path3D {
  70303. /**
  70304. * an array of Vector3, the curve axis of the Path3D
  70305. */
  70306. path: Vector3[];
  70307. private _curve;
  70308. private _distances;
  70309. private _tangents;
  70310. private _normals;
  70311. private _binormals;
  70312. private _raw;
  70313. /**
  70314. * new Path3D(path, normal, raw)
  70315. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  70316. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  70317. * @param path an array of Vector3, the curve axis of the Path3D
  70318. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  70319. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  70320. */
  70321. constructor(
  70322. /**
  70323. * an array of Vector3, the curve axis of the Path3D
  70324. */
  70325. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  70326. /**
  70327. * Returns the Path3D array of successive Vector3 designing its curve.
  70328. * @returns the Path3D array of successive Vector3 designing its curve.
  70329. */
  70330. getCurve(): Vector3[];
  70331. /**
  70332. * Returns an array populated with tangent vectors on each Path3D curve point.
  70333. * @returns an array populated with tangent vectors on each Path3D curve point.
  70334. */
  70335. getTangents(): Vector3[];
  70336. /**
  70337. * Returns an array populated with normal vectors on each Path3D curve point.
  70338. * @returns an array populated with normal vectors on each Path3D curve point.
  70339. */
  70340. getNormals(): Vector3[];
  70341. /**
  70342. * Returns an array populated with binormal vectors on each Path3D curve point.
  70343. * @returns an array populated with binormal vectors on each Path3D curve point.
  70344. */
  70345. getBinormals(): Vector3[];
  70346. /**
  70347. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  70348. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  70349. */
  70350. getDistances(): number[];
  70351. /**
  70352. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  70353. * @param path path which all values are copied into the curves points
  70354. * @param firstNormal which should be projected onto the curve
  70355. * @returns the same object updated.
  70356. */
  70357. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  70358. private _compute;
  70359. private _getFirstNonNullVector;
  70360. private _getLastNonNullVector;
  70361. private _normalVector;
  70362. }
  70363. /**
  70364. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70365. * A Curve3 is designed from a series of successive Vector3.
  70366. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  70367. */
  70368. export class Curve3 {
  70369. private _points;
  70370. private _length;
  70371. /**
  70372. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  70373. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  70374. * @param v1 (Vector3) the control point
  70375. * @param v2 (Vector3) the end point of the Quadratic Bezier
  70376. * @param nbPoints (integer) the wanted number of points in the curve
  70377. * @returns the created Curve3
  70378. */
  70379. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70380. /**
  70381. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  70382. * @param v0 (Vector3) the origin point of the Cubic Bezier
  70383. * @param v1 (Vector3) the first control point
  70384. * @param v2 (Vector3) the second control point
  70385. * @param v3 (Vector3) the end point of the Cubic Bezier
  70386. * @param nbPoints (integer) the wanted number of points in the curve
  70387. * @returns the created Curve3
  70388. */
  70389. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70390. /**
  70391. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  70392. * @param p1 (Vector3) the origin point of the Hermite Spline
  70393. * @param t1 (Vector3) the tangent vector at the origin point
  70394. * @param p2 (Vector3) the end point of the Hermite Spline
  70395. * @param t2 (Vector3) the tangent vector at the end point
  70396. * @param nbPoints (integer) the wanted number of points in the curve
  70397. * @returns the created Curve3
  70398. */
  70399. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70400. /**
  70401. * Returns a Curve3 object along a CatmullRom Spline curve :
  70402. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  70403. * @param nbPoints (integer) the wanted number of points between each curve control points
  70404. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  70405. * @returns the created Curve3
  70406. */
  70407. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  70408. /**
  70409. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70410. * A Curve3 is designed from a series of successive Vector3.
  70411. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  70412. * @param points points which make up the curve
  70413. */
  70414. constructor(points: Vector3[]);
  70415. /**
  70416. * @returns the Curve3 stored array of successive Vector3
  70417. */
  70418. getPoints(): Vector3[];
  70419. /**
  70420. * @returns the computed length (float) of the curve.
  70421. */
  70422. length(): number;
  70423. /**
  70424. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  70425. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  70426. * curveA and curveB keep unchanged.
  70427. * @param curve the curve to continue from this curve
  70428. * @returns the newly constructed curve
  70429. */
  70430. continue(curve: DeepImmutable<Curve3>): Curve3;
  70431. private _computeLength;
  70432. }
  70433. }
  70434. declare module BABYLON {
  70435. /**
  70436. * This represents the main contract an easing function should follow.
  70437. * Easing functions are used throughout the animation system.
  70438. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70439. */
  70440. export interface IEasingFunction {
  70441. /**
  70442. * Given an input gradient between 0 and 1, this returns the corrseponding value
  70443. * of the easing function.
  70444. * The link below provides some of the most common examples of easing functions.
  70445. * @see https://easings.net/
  70446. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70447. * @returns the corresponding value on the curve defined by the easing function
  70448. */
  70449. ease(gradient: number): number;
  70450. }
  70451. /**
  70452. * Base class used for every default easing function.
  70453. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70454. */
  70455. export class EasingFunction implements IEasingFunction {
  70456. /**
  70457. * Interpolation follows the mathematical formula associated with the easing function.
  70458. */
  70459. static readonly EASINGMODE_EASEIN: number;
  70460. /**
  70461. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  70462. */
  70463. static readonly EASINGMODE_EASEOUT: number;
  70464. /**
  70465. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  70466. */
  70467. static readonly EASINGMODE_EASEINOUT: number;
  70468. private _easingMode;
  70469. /**
  70470. * Sets the easing mode of the current function.
  70471. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  70472. */
  70473. setEasingMode(easingMode: number): void;
  70474. /**
  70475. * Gets the current easing mode.
  70476. * @returns the easing mode
  70477. */
  70478. getEasingMode(): number;
  70479. /**
  70480. * @hidden
  70481. */
  70482. easeInCore(gradient: number): number;
  70483. /**
  70484. * Given an input gradient between 0 and 1, this returns the corresponding value
  70485. * of the easing function.
  70486. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70487. * @returns the corresponding value on the curve defined by the easing function
  70488. */
  70489. ease(gradient: number): number;
  70490. }
  70491. /**
  70492. * Easing function with a circle shape (see link below).
  70493. * @see https://easings.net/#easeInCirc
  70494. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70495. */
  70496. export class CircleEase extends EasingFunction implements IEasingFunction {
  70497. /** @hidden */
  70498. easeInCore(gradient: number): number;
  70499. }
  70500. /**
  70501. * Easing function with a ease back shape (see link below).
  70502. * @see https://easings.net/#easeInBack
  70503. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70504. */
  70505. export class BackEase extends EasingFunction implements IEasingFunction {
  70506. /** Defines the amplitude of the function */
  70507. amplitude: number;
  70508. /**
  70509. * Instantiates a back ease easing
  70510. * @see https://easings.net/#easeInBack
  70511. * @param amplitude Defines the amplitude of the function
  70512. */
  70513. constructor(
  70514. /** Defines the amplitude of the function */
  70515. amplitude?: number);
  70516. /** @hidden */
  70517. easeInCore(gradient: number): number;
  70518. }
  70519. /**
  70520. * Easing function with a bouncing shape (see link below).
  70521. * @see https://easings.net/#easeInBounce
  70522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70523. */
  70524. export class BounceEase extends EasingFunction implements IEasingFunction {
  70525. /** Defines the number of bounces */
  70526. bounces: number;
  70527. /** Defines the amplitude of the bounce */
  70528. bounciness: number;
  70529. /**
  70530. * Instantiates a bounce easing
  70531. * @see https://easings.net/#easeInBounce
  70532. * @param bounces Defines the number of bounces
  70533. * @param bounciness Defines the amplitude of the bounce
  70534. */
  70535. constructor(
  70536. /** Defines the number of bounces */
  70537. bounces?: number,
  70538. /** Defines the amplitude of the bounce */
  70539. bounciness?: number);
  70540. /** @hidden */
  70541. easeInCore(gradient: number): number;
  70542. }
  70543. /**
  70544. * Easing function with a power of 3 shape (see link below).
  70545. * @see https://easings.net/#easeInCubic
  70546. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70547. */
  70548. export class CubicEase extends EasingFunction implements IEasingFunction {
  70549. /** @hidden */
  70550. easeInCore(gradient: number): number;
  70551. }
  70552. /**
  70553. * Easing function with an elastic shape (see link below).
  70554. * @see https://easings.net/#easeInElastic
  70555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70556. */
  70557. export class ElasticEase extends EasingFunction implements IEasingFunction {
  70558. /** Defines the number of oscillations*/
  70559. oscillations: number;
  70560. /** Defines the amplitude of the oscillations*/
  70561. springiness: number;
  70562. /**
  70563. * Instantiates an elastic easing function
  70564. * @see https://easings.net/#easeInElastic
  70565. * @param oscillations Defines the number of oscillations
  70566. * @param springiness Defines the amplitude of the oscillations
  70567. */
  70568. constructor(
  70569. /** Defines the number of oscillations*/
  70570. oscillations?: number,
  70571. /** Defines the amplitude of the oscillations*/
  70572. springiness?: number);
  70573. /** @hidden */
  70574. easeInCore(gradient: number): number;
  70575. }
  70576. /**
  70577. * Easing function with an exponential shape (see link below).
  70578. * @see https://easings.net/#easeInExpo
  70579. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70580. */
  70581. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  70582. /** Defines the exponent of the function */
  70583. exponent: number;
  70584. /**
  70585. * Instantiates an exponential easing function
  70586. * @see https://easings.net/#easeInExpo
  70587. * @param exponent Defines the exponent of the function
  70588. */
  70589. constructor(
  70590. /** Defines the exponent of the function */
  70591. exponent?: number);
  70592. /** @hidden */
  70593. easeInCore(gradient: number): number;
  70594. }
  70595. /**
  70596. * Easing function with a power shape (see link below).
  70597. * @see https://easings.net/#easeInQuad
  70598. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70599. */
  70600. export class PowerEase extends EasingFunction implements IEasingFunction {
  70601. /** Defines the power of the function */
  70602. power: number;
  70603. /**
  70604. * Instantiates an power base easing function
  70605. * @see https://easings.net/#easeInQuad
  70606. * @param power Defines the power of the function
  70607. */
  70608. constructor(
  70609. /** Defines the power of the function */
  70610. power?: number);
  70611. /** @hidden */
  70612. easeInCore(gradient: number): number;
  70613. }
  70614. /**
  70615. * Easing function with a power of 2 shape (see link below).
  70616. * @see https://easings.net/#easeInQuad
  70617. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70618. */
  70619. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  70620. /** @hidden */
  70621. easeInCore(gradient: number): number;
  70622. }
  70623. /**
  70624. * Easing function with a power of 4 shape (see link below).
  70625. * @see https://easings.net/#easeInQuart
  70626. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70627. */
  70628. export class QuarticEase extends EasingFunction implements IEasingFunction {
  70629. /** @hidden */
  70630. easeInCore(gradient: number): number;
  70631. }
  70632. /**
  70633. * Easing function with a power of 5 shape (see link below).
  70634. * @see https://easings.net/#easeInQuint
  70635. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70636. */
  70637. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70638. /** @hidden */
  70639. easeInCore(gradient: number): number;
  70640. }
  70641. /**
  70642. * Easing function with a sin shape (see link below).
  70643. * @see https://easings.net/#easeInSine
  70644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70645. */
  70646. export class SineEase extends EasingFunction implements IEasingFunction {
  70647. /** @hidden */
  70648. easeInCore(gradient: number): number;
  70649. }
  70650. /**
  70651. * Easing function with a bezier shape (see link below).
  70652. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70654. */
  70655. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70656. /** Defines the x component of the start tangent in the bezier curve */
  70657. x1: number;
  70658. /** Defines the y component of the start tangent in the bezier curve */
  70659. y1: number;
  70660. /** Defines the x component of the end tangent in the bezier curve */
  70661. x2: number;
  70662. /** Defines the y component of the end tangent in the bezier curve */
  70663. y2: number;
  70664. /**
  70665. * Instantiates a bezier function
  70666. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70667. * @param x1 Defines the x component of the start tangent in the bezier curve
  70668. * @param y1 Defines the y component of the start tangent in the bezier curve
  70669. * @param x2 Defines the x component of the end tangent in the bezier curve
  70670. * @param y2 Defines the y component of the end tangent in the bezier curve
  70671. */
  70672. constructor(
  70673. /** Defines the x component of the start tangent in the bezier curve */
  70674. x1?: number,
  70675. /** Defines the y component of the start tangent in the bezier curve */
  70676. y1?: number,
  70677. /** Defines the x component of the end tangent in the bezier curve */
  70678. x2?: number,
  70679. /** Defines the y component of the end tangent in the bezier curve */
  70680. y2?: number);
  70681. /** @hidden */
  70682. easeInCore(gradient: number): number;
  70683. }
  70684. }
  70685. declare module BABYLON {
  70686. /**
  70687. * Defines an interface which represents an animation key frame
  70688. */
  70689. export interface IAnimationKey {
  70690. /**
  70691. * Frame of the key frame
  70692. */
  70693. frame: number;
  70694. /**
  70695. * Value at the specifies key frame
  70696. */
  70697. value: any;
  70698. /**
  70699. * The input tangent for the cubic hermite spline
  70700. */
  70701. inTangent?: any;
  70702. /**
  70703. * The output tangent for the cubic hermite spline
  70704. */
  70705. outTangent?: any;
  70706. /**
  70707. * The animation interpolation type
  70708. */
  70709. interpolation?: AnimationKeyInterpolation;
  70710. }
  70711. /**
  70712. * Enum for the animation key frame interpolation type
  70713. */
  70714. export enum AnimationKeyInterpolation {
  70715. /**
  70716. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70717. */
  70718. STEP = 1
  70719. }
  70720. }
  70721. declare module BABYLON {
  70722. /**
  70723. * Represents the range of an animation
  70724. */
  70725. export class AnimationRange {
  70726. /**The name of the animation range**/
  70727. name: string;
  70728. /**The starting frame of the animation */
  70729. from: number;
  70730. /**The ending frame of the animation*/
  70731. to: number;
  70732. /**
  70733. * Initializes the range of an animation
  70734. * @param name The name of the animation range
  70735. * @param from The starting frame of the animation
  70736. * @param to The ending frame of the animation
  70737. */
  70738. constructor(
  70739. /**The name of the animation range**/
  70740. name: string,
  70741. /**The starting frame of the animation */
  70742. from: number,
  70743. /**The ending frame of the animation*/
  70744. to: number);
  70745. /**
  70746. * Makes a copy of the animation range
  70747. * @returns A copy of the animation range
  70748. */
  70749. clone(): AnimationRange;
  70750. }
  70751. }
  70752. declare module BABYLON {
  70753. /**
  70754. * Composed of a frame, and an action function
  70755. */
  70756. export class AnimationEvent {
  70757. /** The frame for which the event is triggered **/
  70758. frame: number;
  70759. /** The event to perform when triggered **/
  70760. action: (currentFrame: number) => void;
  70761. /** Specifies if the event should be triggered only once**/
  70762. onlyOnce?: boolean | undefined;
  70763. /**
  70764. * Specifies if the animation event is done
  70765. */
  70766. isDone: boolean;
  70767. /**
  70768. * Initializes the animation event
  70769. * @param frame The frame for which the event is triggered
  70770. * @param action The event to perform when triggered
  70771. * @param onlyOnce Specifies if the event should be triggered only once
  70772. */
  70773. constructor(
  70774. /** The frame for which the event is triggered **/
  70775. frame: number,
  70776. /** The event to perform when triggered **/
  70777. action: (currentFrame: number) => void,
  70778. /** Specifies if the event should be triggered only once**/
  70779. onlyOnce?: boolean | undefined);
  70780. /** @hidden */
  70781. _clone(): AnimationEvent;
  70782. }
  70783. }
  70784. declare module BABYLON {
  70785. /**
  70786. * Interface used to define a behavior
  70787. */
  70788. export interface Behavior<T> {
  70789. /** gets or sets behavior's name */
  70790. name: string;
  70791. /**
  70792. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70793. */
  70794. init(): void;
  70795. /**
  70796. * Called when the behavior is attached to a target
  70797. * @param target defines the target where the behavior is attached to
  70798. */
  70799. attach(target: T): void;
  70800. /**
  70801. * Called when the behavior is detached from its target
  70802. */
  70803. detach(): void;
  70804. }
  70805. /**
  70806. * Interface implemented by classes supporting behaviors
  70807. */
  70808. export interface IBehaviorAware<T> {
  70809. /**
  70810. * Attach a behavior
  70811. * @param behavior defines the behavior to attach
  70812. * @returns the current host
  70813. */
  70814. addBehavior(behavior: Behavior<T>): T;
  70815. /**
  70816. * Remove a behavior from the current object
  70817. * @param behavior defines the behavior to detach
  70818. * @returns the current host
  70819. */
  70820. removeBehavior(behavior: Behavior<T>): T;
  70821. /**
  70822. * Gets a behavior using its name to search
  70823. * @param name defines the name to search
  70824. * @returns the behavior or null if not found
  70825. */
  70826. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70827. }
  70828. }
  70829. declare module BABYLON {
  70830. /**
  70831. * Defines an array and its length.
  70832. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70833. */
  70834. export interface ISmartArrayLike<T> {
  70835. /**
  70836. * The data of the array.
  70837. */
  70838. data: Array<T>;
  70839. /**
  70840. * The active length of the array.
  70841. */
  70842. length: number;
  70843. }
  70844. /**
  70845. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70846. */
  70847. export class SmartArray<T> implements ISmartArrayLike<T> {
  70848. /**
  70849. * The full set of data from the array.
  70850. */
  70851. data: Array<T>;
  70852. /**
  70853. * The active length of the array.
  70854. */
  70855. length: number;
  70856. protected _id: number;
  70857. /**
  70858. * Instantiates a Smart Array.
  70859. * @param capacity defines the default capacity of the array.
  70860. */
  70861. constructor(capacity: number);
  70862. /**
  70863. * Pushes a value at the end of the active data.
  70864. * @param value defines the object to push in the array.
  70865. */
  70866. push(value: T): void;
  70867. /**
  70868. * Iterates over the active data and apply the lambda to them.
  70869. * @param func defines the action to apply on each value.
  70870. */
  70871. forEach(func: (content: T) => void): void;
  70872. /**
  70873. * Sorts the full sets of data.
  70874. * @param compareFn defines the comparison function to apply.
  70875. */
  70876. sort(compareFn: (a: T, b: T) => number): void;
  70877. /**
  70878. * Resets the active data to an empty array.
  70879. */
  70880. reset(): void;
  70881. /**
  70882. * Releases all the data from the array as well as the array.
  70883. */
  70884. dispose(): void;
  70885. /**
  70886. * Concats the active data with a given array.
  70887. * @param array defines the data to concatenate with.
  70888. */
  70889. concat(array: any): void;
  70890. /**
  70891. * Returns the position of a value in the active data.
  70892. * @param value defines the value to find the index for
  70893. * @returns the index if found in the active data otherwise -1
  70894. */
  70895. indexOf(value: T): number;
  70896. /**
  70897. * Returns whether an element is part of the active data.
  70898. * @param value defines the value to look for
  70899. * @returns true if found in the active data otherwise false
  70900. */
  70901. contains(value: T): boolean;
  70902. private static _GlobalId;
  70903. }
  70904. /**
  70905. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70906. * The data in this array can only be present once
  70907. */
  70908. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70909. private _duplicateId;
  70910. /**
  70911. * Pushes a value at the end of the active data.
  70912. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70913. * @param value defines the object to push in the array.
  70914. */
  70915. push(value: T): void;
  70916. /**
  70917. * Pushes a value at the end of the active data.
  70918. * If the data is already present, it won t be added again
  70919. * @param value defines the object to push in the array.
  70920. * @returns true if added false if it was already present
  70921. */
  70922. pushNoDuplicate(value: T): boolean;
  70923. /**
  70924. * Resets the active data to an empty array.
  70925. */
  70926. reset(): void;
  70927. /**
  70928. * Concats the active data with a given array.
  70929. * This ensures no dupplicate will be present in the result.
  70930. * @param array defines the data to concatenate with.
  70931. */
  70932. concatWithNoDuplicate(array: any): void;
  70933. }
  70934. }
  70935. declare module BABYLON {
  70936. /**
  70937. * @ignore
  70938. * This is a list of all the different input types that are available in the application.
  70939. * Fo instance: ArcRotateCameraGamepadInput...
  70940. */
  70941. export var CameraInputTypes: {};
  70942. /**
  70943. * This is the contract to implement in order to create a new input class.
  70944. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70945. */
  70946. export interface ICameraInput<TCamera extends Camera> {
  70947. /**
  70948. * Defines the camera the input is attached to.
  70949. */
  70950. camera: Nullable<TCamera>;
  70951. /**
  70952. * Gets the class name of the current intput.
  70953. * @returns the class name
  70954. */
  70955. getClassName(): string;
  70956. /**
  70957. * Get the friendly name associated with the input class.
  70958. * @returns the input friendly name
  70959. */
  70960. getSimpleName(): string;
  70961. /**
  70962. * Attach the input controls to a specific dom element to get the input from.
  70963. * @param element Defines the element the controls should be listened from
  70964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70965. */
  70966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70967. /**
  70968. * Detach the current controls from the specified dom element.
  70969. * @param element Defines the element to stop listening the inputs from
  70970. */
  70971. detachControl(element: Nullable<HTMLElement>): void;
  70972. /**
  70973. * Update the current camera state depending on the inputs that have been used this frame.
  70974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70975. */
  70976. checkInputs?: () => void;
  70977. }
  70978. /**
  70979. * Represents a map of input types to input instance or input index to input instance.
  70980. */
  70981. export interface CameraInputsMap<TCamera extends Camera> {
  70982. /**
  70983. * Accessor to the input by input type.
  70984. */
  70985. [name: string]: ICameraInput<TCamera>;
  70986. /**
  70987. * Accessor to the input by input index.
  70988. */
  70989. [idx: number]: ICameraInput<TCamera>;
  70990. }
  70991. /**
  70992. * This represents the input manager used within a camera.
  70993. * It helps dealing with all the different kind of input attached to a camera.
  70994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70995. */
  70996. export class CameraInputsManager<TCamera extends Camera> {
  70997. /**
  70998. * Defines the list of inputs attahed to the camera.
  70999. */
  71000. attached: CameraInputsMap<TCamera>;
  71001. /**
  71002. * Defines the dom element the camera is collecting inputs from.
  71003. * This is null if the controls have not been attached.
  71004. */
  71005. attachedElement: Nullable<HTMLElement>;
  71006. /**
  71007. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71008. */
  71009. noPreventDefault: boolean;
  71010. /**
  71011. * Defined the camera the input manager belongs to.
  71012. */
  71013. camera: TCamera;
  71014. /**
  71015. * Update the current camera state depending on the inputs that have been used this frame.
  71016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71017. */
  71018. checkInputs: () => void;
  71019. /**
  71020. * Instantiate a new Camera Input Manager.
  71021. * @param camera Defines the camera the input manager blongs to
  71022. */
  71023. constructor(camera: TCamera);
  71024. /**
  71025. * Add an input method to a camera
  71026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71027. * @param input camera input method
  71028. */
  71029. add(input: ICameraInput<TCamera>): void;
  71030. /**
  71031. * Remove a specific input method from a camera
  71032. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71033. * @param inputToRemove camera input method
  71034. */
  71035. remove(inputToRemove: ICameraInput<TCamera>): void;
  71036. /**
  71037. * Remove a specific input type from a camera
  71038. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71039. * @param inputType the type of the input to remove
  71040. */
  71041. removeByType(inputType: string): void;
  71042. private _addCheckInputs;
  71043. /**
  71044. * Attach the input controls to the currently attached dom element to listen the events from.
  71045. * @param input Defines the input to attach
  71046. */
  71047. attachInput(input: ICameraInput<TCamera>): void;
  71048. /**
  71049. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71050. * @param element Defines the dom element to collect the events from
  71051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71052. */
  71053. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71054. /**
  71055. * Detach the current manager inputs controls from a specific dom element.
  71056. * @param element Defines the dom element to collect the events from
  71057. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71058. */
  71059. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71060. /**
  71061. * Rebuild the dynamic inputCheck function from the current list of
  71062. * defined inputs in the manager.
  71063. */
  71064. rebuildInputCheck(): void;
  71065. /**
  71066. * Remove all attached input methods from a camera
  71067. */
  71068. clear(): void;
  71069. /**
  71070. * Serialize the current input manager attached to a camera.
  71071. * This ensures than once parsed,
  71072. * the input associated to the camera will be identical to the current ones
  71073. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71074. */
  71075. serialize(serializedCamera: any): void;
  71076. /**
  71077. * Parses an input manager serialized JSON to restore the previous list of inputs
  71078. * and states associated to a camera.
  71079. * @param parsedCamera Defines the JSON to parse
  71080. */
  71081. parse(parsedCamera: any): void;
  71082. }
  71083. }
  71084. declare module BABYLON {
  71085. /**
  71086. * @hidden
  71087. */
  71088. export class IntersectionInfo {
  71089. bu: Nullable<number>;
  71090. bv: Nullable<number>;
  71091. distance: number;
  71092. faceId: number;
  71093. subMeshId: number;
  71094. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  71095. }
  71096. }
  71097. declare module BABYLON {
  71098. /**
  71099. * Represens a plane by the equation ax + by + cz + d = 0
  71100. */
  71101. export class Plane {
  71102. private static _TmpMatrix;
  71103. /**
  71104. * Normal of the plane (a,b,c)
  71105. */
  71106. normal: Vector3;
  71107. /**
  71108. * d component of the plane
  71109. */
  71110. d: number;
  71111. /**
  71112. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  71113. * @param a a component of the plane
  71114. * @param b b component of the plane
  71115. * @param c c component of the plane
  71116. * @param d d component of the plane
  71117. */
  71118. constructor(a: number, b: number, c: number, d: number);
  71119. /**
  71120. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  71121. */
  71122. asArray(): number[];
  71123. /**
  71124. * @returns a new plane copied from the current Plane.
  71125. */
  71126. clone(): Plane;
  71127. /**
  71128. * @returns the string "Plane".
  71129. */
  71130. getClassName(): string;
  71131. /**
  71132. * @returns the Plane hash code.
  71133. */
  71134. getHashCode(): number;
  71135. /**
  71136. * Normalize the current Plane in place.
  71137. * @returns the updated Plane.
  71138. */
  71139. normalize(): Plane;
  71140. /**
  71141. * Applies a transformation the plane and returns the result
  71142. * @param transformation the transformation matrix to be applied to the plane
  71143. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  71144. */
  71145. transform(transformation: DeepImmutable<Matrix>): Plane;
  71146. /**
  71147. * Calcualtte the dot product between the point and the plane normal
  71148. * @param point point to calculate the dot product with
  71149. * @returns the dot product (float) of the point coordinates and the plane normal.
  71150. */
  71151. dotCoordinate(point: DeepImmutable<Vector3>): number;
  71152. /**
  71153. * Updates the current Plane from the plane defined by the three given points.
  71154. * @param point1 one of the points used to contruct the plane
  71155. * @param point2 one of the points used to contruct the plane
  71156. * @param point3 one of the points used to contruct the plane
  71157. * @returns the updated Plane.
  71158. */
  71159. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71160. /**
  71161. * Checks if the plane is facing a given direction
  71162. * @param direction the direction to check if the plane is facing
  71163. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  71164. * @returns True is the vector "direction" is the same side than the plane normal.
  71165. */
  71166. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  71167. /**
  71168. * Calculates the distance to a point
  71169. * @param point point to calculate distance to
  71170. * @returns the signed distance (float) from the given point to the Plane.
  71171. */
  71172. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  71173. /**
  71174. * Creates a plane from an array
  71175. * @param array the array to create a plane from
  71176. * @returns a new Plane from the given array.
  71177. */
  71178. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  71179. /**
  71180. * Creates a plane from three points
  71181. * @param point1 point used to create the plane
  71182. * @param point2 point used to create the plane
  71183. * @param point3 point used to create the plane
  71184. * @returns a new Plane defined by the three given points.
  71185. */
  71186. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71187. /**
  71188. * Creates a plane from an origin point and a normal
  71189. * @param origin origin of the plane to be constructed
  71190. * @param normal normal of the plane to be constructed
  71191. * @returns a new Plane the normal vector to this plane at the given origin point.
  71192. * Note : the vector "normal" is updated because normalized.
  71193. */
  71194. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  71195. /**
  71196. * Calculates the distance from a plane and a point
  71197. * @param origin origin of the plane to be constructed
  71198. * @param normal normal of the plane to be constructed
  71199. * @param point point to calculate distance to
  71200. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  71201. */
  71202. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  71203. }
  71204. }
  71205. declare module BABYLON {
  71206. /**
  71207. * Class used to store bounding sphere information
  71208. */
  71209. export class BoundingSphere {
  71210. /**
  71211. * Gets the center of the bounding sphere in local space
  71212. */
  71213. readonly center: Vector3;
  71214. /**
  71215. * Radius of the bounding sphere in local space
  71216. */
  71217. radius: number;
  71218. /**
  71219. * Gets the center of the bounding sphere in world space
  71220. */
  71221. readonly centerWorld: Vector3;
  71222. /**
  71223. * Radius of the bounding sphere in world space
  71224. */
  71225. radiusWorld: number;
  71226. /**
  71227. * Gets the minimum vector in local space
  71228. */
  71229. readonly minimum: Vector3;
  71230. /**
  71231. * Gets the maximum vector in local space
  71232. */
  71233. readonly maximum: Vector3;
  71234. private _worldMatrix;
  71235. private static readonly TmpVector3;
  71236. /**
  71237. * Creates a new bounding sphere
  71238. * @param min defines the minimum vector (in local space)
  71239. * @param max defines the maximum vector (in local space)
  71240. * @param worldMatrix defines the new world matrix
  71241. */
  71242. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71243. /**
  71244. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  71245. * @param min defines the new minimum vector (in local space)
  71246. * @param max defines the new maximum vector (in local space)
  71247. * @param worldMatrix defines the new world matrix
  71248. */
  71249. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71250. /**
  71251. * Scale the current bounding sphere by applying a scale factor
  71252. * @param factor defines the scale factor to apply
  71253. * @returns the current bounding box
  71254. */
  71255. scale(factor: number): BoundingSphere;
  71256. /**
  71257. * Gets the world matrix of the bounding box
  71258. * @returns a matrix
  71259. */
  71260. getWorldMatrix(): DeepImmutable<Matrix>;
  71261. /** @hidden */
  71262. _update(worldMatrix: DeepImmutable<Matrix>): void;
  71263. /**
  71264. * Tests if the bounding sphere is intersecting the frustum planes
  71265. * @param frustumPlanes defines the frustum planes to test
  71266. * @returns true if there is an intersection
  71267. */
  71268. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71269. /**
  71270. * Tests if the bounding sphere center is in between the frustum planes.
  71271. * Used for optimistic fast inclusion.
  71272. * @param frustumPlanes defines the frustum planes to test
  71273. * @returns true if the sphere center is in between the frustum planes
  71274. */
  71275. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71276. /**
  71277. * Tests if a point is inside the bounding sphere
  71278. * @param point defines the point to test
  71279. * @returns true if the point is inside the bounding sphere
  71280. */
  71281. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71282. /**
  71283. * Checks if two sphere intersct
  71284. * @param sphere0 sphere 0
  71285. * @param sphere1 sphere 1
  71286. * @returns true if the speres intersect
  71287. */
  71288. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  71289. }
  71290. }
  71291. declare module BABYLON {
  71292. /**
  71293. * Class used to store bounding box information
  71294. */
  71295. export class BoundingBox implements ICullable {
  71296. /**
  71297. * Gets the 8 vectors representing the bounding box in local space
  71298. */
  71299. readonly vectors: Vector3[];
  71300. /**
  71301. * Gets the center of the bounding box in local space
  71302. */
  71303. readonly center: Vector3;
  71304. /**
  71305. * Gets the center of the bounding box in world space
  71306. */
  71307. readonly centerWorld: Vector3;
  71308. /**
  71309. * Gets the extend size in local space
  71310. */
  71311. readonly extendSize: Vector3;
  71312. /**
  71313. * Gets the extend size in world space
  71314. */
  71315. readonly extendSizeWorld: Vector3;
  71316. /**
  71317. * Gets the OBB (object bounding box) directions
  71318. */
  71319. readonly directions: Vector3[];
  71320. /**
  71321. * Gets the 8 vectors representing the bounding box in world space
  71322. */
  71323. readonly vectorsWorld: Vector3[];
  71324. /**
  71325. * Gets the minimum vector in world space
  71326. */
  71327. readonly minimumWorld: Vector3;
  71328. /**
  71329. * Gets the maximum vector in world space
  71330. */
  71331. readonly maximumWorld: Vector3;
  71332. /**
  71333. * Gets the minimum vector in local space
  71334. */
  71335. readonly minimum: Vector3;
  71336. /**
  71337. * Gets the maximum vector in local space
  71338. */
  71339. readonly maximum: Vector3;
  71340. private _worldMatrix;
  71341. private static readonly TmpVector3;
  71342. /**
  71343. * @hidden
  71344. */
  71345. _tag: number;
  71346. /**
  71347. * Creates a new bounding box
  71348. * @param min defines the minimum vector (in local space)
  71349. * @param max defines the maximum vector (in local space)
  71350. * @param worldMatrix defines the new world matrix
  71351. */
  71352. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71353. /**
  71354. * Recreates the entire bounding box from scratch as if we call the constructor in place
  71355. * @param min defines the new minimum vector (in local space)
  71356. * @param max defines the new maximum vector (in local space)
  71357. * @param worldMatrix defines the new world matrix
  71358. */
  71359. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71360. /**
  71361. * Scale the current bounding box by applying a scale factor
  71362. * @param factor defines the scale factor to apply
  71363. * @returns the current bounding box
  71364. */
  71365. scale(factor: number): BoundingBox;
  71366. /**
  71367. * Gets the world matrix of the bounding box
  71368. * @returns a matrix
  71369. */
  71370. getWorldMatrix(): DeepImmutable<Matrix>;
  71371. /** @hidden */
  71372. _update(world: DeepImmutable<Matrix>): void;
  71373. /**
  71374. * Tests if the bounding box is intersecting the frustum planes
  71375. * @param frustumPlanes defines the frustum planes to test
  71376. * @returns true if there is an intersection
  71377. */
  71378. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71379. /**
  71380. * Tests if the bounding box is entirely inside the frustum planes
  71381. * @param frustumPlanes defines the frustum planes to test
  71382. * @returns true if there is an inclusion
  71383. */
  71384. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71385. /**
  71386. * Tests if a point is inside the bounding box
  71387. * @param point defines the point to test
  71388. * @returns true if the point is inside the bounding box
  71389. */
  71390. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71391. /**
  71392. * Tests if the bounding box intersects with a bounding sphere
  71393. * @param sphere defines the sphere to test
  71394. * @returns true if there is an intersection
  71395. */
  71396. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  71397. /**
  71398. * Tests if the bounding box intersects with a box defined by a min and max vectors
  71399. * @param min defines the min vector to use
  71400. * @param max defines the max vector to use
  71401. * @returns true if there is an intersection
  71402. */
  71403. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  71404. /**
  71405. * Tests if two bounding boxes are intersections
  71406. * @param box0 defines the first box to test
  71407. * @param box1 defines the second box to test
  71408. * @returns true if there is an intersection
  71409. */
  71410. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  71411. /**
  71412. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  71413. * @param minPoint defines the minimum vector of the bounding box
  71414. * @param maxPoint defines the maximum vector of the bounding box
  71415. * @param sphereCenter defines the sphere center
  71416. * @param sphereRadius defines the sphere radius
  71417. * @returns true if there is an intersection
  71418. */
  71419. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  71420. /**
  71421. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  71422. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71423. * @param frustumPlanes defines the frustum planes to test
  71424. * @return true if there is an inclusion
  71425. */
  71426. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71427. /**
  71428. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  71429. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71430. * @param frustumPlanes defines the frustum planes to test
  71431. * @return true if there is an intersection
  71432. */
  71433. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71434. }
  71435. }
  71436. declare module BABYLON {
  71437. /** @hidden */
  71438. export class Collider {
  71439. /** Define if a collision was found */
  71440. collisionFound: boolean;
  71441. /**
  71442. * Define last intersection point in local space
  71443. */
  71444. intersectionPoint: Vector3;
  71445. /**
  71446. * Define last collided mesh
  71447. */
  71448. collidedMesh: Nullable<AbstractMesh>;
  71449. private _collisionPoint;
  71450. private _planeIntersectionPoint;
  71451. private _tempVector;
  71452. private _tempVector2;
  71453. private _tempVector3;
  71454. private _tempVector4;
  71455. private _edge;
  71456. private _baseToVertex;
  71457. private _destinationPoint;
  71458. private _slidePlaneNormal;
  71459. private _displacementVector;
  71460. /** @hidden */
  71461. _radius: Vector3;
  71462. /** @hidden */
  71463. _retry: number;
  71464. private _velocity;
  71465. private _basePoint;
  71466. private _epsilon;
  71467. /** @hidden */
  71468. _velocityWorldLength: number;
  71469. /** @hidden */
  71470. _basePointWorld: Vector3;
  71471. private _velocityWorld;
  71472. private _normalizedVelocity;
  71473. /** @hidden */
  71474. _initialVelocity: Vector3;
  71475. /** @hidden */
  71476. _initialPosition: Vector3;
  71477. private _nearestDistance;
  71478. private _collisionMask;
  71479. collisionMask: number;
  71480. /**
  71481. * Gets the plane normal used to compute the sliding response (in local space)
  71482. */
  71483. readonly slidePlaneNormal: Vector3;
  71484. /** @hidden */
  71485. _initialize(source: Vector3, dir: Vector3, e: number): void;
  71486. /** @hidden */
  71487. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  71488. /** @hidden */
  71489. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  71490. /** @hidden */
  71491. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71492. /** @hidden */
  71493. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71494. /** @hidden */
  71495. _getResponse(pos: Vector3, vel: Vector3): void;
  71496. }
  71497. }
  71498. declare module BABYLON {
  71499. /**
  71500. * Interface for cullable objects
  71501. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  71502. */
  71503. export interface ICullable {
  71504. /**
  71505. * Checks if the object or part of the object is in the frustum
  71506. * @param frustumPlanes Camera near/planes
  71507. * @returns true if the object is in frustum otherwise false
  71508. */
  71509. isInFrustum(frustumPlanes: Plane[]): boolean;
  71510. /**
  71511. * Checks if a cullable object (mesh...) is in the camera frustum
  71512. * Unlike isInFrustum this cheks the full bounding box
  71513. * @param frustumPlanes Camera near/planes
  71514. * @returns true if the object is in frustum otherwise false
  71515. */
  71516. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  71517. }
  71518. /**
  71519. * Info for a bounding data of a mesh
  71520. */
  71521. export class BoundingInfo implements ICullable {
  71522. /**
  71523. * Bounding box for the mesh
  71524. */
  71525. readonly boundingBox: BoundingBox;
  71526. /**
  71527. * Bounding sphere for the mesh
  71528. */
  71529. readonly boundingSphere: BoundingSphere;
  71530. private _isLocked;
  71531. private static readonly TmpVector3;
  71532. /**
  71533. * Constructs bounding info
  71534. * @param minimum min vector of the bounding box/sphere
  71535. * @param maximum max vector of the bounding box/sphere
  71536. * @param worldMatrix defines the new world matrix
  71537. */
  71538. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71539. /**
  71540. * Recreates the entire bounding info from scratch as if we call the constructor in place
  71541. * @param min defines the new minimum vector (in local space)
  71542. * @param max defines the new maximum vector (in local space)
  71543. * @param worldMatrix defines the new world matrix
  71544. */
  71545. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71546. /**
  71547. * min vector of the bounding box/sphere
  71548. */
  71549. readonly minimum: Vector3;
  71550. /**
  71551. * max vector of the bounding box/sphere
  71552. */
  71553. readonly maximum: Vector3;
  71554. /**
  71555. * If the info is locked and won't be updated to avoid perf overhead
  71556. */
  71557. isLocked: boolean;
  71558. /**
  71559. * Updates the bounding sphere and box
  71560. * @param world world matrix to be used to update
  71561. */
  71562. update(world: DeepImmutable<Matrix>): void;
  71563. /**
  71564. * Recreate the bounding info to be centered around a specific point given a specific extend.
  71565. * @param center New center of the bounding info
  71566. * @param extend New extend of the bounding info
  71567. * @returns the current bounding info
  71568. */
  71569. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  71570. /**
  71571. * Scale the current bounding info by applying a scale factor
  71572. * @param factor defines the scale factor to apply
  71573. * @returns the current bounding info
  71574. */
  71575. scale(factor: number): BoundingInfo;
  71576. /**
  71577. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  71578. * @param frustumPlanes defines the frustum to test
  71579. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  71580. * @returns true if the bounding info is in the frustum planes
  71581. */
  71582. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  71583. /**
  71584. * Gets the world distance between the min and max points of the bounding box
  71585. */
  71586. readonly diagonalLength: number;
  71587. /**
  71588. * Checks if a cullable object (mesh...) is in the camera frustum
  71589. * Unlike isInFrustum this cheks the full bounding box
  71590. * @param frustumPlanes Camera near/planes
  71591. * @returns true if the object is in frustum otherwise false
  71592. */
  71593. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71594. /** @hidden */
  71595. _checkCollision(collider: Collider): boolean;
  71596. /**
  71597. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  71598. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71599. * @param point the point to check intersection with
  71600. * @returns if the point intersects
  71601. */
  71602. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71603. /**
  71604. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  71605. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71606. * @param boundingInfo the bounding info to check intersection with
  71607. * @param precise if the intersection should be done using OBB
  71608. * @returns if the bounding info intersects
  71609. */
  71610. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  71611. }
  71612. }
  71613. declare module BABYLON {
  71614. /**
  71615. * Extracts minimum and maximum values from a list of indexed positions
  71616. * @param positions defines the positions to use
  71617. * @param indices defines the indices to the positions
  71618. * @param indexStart defines the start index
  71619. * @param indexCount defines the end index
  71620. * @param bias defines bias value to add to the result
  71621. * @return minimum and maximum values
  71622. */
  71623. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  71624. minimum: Vector3;
  71625. maximum: Vector3;
  71626. };
  71627. /**
  71628. * Extracts minimum and maximum values from a list of positions
  71629. * @param positions defines the positions to use
  71630. * @param start defines the start index in the positions array
  71631. * @param count defines the number of positions to handle
  71632. * @param bias defines bias value to add to the result
  71633. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71634. * @return minimum and maximum values
  71635. */
  71636. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71637. minimum: Vector3;
  71638. maximum: Vector3;
  71639. };
  71640. }
  71641. declare module BABYLON {
  71642. /**
  71643. * Enum that determines the text-wrapping mode to use.
  71644. */
  71645. export enum InspectableType {
  71646. /**
  71647. * Checkbox for booleans
  71648. */
  71649. Checkbox = 0,
  71650. /**
  71651. * Sliders for numbers
  71652. */
  71653. Slider = 1,
  71654. /**
  71655. * Vector3
  71656. */
  71657. Vector3 = 2,
  71658. /**
  71659. * Quaternions
  71660. */
  71661. Quaternion = 3,
  71662. /**
  71663. * Color3
  71664. */
  71665. Color3 = 4,
  71666. /**
  71667. * String
  71668. */
  71669. String = 5
  71670. }
  71671. /**
  71672. * Interface used to define custom inspectable properties.
  71673. * This interface is used by the inspector to display custom property grids
  71674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71675. */
  71676. export interface IInspectable {
  71677. /**
  71678. * Gets the label to display
  71679. */
  71680. label: string;
  71681. /**
  71682. * Gets the name of the property to edit
  71683. */
  71684. propertyName: string;
  71685. /**
  71686. * Gets the type of the editor to use
  71687. */
  71688. type: InspectableType;
  71689. /**
  71690. * Gets the minimum value of the property when using in "slider" mode
  71691. */
  71692. min?: number;
  71693. /**
  71694. * Gets the maximum value of the property when using in "slider" mode
  71695. */
  71696. max?: number;
  71697. /**
  71698. * Gets the setp to use when using in "slider" mode
  71699. */
  71700. step?: number;
  71701. }
  71702. }
  71703. declare module BABYLON {
  71704. /**
  71705. * Class used to provide helper for timing
  71706. */
  71707. export class TimingTools {
  71708. /**
  71709. * Polyfill for setImmediate
  71710. * @param action defines the action to execute after the current execution block
  71711. */
  71712. static SetImmediate(action: () => void): void;
  71713. }
  71714. }
  71715. declare module BABYLON {
  71716. /**
  71717. * Class used to enable instatition of objects by class name
  71718. */
  71719. export class InstantiationTools {
  71720. /**
  71721. * Use this object to register external classes like custom textures or material
  71722. * to allow the laoders to instantiate them
  71723. */
  71724. static RegisteredExternalClasses: {
  71725. [key: string]: Object;
  71726. };
  71727. /**
  71728. * Tries to instantiate a new object from a given class name
  71729. * @param className defines the class name to instantiate
  71730. * @returns the new object or null if the system was not able to do the instantiation
  71731. */
  71732. static Instantiate(className: string): any;
  71733. }
  71734. }
  71735. declare module BABYLON {
  71736. /**
  71737. * This represents the required contract to create a new type of texture loader.
  71738. */
  71739. export interface IInternalTextureLoader {
  71740. /**
  71741. * Defines wether the loader supports cascade loading the different faces.
  71742. */
  71743. supportCascades: boolean;
  71744. /**
  71745. * This returns if the loader support the current file information.
  71746. * @param extension defines the file extension of the file being loaded
  71747. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71748. * @param fallback defines the fallback internal texture if any
  71749. * @param isBase64 defines whether the texture is encoded as a base64
  71750. * @param isBuffer defines whether the texture data are stored as a buffer
  71751. * @returns true if the loader can load the specified file
  71752. */
  71753. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71754. /**
  71755. * Transform the url before loading if required.
  71756. * @param rootUrl the url of the texture
  71757. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71758. * @returns the transformed texture
  71759. */
  71760. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71761. /**
  71762. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71763. * @param rootUrl the url of the texture
  71764. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71765. * @returns the fallback texture
  71766. */
  71767. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71768. /**
  71769. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71770. * @param data contains the texture data
  71771. * @param texture defines the BabylonJS internal texture
  71772. * @param createPolynomials will be true if polynomials have been requested
  71773. * @param onLoad defines the callback to trigger once the texture is ready
  71774. * @param onError defines the callback to trigger in case of error
  71775. */
  71776. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71777. /**
  71778. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71779. * @param data contains the texture data
  71780. * @param texture defines the BabylonJS internal texture
  71781. * @param callback defines the method to call once ready to upload
  71782. */
  71783. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71784. }
  71785. }
  71786. declare module BABYLON {
  71787. interface Engine {
  71788. /**
  71789. * Creates a depth stencil cube texture.
  71790. * This is only available in WebGL 2.
  71791. * @param size The size of face edge in the cube texture.
  71792. * @param options The options defining the cube texture.
  71793. * @returns The cube texture
  71794. */
  71795. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71796. /**
  71797. * Creates a cube texture
  71798. * @param rootUrl defines the url where the files to load is located
  71799. * @param scene defines the current scene
  71800. * @param files defines the list of files to load (1 per face)
  71801. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71802. * @param onLoad defines an optional callback raised when the texture is loaded
  71803. * @param onError defines an optional callback raised if there is an issue to load the texture
  71804. * @param format defines the format of the data
  71805. * @param forcedExtension defines the extension to use to pick the right loader
  71806. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71807. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71808. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71809. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71810. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71811. * @returns the cube texture as an InternalTexture
  71812. */
  71813. 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;
  71814. /**
  71815. * Creates a cube texture
  71816. * @param rootUrl defines the url where the files to load is located
  71817. * @param scene defines the current scene
  71818. * @param files defines the list of files to load (1 per face)
  71819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71820. * @param onLoad defines an optional callback raised when the texture is loaded
  71821. * @param onError defines an optional callback raised if there is an issue to load the texture
  71822. * @param format defines the format of the data
  71823. * @param forcedExtension defines the extension to use to pick the right loader
  71824. * @returns the cube texture as an InternalTexture
  71825. */
  71826. 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;
  71827. /**
  71828. * Creates a cube texture
  71829. * @param rootUrl defines the url where the files to load is located
  71830. * @param scene defines the current scene
  71831. * @param files defines the list of files to load (1 per face)
  71832. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71833. * @param onLoad defines an optional callback raised when the texture is loaded
  71834. * @param onError defines an optional callback raised if there is an issue to load the texture
  71835. * @param format defines the format of the data
  71836. * @param forcedExtension defines the extension to use to pick the right loader
  71837. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71838. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71839. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71840. * @returns the cube texture as an InternalTexture
  71841. */
  71842. 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;
  71843. /** @hidden */
  71844. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71845. /** @hidden */
  71846. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71847. /** @hidden */
  71848. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71849. /** @hidden */
  71850. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71851. }
  71852. }
  71853. declare module BABYLON {
  71854. /**
  71855. * Class for creating a cube texture
  71856. */
  71857. export class CubeTexture extends BaseTexture {
  71858. private _delayedOnLoad;
  71859. /**
  71860. * The url of the texture
  71861. */
  71862. url: string;
  71863. /**
  71864. * Gets or sets the center of the bounding box associated with the cube texture.
  71865. * It must define where the camera used to render the texture was set
  71866. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71867. */
  71868. boundingBoxPosition: Vector3;
  71869. private _boundingBoxSize;
  71870. /**
  71871. * Gets or sets the size of the bounding box associated with the cube texture
  71872. * When defined, the cubemap will switch to local mode
  71873. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71874. * @example https://www.babylonjs-playground.com/#RNASML
  71875. */
  71876. /**
  71877. * Returns the bounding box size
  71878. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71879. */
  71880. boundingBoxSize: Vector3;
  71881. protected _rotationY: number;
  71882. /**
  71883. * Sets texture matrix rotation angle around Y axis in radians.
  71884. */
  71885. /**
  71886. * Gets texture matrix rotation angle around Y axis radians.
  71887. */
  71888. rotationY: number;
  71889. /**
  71890. * Are mip maps generated for this texture or not.
  71891. */
  71892. readonly noMipmap: boolean;
  71893. private _noMipmap;
  71894. private _files;
  71895. private _extensions;
  71896. private _textureMatrix;
  71897. private _format;
  71898. private _createPolynomials;
  71899. /** @hidden */
  71900. _prefiltered: boolean;
  71901. /**
  71902. * Creates a cube texture from an array of image urls
  71903. * @param files defines an array of image urls
  71904. * @param scene defines the hosting scene
  71905. * @param noMipmap specifies if mip maps are not used
  71906. * @returns a cube texture
  71907. */
  71908. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71909. /**
  71910. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71911. * @param url defines the url of the prefiltered texture
  71912. * @param scene defines the scene the texture is attached to
  71913. * @param forcedExtension defines the extension of the file if different from the url
  71914. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71915. * @return the prefiltered texture
  71916. */
  71917. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71918. /**
  71919. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71920. * as prefiltered data.
  71921. * @param rootUrl defines the url of the texture or the root name of the six images
  71922. * @param scene defines the scene the texture is attached to
  71923. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71924. * @param noMipmap defines if mipmaps should be created or not
  71925. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71926. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71927. * @param onError defines a callback triggered in case of error during load
  71928. * @param format defines the internal format to use for the texture once loaded
  71929. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71930. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71931. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71932. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71933. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71934. * @return the cube texture
  71935. */
  71936. 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);
  71937. /**
  71938. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71939. */
  71940. readonly isPrefiltered: boolean;
  71941. /**
  71942. * Get the current class name of the texture useful for serialization or dynamic coding.
  71943. * @returns "CubeTexture"
  71944. */
  71945. getClassName(): string;
  71946. /**
  71947. * Update the url (and optional buffer) of this texture if url was null during construction.
  71948. * @param url the url of the texture
  71949. * @param forcedExtension defines the extension to use
  71950. * @param onLoad callback called when the texture is loaded (defaults to null)
  71951. */
  71952. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71953. /**
  71954. * Delays loading of the cube texture
  71955. * @param forcedExtension defines the extension to use
  71956. */
  71957. delayLoad(forcedExtension?: string): void;
  71958. /**
  71959. * Returns the reflection texture matrix
  71960. * @returns the reflection texture matrix
  71961. */
  71962. getReflectionTextureMatrix(): Matrix;
  71963. /**
  71964. * Sets the reflection texture matrix
  71965. * @param value Reflection texture matrix
  71966. */
  71967. setReflectionTextureMatrix(value: Matrix): void;
  71968. /**
  71969. * Parses text to create a cube texture
  71970. * @param parsedTexture define the serialized text to read from
  71971. * @param scene defines the hosting scene
  71972. * @param rootUrl defines the root url of the cube texture
  71973. * @returns a cube texture
  71974. */
  71975. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71976. /**
  71977. * Makes a clone, or deep copy, of the cube texture
  71978. * @returns a new cube texture
  71979. */
  71980. clone(): CubeTexture;
  71981. }
  71982. }
  71983. declare module BABYLON {
  71984. /**
  71985. * Manages the defines for the Material
  71986. */
  71987. export class MaterialDefines {
  71988. /** @hidden */
  71989. protected _keys: string[];
  71990. private _isDirty;
  71991. /** @hidden */
  71992. _renderId: number;
  71993. /** @hidden */
  71994. _areLightsDirty: boolean;
  71995. /** @hidden */
  71996. _areAttributesDirty: boolean;
  71997. /** @hidden */
  71998. _areTexturesDirty: boolean;
  71999. /** @hidden */
  72000. _areFresnelDirty: boolean;
  72001. /** @hidden */
  72002. _areMiscDirty: boolean;
  72003. /** @hidden */
  72004. _areImageProcessingDirty: boolean;
  72005. /** @hidden */
  72006. _normals: boolean;
  72007. /** @hidden */
  72008. _uvs: boolean;
  72009. /** @hidden */
  72010. _needNormals: boolean;
  72011. /** @hidden */
  72012. _needUVs: boolean;
  72013. [id: string]: any;
  72014. /**
  72015. * Specifies if the material needs to be re-calculated
  72016. */
  72017. readonly isDirty: boolean;
  72018. /**
  72019. * Marks the material to indicate that it has been re-calculated
  72020. */
  72021. markAsProcessed(): void;
  72022. /**
  72023. * Marks the material to indicate that it needs to be re-calculated
  72024. */
  72025. markAsUnprocessed(): void;
  72026. /**
  72027. * Marks the material to indicate all of its defines need to be re-calculated
  72028. */
  72029. markAllAsDirty(): void;
  72030. /**
  72031. * Marks the material to indicate that image processing needs to be re-calculated
  72032. */
  72033. markAsImageProcessingDirty(): void;
  72034. /**
  72035. * Marks the material to indicate the lights need to be re-calculated
  72036. */
  72037. markAsLightDirty(): void;
  72038. /**
  72039. * Marks the attribute state as changed
  72040. */
  72041. markAsAttributesDirty(): void;
  72042. /**
  72043. * Marks the texture state as changed
  72044. */
  72045. markAsTexturesDirty(): void;
  72046. /**
  72047. * Marks the fresnel state as changed
  72048. */
  72049. markAsFresnelDirty(): void;
  72050. /**
  72051. * Marks the misc state as changed
  72052. */
  72053. markAsMiscDirty(): void;
  72054. /**
  72055. * Rebuilds the material defines
  72056. */
  72057. rebuild(): void;
  72058. /**
  72059. * Specifies if two material defines are equal
  72060. * @param other - A material define instance to compare to
  72061. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  72062. */
  72063. isEqual(other: MaterialDefines): boolean;
  72064. /**
  72065. * Clones this instance's defines to another instance
  72066. * @param other - material defines to clone values to
  72067. */
  72068. cloneTo(other: MaterialDefines): void;
  72069. /**
  72070. * Resets the material define values
  72071. */
  72072. reset(): void;
  72073. /**
  72074. * Converts the material define values to a string
  72075. * @returns - String of material define information
  72076. */
  72077. toString(): string;
  72078. }
  72079. }
  72080. declare module BABYLON {
  72081. /**
  72082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  72083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  72084. * 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;
  72085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  72086. */
  72087. export class ColorCurves {
  72088. private _dirty;
  72089. private _tempColor;
  72090. private _globalCurve;
  72091. private _highlightsCurve;
  72092. private _midtonesCurve;
  72093. private _shadowsCurve;
  72094. private _positiveCurve;
  72095. private _negativeCurve;
  72096. private _globalHue;
  72097. private _globalDensity;
  72098. private _globalSaturation;
  72099. private _globalExposure;
  72100. /**
  72101. * Gets the global Hue value.
  72102. * 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).
  72103. */
  72104. /**
  72105. * Sets the global Hue value.
  72106. * 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).
  72107. */
  72108. globalHue: number;
  72109. /**
  72110. * Gets the global Density value.
  72111. * 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.
  72112. * Values less than zero provide a filter of opposite hue.
  72113. */
  72114. /**
  72115. * Sets the global Density value.
  72116. * 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.
  72117. * Values less than zero provide a filter of opposite hue.
  72118. */
  72119. globalDensity: number;
  72120. /**
  72121. * Gets the global Saturation value.
  72122. * 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.
  72123. */
  72124. /**
  72125. * Sets the global Saturation value.
  72126. * 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.
  72127. */
  72128. globalSaturation: number;
  72129. /**
  72130. * Gets the global Exposure value.
  72131. * 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.
  72132. */
  72133. /**
  72134. * Sets the global Exposure value.
  72135. * 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.
  72136. */
  72137. globalExposure: number;
  72138. private _highlightsHue;
  72139. private _highlightsDensity;
  72140. private _highlightsSaturation;
  72141. private _highlightsExposure;
  72142. /**
  72143. * Gets the highlights Hue value.
  72144. * 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).
  72145. */
  72146. /**
  72147. * Sets the highlights Hue value.
  72148. * 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).
  72149. */
  72150. highlightsHue: number;
  72151. /**
  72152. * Gets the highlights Density value.
  72153. * 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.
  72154. * Values less than zero provide a filter of opposite hue.
  72155. */
  72156. /**
  72157. * Sets the highlights Density value.
  72158. * 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.
  72159. * Values less than zero provide a filter of opposite hue.
  72160. */
  72161. highlightsDensity: number;
  72162. /**
  72163. * Gets the highlights Saturation value.
  72164. * 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.
  72165. */
  72166. /**
  72167. * Sets the highlights Saturation value.
  72168. * 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.
  72169. */
  72170. highlightsSaturation: number;
  72171. /**
  72172. * Gets the highlights Exposure value.
  72173. * 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.
  72174. */
  72175. /**
  72176. * Sets the highlights Exposure value.
  72177. * 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.
  72178. */
  72179. highlightsExposure: number;
  72180. private _midtonesHue;
  72181. private _midtonesDensity;
  72182. private _midtonesSaturation;
  72183. private _midtonesExposure;
  72184. /**
  72185. * Gets the midtones Hue value.
  72186. * 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).
  72187. */
  72188. /**
  72189. * Sets the midtones Hue value.
  72190. * 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).
  72191. */
  72192. midtonesHue: number;
  72193. /**
  72194. * Gets the midtones Density value.
  72195. * 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.
  72196. * Values less than zero provide a filter of opposite hue.
  72197. */
  72198. /**
  72199. * Sets the midtones Density value.
  72200. * 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.
  72201. * Values less than zero provide a filter of opposite hue.
  72202. */
  72203. midtonesDensity: number;
  72204. /**
  72205. * Gets the midtones Saturation value.
  72206. * 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.
  72207. */
  72208. /**
  72209. * Sets the midtones Saturation value.
  72210. * 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.
  72211. */
  72212. midtonesSaturation: number;
  72213. /**
  72214. * Gets the midtones Exposure value.
  72215. * 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.
  72216. */
  72217. /**
  72218. * Sets the midtones Exposure value.
  72219. * 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.
  72220. */
  72221. midtonesExposure: number;
  72222. private _shadowsHue;
  72223. private _shadowsDensity;
  72224. private _shadowsSaturation;
  72225. private _shadowsExposure;
  72226. /**
  72227. * Gets the shadows Hue value.
  72228. * 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).
  72229. */
  72230. /**
  72231. * Sets the shadows Hue value.
  72232. * 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).
  72233. */
  72234. shadowsHue: number;
  72235. /**
  72236. * Gets the shadows Density value.
  72237. * 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.
  72238. * Values less than zero provide a filter of opposite hue.
  72239. */
  72240. /**
  72241. * Sets the shadows Density value.
  72242. * 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.
  72243. * Values less than zero provide a filter of opposite hue.
  72244. */
  72245. shadowsDensity: number;
  72246. /**
  72247. * Gets the shadows Saturation value.
  72248. * 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.
  72249. */
  72250. /**
  72251. * Sets the shadows Saturation value.
  72252. * 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.
  72253. */
  72254. shadowsSaturation: number;
  72255. /**
  72256. * Gets the shadows Exposure value.
  72257. * 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.
  72258. */
  72259. /**
  72260. * Sets the shadows Exposure value.
  72261. * 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.
  72262. */
  72263. shadowsExposure: number;
  72264. /**
  72265. * Returns the class name
  72266. * @returns The class name
  72267. */
  72268. getClassName(): string;
  72269. /**
  72270. * Binds the color curves to the shader.
  72271. * @param colorCurves The color curve to bind
  72272. * @param effect The effect to bind to
  72273. * @param positiveUniform The positive uniform shader parameter
  72274. * @param neutralUniform The neutral uniform shader parameter
  72275. * @param negativeUniform The negative uniform shader parameter
  72276. */
  72277. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  72278. /**
  72279. * Prepare the list of uniforms associated with the ColorCurves effects.
  72280. * @param uniformsList The list of uniforms used in the effect
  72281. */
  72282. static PrepareUniforms(uniformsList: string[]): void;
  72283. /**
  72284. * Returns color grading data based on a hue, density, saturation and exposure value.
  72285. * @param filterHue The hue of the color filter.
  72286. * @param filterDensity The density of the color filter.
  72287. * @param saturation The saturation.
  72288. * @param exposure The exposure.
  72289. * @param result The result data container.
  72290. */
  72291. private getColorGradingDataToRef;
  72292. /**
  72293. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72294. * @param value The input slider value in range [-100,100].
  72295. * @returns Adjusted value.
  72296. */
  72297. private static applyColorGradingSliderNonlinear;
  72298. /**
  72299. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72300. * @param hue The hue (H) input.
  72301. * @param saturation The saturation (S) input.
  72302. * @param brightness The brightness (B) input.
  72303. * @result An RGBA color represented as Vector4.
  72304. */
  72305. private static fromHSBToRef;
  72306. /**
  72307. * Returns a value clamped between min and max
  72308. * @param value The value to clamp
  72309. * @param min The minimum of value
  72310. * @param max The maximum of value
  72311. * @returns The clamped value.
  72312. */
  72313. private static clamp;
  72314. /**
  72315. * Clones the current color curve instance.
  72316. * @return The cloned curves
  72317. */
  72318. clone(): ColorCurves;
  72319. /**
  72320. * Serializes the current color curve instance to a json representation.
  72321. * @return a JSON representation
  72322. */
  72323. serialize(): any;
  72324. /**
  72325. * Parses the color curve from a json representation.
  72326. * @param source the JSON source to parse
  72327. * @return The parsed curves
  72328. */
  72329. static Parse(source: any): ColorCurves;
  72330. }
  72331. }
  72332. declare module BABYLON {
  72333. /**
  72334. * Interface to follow in your material defines to integrate easily the
  72335. * Image proccessing functions.
  72336. * @hidden
  72337. */
  72338. export interface IImageProcessingConfigurationDefines {
  72339. IMAGEPROCESSING: boolean;
  72340. VIGNETTE: boolean;
  72341. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72342. VIGNETTEBLENDMODEOPAQUE: boolean;
  72343. TONEMAPPING: boolean;
  72344. TONEMAPPING_ACES: boolean;
  72345. CONTRAST: boolean;
  72346. EXPOSURE: boolean;
  72347. COLORCURVES: boolean;
  72348. COLORGRADING: boolean;
  72349. COLORGRADING3D: boolean;
  72350. SAMPLER3DGREENDEPTH: boolean;
  72351. SAMPLER3DBGRMAP: boolean;
  72352. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72353. }
  72354. /**
  72355. * @hidden
  72356. */
  72357. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  72358. IMAGEPROCESSING: boolean;
  72359. VIGNETTE: boolean;
  72360. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72361. VIGNETTEBLENDMODEOPAQUE: boolean;
  72362. TONEMAPPING: boolean;
  72363. TONEMAPPING_ACES: boolean;
  72364. CONTRAST: boolean;
  72365. COLORCURVES: boolean;
  72366. COLORGRADING: boolean;
  72367. COLORGRADING3D: boolean;
  72368. SAMPLER3DGREENDEPTH: boolean;
  72369. SAMPLER3DBGRMAP: boolean;
  72370. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72371. EXPOSURE: boolean;
  72372. constructor();
  72373. }
  72374. /**
  72375. * This groups together the common properties used for image processing either in direct forward pass
  72376. * or through post processing effect depending on the use of the image processing pipeline in your scene
  72377. * or not.
  72378. */
  72379. export class ImageProcessingConfiguration {
  72380. /**
  72381. * Default tone mapping applied in BabylonJS.
  72382. */
  72383. static readonly TONEMAPPING_STANDARD: number;
  72384. /**
  72385. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  72386. * to other engines rendering to increase portability.
  72387. */
  72388. static readonly TONEMAPPING_ACES: number;
  72389. /**
  72390. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  72391. */
  72392. colorCurves: Nullable<ColorCurves>;
  72393. private _colorCurvesEnabled;
  72394. /**
  72395. * Gets wether the color curves effect is enabled.
  72396. */
  72397. /**
  72398. * Sets wether the color curves effect is enabled.
  72399. */
  72400. colorCurvesEnabled: boolean;
  72401. private _colorGradingTexture;
  72402. /**
  72403. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72404. */
  72405. /**
  72406. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72407. */
  72408. colorGradingTexture: Nullable<BaseTexture>;
  72409. private _colorGradingEnabled;
  72410. /**
  72411. * Gets wether the color grading effect is enabled.
  72412. */
  72413. /**
  72414. * Sets wether the color grading effect is enabled.
  72415. */
  72416. colorGradingEnabled: boolean;
  72417. private _colorGradingWithGreenDepth;
  72418. /**
  72419. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  72420. */
  72421. /**
  72422. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  72423. */
  72424. colorGradingWithGreenDepth: boolean;
  72425. private _colorGradingBGR;
  72426. /**
  72427. * Gets wether the color grading texture contains BGR values.
  72428. */
  72429. /**
  72430. * Sets wether the color grading texture contains BGR values.
  72431. */
  72432. colorGradingBGR: boolean;
  72433. /** @hidden */
  72434. _exposure: number;
  72435. /**
  72436. * Gets the Exposure used in the effect.
  72437. */
  72438. /**
  72439. * Sets the Exposure used in the effect.
  72440. */
  72441. exposure: number;
  72442. private _toneMappingEnabled;
  72443. /**
  72444. * Gets wether the tone mapping effect is enabled.
  72445. */
  72446. /**
  72447. * Sets wether the tone mapping effect is enabled.
  72448. */
  72449. toneMappingEnabled: boolean;
  72450. private _toneMappingType;
  72451. /**
  72452. * Gets the type of tone mapping effect.
  72453. */
  72454. /**
  72455. * Sets the type of tone mapping effect used in BabylonJS.
  72456. */
  72457. toneMappingType: number;
  72458. protected _contrast: number;
  72459. /**
  72460. * Gets the contrast used in the effect.
  72461. */
  72462. /**
  72463. * Sets the contrast used in the effect.
  72464. */
  72465. contrast: number;
  72466. /**
  72467. * Vignette stretch size.
  72468. */
  72469. vignetteStretch: number;
  72470. /**
  72471. * Vignette centre X Offset.
  72472. */
  72473. vignetteCentreX: number;
  72474. /**
  72475. * Vignette centre Y Offset.
  72476. */
  72477. vignetteCentreY: number;
  72478. /**
  72479. * Vignette weight or intensity of the vignette effect.
  72480. */
  72481. vignetteWeight: number;
  72482. /**
  72483. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  72484. * if vignetteEnabled is set to true.
  72485. */
  72486. vignetteColor: Color4;
  72487. /**
  72488. * Camera field of view used by the Vignette effect.
  72489. */
  72490. vignetteCameraFov: number;
  72491. private _vignetteBlendMode;
  72492. /**
  72493. * Gets the vignette blend mode allowing different kind of effect.
  72494. */
  72495. /**
  72496. * Sets the vignette blend mode allowing different kind of effect.
  72497. */
  72498. vignetteBlendMode: number;
  72499. private _vignetteEnabled;
  72500. /**
  72501. * Gets wether the vignette effect is enabled.
  72502. */
  72503. /**
  72504. * Sets wether the vignette effect is enabled.
  72505. */
  72506. vignetteEnabled: boolean;
  72507. private _applyByPostProcess;
  72508. /**
  72509. * Gets wether the image processing is applied through a post process or not.
  72510. */
  72511. /**
  72512. * Sets wether the image processing is applied through a post process or not.
  72513. */
  72514. applyByPostProcess: boolean;
  72515. private _isEnabled;
  72516. /**
  72517. * Gets wether the image processing is enabled or not.
  72518. */
  72519. /**
  72520. * Sets wether the image processing is enabled or not.
  72521. */
  72522. isEnabled: boolean;
  72523. /**
  72524. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  72525. */
  72526. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  72527. /**
  72528. * Method called each time the image processing information changes requires to recompile the effect.
  72529. */
  72530. protected _updateParameters(): void;
  72531. /**
  72532. * Gets the current class name.
  72533. * @return "ImageProcessingConfiguration"
  72534. */
  72535. getClassName(): string;
  72536. /**
  72537. * Prepare the list of uniforms associated with the Image Processing effects.
  72538. * @param uniforms The list of uniforms used in the effect
  72539. * @param defines the list of defines currently in use
  72540. */
  72541. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  72542. /**
  72543. * Prepare the list of samplers associated with the Image Processing effects.
  72544. * @param samplersList The list of uniforms used in the effect
  72545. * @param defines the list of defines currently in use
  72546. */
  72547. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  72548. /**
  72549. * Prepare the list of defines associated to the shader.
  72550. * @param defines the list of defines to complete
  72551. * @param forPostProcess Define if we are currently in post process mode or not
  72552. */
  72553. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  72554. /**
  72555. * Returns true if all the image processing information are ready.
  72556. * @returns True if ready, otherwise, false
  72557. */
  72558. isReady(): boolean;
  72559. /**
  72560. * Binds the image processing to the shader.
  72561. * @param effect The effect to bind to
  72562. * @param aspectRatio Define the current aspect ratio of the effect
  72563. */
  72564. bind(effect: Effect, aspectRatio?: number): void;
  72565. /**
  72566. * Clones the current image processing instance.
  72567. * @return The cloned image processing
  72568. */
  72569. clone(): ImageProcessingConfiguration;
  72570. /**
  72571. * Serializes the current image processing instance to a json representation.
  72572. * @return a JSON representation
  72573. */
  72574. serialize(): any;
  72575. /**
  72576. * Parses the image processing from a json representation.
  72577. * @param source the JSON source to parse
  72578. * @return The parsed image processing
  72579. */
  72580. static Parse(source: any): ImageProcessingConfiguration;
  72581. private static _VIGNETTEMODE_MULTIPLY;
  72582. private static _VIGNETTEMODE_OPAQUE;
  72583. /**
  72584. * Used to apply the vignette as a mix with the pixel color.
  72585. */
  72586. static readonly VIGNETTEMODE_MULTIPLY: number;
  72587. /**
  72588. * Used to apply the vignette as a replacement of the pixel color.
  72589. */
  72590. static readonly VIGNETTEMODE_OPAQUE: number;
  72591. }
  72592. }
  72593. declare module BABYLON {
  72594. /** @hidden */
  72595. export var postprocessVertexShader: {
  72596. name: string;
  72597. shader: string;
  72598. };
  72599. }
  72600. declare module BABYLON {
  72601. /** Defines supported spaces */
  72602. export enum Space {
  72603. /** Local (object) space */
  72604. LOCAL = 0,
  72605. /** World space */
  72606. WORLD = 1,
  72607. /** Bone space */
  72608. BONE = 2
  72609. }
  72610. /** Defines the 3 main axes */
  72611. export class Axis {
  72612. /** X axis */
  72613. static X: Vector3;
  72614. /** Y axis */
  72615. static Y: Vector3;
  72616. /** Z axis */
  72617. static Z: Vector3;
  72618. }
  72619. }
  72620. declare module BABYLON {
  72621. /**
  72622. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  72623. * This is the base of the follow, arc rotate cameras and Free camera
  72624. * @see http://doc.babylonjs.com/features/cameras
  72625. */
  72626. export class TargetCamera extends Camera {
  72627. private static _RigCamTransformMatrix;
  72628. private static _TargetTransformMatrix;
  72629. private static _TargetFocalPoint;
  72630. /**
  72631. * Define the current direction the camera is moving to
  72632. */
  72633. cameraDirection: Vector3;
  72634. /**
  72635. * Define the current rotation the camera is rotating to
  72636. */
  72637. cameraRotation: Vector2;
  72638. /**
  72639. * When set, the up vector of the camera will be updated by the rotation of the camera
  72640. */
  72641. updateUpVectorFromRotation: boolean;
  72642. private _tmpQuaternion;
  72643. /**
  72644. * Define the current rotation of the camera
  72645. */
  72646. rotation: Vector3;
  72647. /**
  72648. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72649. */
  72650. rotationQuaternion: Quaternion;
  72651. /**
  72652. * Define the current speed of the camera
  72653. */
  72654. speed: number;
  72655. /**
  72656. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72657. * around all axis.
  72658. */
  72659. noRotationConstraint: boolean;
  72660. /**
  72661. * Define the current target of the camera as an object or a position.
  72662. */
  72663. lockedTarget: any;
  72664. /** @hidden */
  72665. _currentTarget: Vector3;
  72666. /** @hidden */
  72667. _initialFocalDistance: number;
  72668. /** @hidden */
  72669. _viewMatrix: Matrix;
  72670. /** @hidden */
  72671. _camMatrix: Matrix;
  72672. /** @hidden */
  72673. _cameraTransformMatrix: Matrix;
  72674. /** @hidden */
  72675. _cameraRotationMatrix: Matrix;
  72676. /** @hidden */
  72677. _referencePoint: Vector3;
  72678. /** @hidden */
  72679. _transformedReferencePoint: Vector3;
  72680. protected _globalCurrentTarget: Vector3;
  72681. protected _globalCurrentUpVector: Vector3;
  72682. /** @hidden */
  72683. _reset: () => void;
  72684. private _defaultUp;
  72685. /**
  72686. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72687. * This is the base of the follow, arc rotate cameras and Free camera
  72688. * @see http://doc.babylonjs.com/features/cameras
  72689. * @param name Defines the name of the camera in the scene
  72690. * @param position Defines the start position of the camera in the scene
  72691. * @param scene Defines the scene the camera belongs to
  72692. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72693. */
  72694. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72695. /**
  72696. * Gets the position in front of the camera at a given distance.
  72697. * @param distance The distance from the camera we want the position to be
  72698. * @returns the position
  72699. */
  72700. getFrontPosition(distance: number): Vector3;
  72701. /** @hidden */
  72702. _getLockedTargetPosition(): Nullable<Vector3>;
  72703. private _storedPosition;
  72704. private _storedRotation;
  72705. private _storedRotationQuaternion;
  72706. /**
  72707. * Store current camera state of the camera (fov, position, rotation, etc..)
  72708. * @returns the camera
  72709. */
  72710. storeState(): Camera;
  72711. /**
  72712. * Restored camera state. You must call storeState() first
  72713. * @returns whether it was successful or not
  72714. * @hidden
  72715. */
  72716. _restoreStateValues(): boolean;
  72717. /** @hidden */
  72718. _initCache(): void;
  72719. /** @hidden */
  72720. _updateCache(ignoreParentClass?: boolean): void;
  72721. /** @hidden */
  72722. _isSynchronizedViewMatrix(): boolean;
  72723. /** @hidden */
  72724. _computeLocalCameraSpeed(): number;
  72725. /**
  72726. * Defines the target the camera should look at.
  72727. * @param target Defines the new target as a Vector or a mesh
  72728. */
  72729. setTarget(target: Vector3): void;
  72730. /**
  72731. * Return the current target position of the camera. This value is expressed in local space.
  72732. * @returns the target position
  72733. */
  72734. getTarget(): Vector3;
  72735. /** @hidden */
  72736. _decideIfNeedsToMove(): boolean;
  72737. /** @hidden */
  72738. _updatePosition(): void;
  72739. /** @hidden */
  72740. _checkInputs(): void;
  72741. protected _updateCameraRotationMatrix(): void;
  72742. /**
  72743. * 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)
  72744. * @returns the current camera
  72745. */
  72746. private _rotateUpVectorWithCameraRotationMatrix;
  72747. private _cachedRotationZ;
  72748. private _cachedQuaternionRotationZ;
  72749. /** @hidden */
  72750. _getViewMatrix(): Matrix;
  72751. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72752. /**
  72753. * @hidden
  72754. */
  72755. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72756. /**
  72757. * @hidden
  72758. */
  72759. _updateRigCameras(): void;
  72760. private _getRigCamPositionAndTarget;
  72761. /**
  72762. * Gets the current object class name.
  72763. * @return the class name
  72764. */
  72765. getClassName(): string;
  72766. }
  72767. }
  72768. declare module BABYLON {
  72769. /**
  72770. * Gather the list of keyboard event types as constants.
  72771. */
  72772. export class KeyboardEventTypes {
  72773. /**
  72774. * The keydown event is fired when a key becomes active (pressed).
  72775. */
  72776. static readonly KEYDOWN: number;
  72777. /**
  72778. * The keyup event is fired when a key has been released.
  72779. */
  72780. static readonly KEYUP: number;
  72781. }
  72782. /**
  72783. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72784. */
  72785. export class KeyboardInfo {
  72786. /**
  72787. * Defines the type of event (KeyboardEventTypes)
  72788. */
  72789. type: number;
  72790. /**
  72791. * Defines the related dom event
  72792. */
  72793. event: KeyboardEvent;
  72794. /**
  72795. * Instantiates a new keyboard info.
  72796. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72797. * @param type Defines the type of event (KeyboardEventTypes)
  72798. * @param event Defines the related dom event
  72799. */
  72800. constructor(
  72801. /**
  72802. * Defines the type of event (KeyboardEventTypes)
  72803. */
  72804. type: number,
  72805. /**
  72806. * Defines the related dom event
  72807. */
  72808. event: KeyboardEvent);
  72809. }
  72810. /**
  72811. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72812. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72813. */
  72814. export class KeyboardInfoPre extends KeyboardInfo {
  72815. /**
  72816. * Defines the type of event (KeyboardEventTypes)
  72817. */
  72818. type: number;
  72819. /**
  72820. * Defines the related dom event
  72821. */
  72822. event: KeyboardEvent;
  72823. /**
  72824. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72825. */
  72826. skipOnPointerObservable: boolean;
  72827. /**
  72828. * Instantiates a new keyboard pre info.
  72829. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72830. * @param type Defines the type of event (KeyboardEventTypes)
  72831. * @param event Defines the related dom event
  72832. */
  72833. constructor(
  72834. /**
  72835. * Defines the type of event (KeyboardEventTypes)
  72836. */
  72837. type: number,
  72838. /**
  72839. * Defines the related dom event
  72840. */
  72841. event: KeyboardEvent);
  72842. }
  72843. }
  72844. declare module BABYLON {
  72845. /**
  72846. * Manage the keyboard inputs to control the movement of a free camera.
  72847. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72848. */
  72849. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  72850. /**
  72851. * Defines the camera the input is attached to.
  72852. */
  72853. camera: FreeCamera;
  72854. /**
  72855. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72856. */
  72857. keysUp: number[];
  72858. /**
  72859. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72860. */
  72861. keysDown: number[];
  72862. /**
  72863. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72864. */
  72865. keysLeft: number[];
  72866. /**
  72867. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72868. */
  72869. keysRight: number[];
  72870. private _keys;
  72871. private _onCanvasBlurObserver;
  72872. private _onKeyboardObserver;
  72873. private _engine;
  72874. private _scene;
  72875. /**
  72876. * Attach the input controls to a specific dom element to get the input from.
  72877. * @param element Defines the element the controls should be listened from
  72878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72879. */
  72880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72881. /**
  72882. * Detach the current controls from the specified dom element.
  72883. * @param element Defines the element to stop listening the inputs from
  72884. */
  72885. detachControl(element: Nullable<HTMLElement>): void;
  72886. /**
  72887. * Update the current camera state depending on the inputs that have been used this frame.
  72888. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72889. */
  72890. checkInputs(): void;
  72891. /**
  72892. * Gets the class name of the current intput.
  72893. * @returns the class name
  72894. */
  72895. getClassName(): string;
  72896. /** @hidden */
  72897. _onLostFocus(): void;
  72898. /**
  72899. * Get the friendly name associated with the input class.
  72900. * @returns the input friendly name
  72901. */
  72902. getSimpleName(): string;
  72903. }
  72904. }
  72905. declare module BABYLON {
  72906. /**
  72907. * Interface describing all the common properties and methods a shadow light needs to implement.
  72908. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  72909. * as well as binding the different shadow properties to the effects.
  72910. */
  72911. export interface IShadowLight extends Light {
  72912. /**
  72913. * The light id in the scene (used in scene.findLighById for instance)
  72914. */
  72915. id: string;
  72916. /**
  72917. * The position the shdow will be casted from.
  72918. */
  72919. position: Vector3;
  72920. /**
  72921. * In 2d mode (needCube being false), the direction used to cast the shadow.
  72922. */
  72923. direction: Vector3;
  72924. /**
  72925. * The transformed position. Position of the light in world space taking parenting in account.
  72926. */
  72927. transformedPosition: Vector3;
  72928. /**
  72929. * The transformed direction. Direction of the light in world space taking parenting in account.
  72930. */
  72931. transformedDirection: Vector3;
  72932. /**
  72933. * The friendly name of the light in the scene.
  72934. */
  72935. name: string;
  72936. /**
  72937. * Defines the shadow projection clipping minimum z value.
  72938. */
  72939. shadowMinZ: number;
  72940. /**
  72941. * Defines the shadow projection clipping maximum z value.
  72942. */
  72943. shadowMaxZ: number;
  72944. /**
  72945. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72946. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72947. */
  72948. computeTransformedInformation(): boolean;
  72949. /**
  72950. * Gets the scene the light belongs to.
  72951. * @returns The scene
  72952. */
  72953. getScene(): Scene;
  72954. /**
  72955. * Callback defining a custom Projection Matrix Builder.
  72956. * This can be used to override the default projection matrix computation.
  72957. */
  72958. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72959. /**
  72960. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72961. * @param matrix The materix to updated with the projection information
  72962. * @param viewMatrix The transform matrix of the light
  72963. * @param renderList The list of mesh to render in the map
  72964. * @returns The current light
  72965. */
  72966. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72967. /**
  72968. * Gets the current depth scale used in ESM.
  72969. * @returns The scale
  72970. */
  72971. getDepthScale(): number;
  72972. /**
  72973. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72974. * @returns true if a cube texture needs to be use
  72975. */
  72976. needCube(): boolean;
  72977. /**
  72978. * Detects if the projection matrix requires to be recomputed this frame.
  72979. * @returns true if it requires to be recomputed otherwise, false.
  72980. */
  72981. needProjectionMatrixCompute(): boolean;
  72982. /**
  72983. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72984. */
  72985. forceProjectionMatrixCompute(): void;
  72986. /**
  72987. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72988. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72989. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72990. */
  72991. getShadowDirection(faceIndex?: number): Vector3;
  72992. /**
  72993. * Gets the minZ used for shadow according to both the scene and the light.
  72994. * @param activeCamera The camera we are returning the min for
  72995. * @returns the depth min z
  72996. */
  72997. getDepthMinZ(activeCamera: Camera): number;
  72998. /**
  72999. * Gets the maxZ used for shadow according to both the scene and the light.
  73000. * @param activeCamera The camera we are returning the max for
  73001. * @returns the depth max z
  73002. */
  73003. getDepthMaxZ(activeCamera: Camera): number;
  73004. }
  73005. /**
  73006. * Base implementation IShadowLight
  73007. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73008. */
  73009. export abstract class ShadowLight extends Light implements IShadowLight {
  73010. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73011. protected _position: Vector3;
  73012. protected _setPosition(value: Vector3): void;
  73013. /**
  73014. * Sets the position the shadow will be casted from. Also use as the light position for both
  73015. * point and spot lights.
  73016. */
  73017. /**
  73018. * Sets the position the shadow will be casted from. Also use as the light position for both
  73019. * point and spot lights.
  73020. */
  73021. position: Vector3;
  73022. protected _direction: Vector3;
  73023. protected _setDirection(value: Vector3): void;
  73024. /**
  73025. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73026. * Also use as the light direction on spot and directional lights.
  73027. */
  73028. /**
  73029. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73030. * Also use as the light direction on spot and directional lights.
  73031. */
  73032. direction: Vector3;
  73033. private _shadowMinZ;
  73034. /**
  73035. * Gets the shadow projection clipping minimum z value.
  73036. */
  73037. /**
  73038. * Sets the shadow projection clipping minimum z value.
  73039. */
  73040. shadowMinZ: number;
  73041. private _shadowMaxZ;
  73042. /**
  73043. * Sets the shadow projection clipping maximum z value.
  73044. */
  73045. /**
  73046. * Gets the shadow projection clipping maximum z value.
  73047. */
  73048. shadowMaxZ: number;
  73049. /**
  73050. * Callback defining a custom Projection Matrix Builder.
  73051. * This can be used to override the default projection matrix computation.
  73052. */
  73053. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73054. /**
  73055. * The transformed position. Position of the light in world space taking parenting in account.
  73056. */
  73057. transformedPosition: Vector3;
  73058. /**
  73059. * The transformed direction. Direction of the light in world space taking parenting in account.
  73060. */
  73061. transformedDirection: Vector3;
  73062. private _needProjectionMatrixCompute;
  73063. /**
  73064. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73065. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73066. */
  73067. computeTransformedInformation(): boolean;
  73068. /**
  73069. * Return the depth scale used for the shadow map.
  73070. * @returns the depth scale.
  73071. */
  73072. getDepthScale(): number;
  73073. /**
  73074. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73075. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73076. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73077. */
  73078. getShadowDirection(faceIndex?: number): Vector3;
  73079. /**
  73080. * Returns the ShadowLight absolute position in the World.
  73081. * @returns the position vector in world space
  73082. */
  73083. getAbsolutePosition(): Vector3;
  73084. /**
  73085. * Sets the ShadowLight direction toward the passed target.
  73086. * @param target The point to target in local space
  73087. * @returns the updated ShadowLight direction
  73088. */
  73089. setDirectionToTarget(target: Vector3): Vector3;
  73090. /**
  73091. * Returns the light rotation in euler definition.
  73092. * @returns the x y z rotation in local space.
  73093. */
  73094. getRotation(): Vector3;
  73095. /**
  73096. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73097. * @returns true if a cube texture needs to be use
  73098. */
  73099. needCube(): boolean;
  73100. /**
  73101. * Detects if the projection matrix requires to be recomputed this frame.
  73102. * @returns true if it requires to be recomputed otherwise, false.
  73103. */
  73104. needProjectionMatrixCompute(): boolean;
  73105. /**
  73106. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73107. */
  73108. forceProjectionMatrixCompute(): void;
  73109. /** @hidden */
  73110. _initCache(): void;
  73111. /** @hidden */
  73112. _isSynchronized(): boolean;
  73113. /**
  73114. * Computes the world matrix of the node
  73115. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73116. * @returns the world matrix
  73117. */
  73118. computeWorldMatrix(force?: boolean): Matrix;
  73119. /**
  73120. * Gets the minZ used for shadow according to both the scene and the light.
  73121. * @param activeCamera The camera we are returning the min for
  73122. * @returns the depth min z
  73123. */
  73124. getDepthMinZ(activeCamera: Camera): number;
  73125. /**
  73126. * Gets the maxZ used for shadow according to both the scene and the light.
  73127. * @param activeCamera The camera we are returning the max for
  73128. * @returns the depth max z
  73129. */
  73130. getDepthMaxZ(activeCamera: Camera): number;
  73131. /**
  73132. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73133. * @param matrix The materix to updated with the projection information
  73134. * @param viewMatrix The transform matrix of the light
  73135. * @param renderList The list of mesh to render in the map
  73136. * @returns The current light
  73137. */
  73138. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73139. }
  73140. }
  73141. declare module BABYLON {
  73142. /**
  73143. * "Static Class" containing the most commonly used helper while dealing with material for
  73144. * rendering purpose.
  73145. *
  73146. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73147. *
  73148. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73149. */
  73150. export class MaterialHelper {
  73151. /**
  73152. * Bind the current view position to an effect.
  73153. * @param effect The effect to be bound
  73154. * @param scene The scene the eyes position is used from
  73155. */
  73156. static BindEyePosition(effect: Effect, scene: Scene): void;
  73157. /**
  73158. * Helps preparing the defines values about the UVs in used in the effect.
  73159. * UVs are shared as much as we can accross channels in the shaders.
  73160. * @param texture The texture we are preparing the UVs for
  73161. * @param defines The defines to update
  73162. * @param key The channel key "diffuse", "specular"... used in the shader
  73163. */
  73164. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73165. /**
  73166. * Binds a texture matrix value to its corrsponding uniform
  73167. * @param texture The texture to bind the matrix for
  73168. * @param uniformBuffer The uniform buffer receivin the data
  73169. * @param key The channel key "diffuse", "specular"... used in the shader
  73170. */
  73171. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73172. /**
  73173. * Gets the current status of the fog (should it be enabled?)
  73174. * @param mesh defines the mesh to evaluate for fog support
  73175. * @param scene defines the hosting scene
  73176. * @returns true if fog must be enabled
  73177. */
  73178. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73179. /**
  73180. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73181. * @param mesh defines the current mesh
  73182. * @param scene defines the current scene
  73183. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73184. * @param pointsCloud defines if point cloud rendering has to be turned on
  73185. * @param fogEnabled defines if fog has to be turned on
  73186. * @param alphaTest defines if alpha testing has to be turned on
  73187. * @param defines defines the current list of defines
  73188. */
  73189. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73190. /**
  73191. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73192. * @param scene defines the current scene
  73193. * @param engine defines the current engine
  73194. * @param defines specifies the list of active defines
  73195. * @param useInstances defines if instances have to be turned on
  73196. * @param useClipPlane defines if clip plane have to be turned on
  73197. */
  73198. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73199. /**
  73200. * Prepares the defines for bones
  73201. * @param mesh The mesh containing the geometry data we will draw
  73202. * @param defines The defines to update
  73203. */
  73204. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73205. /**
  73206. * Prepares the defines for morph targets
  73207. * @param mesh The mesh containing the geometry data we will draw
  73208. * @param defines The defines to update
  73209. */
  73210. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73211. /**
  73212. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73213. * @param mesh The mesh containing the geometry data we will draw
  73214. * @param defines The defines to update
  73215. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73216. * @param useBones Precise whether bones should be used or not (override mesh info)
  73217. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73218. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73219. * @returns false if defines are considered not dirty and have not been checked
  73220. */
  73221. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73222. /**
  73223. * Prepares the defines related to multiview
  73224. * @param scene The scene we are intending to draw
  73225. * @param defines The defines to update
  73226. */
  73227. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73228. /**
  73229. * Prepares the defines related to the light information passed in parameter
  73230. * @param scene The scene we are intending to draw
  73231. * @param mesh The mesh the effect is compiling for
  73232. * @param light The light the effect is compiling for
  73233. * @param lightIndex The index of the light
  73234. * @param defines The defines to update
  73235. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73236. * @param state Defines the current state regarding what is needed (normals, etc...)
  73237. */
  73238. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73239. needNormals: boolean;
  73240. needRebuild: boolean;
  73241. shadowEnabled: boolean;
  73242. specularEnabled: boolean;
  73243. lightmapMode: boolean;
  73244. }): void;
  73245. /**
  73246. * Prepares the defines related to the light information passed in parameter
  73247. * @param scene The scene we are intending to draw
  73248. * @param mesh The mesh the effect is compiling for
  73249. * @param defines The defines to update
  73250. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73251. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73252. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73253. * @returns true if normals will be required for the rest of the effect
  73254. */
  73255. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73256. /**
  73257. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73258. * @param lightIndex defines the light index
  73259. * @param uniformsList The uniform list
  73260. * @param samplersList The sampler list
  73261. * @param projectedLightTexture defines if projected texture must be used
  73262. * @param uniformBuffersList defines an optional list of uniform buffers
  73263. */
  73264. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73265. /**
  73266. * Prepares the uniforms and samplers list to be used in the effect
  73267. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73268. * @param samplersList The sampler list
  73269. * @param defines The defines helping in the list generation
  73270. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73271. */
  73272. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73273. /**
  73274. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73275. * @param defines The defines to update while falling back
  73276. * @param fallbacks The authorized effect fallbacks
  73277. * @param maxSimultaneousLights The maximum number of lights allowed
  73278. * @param rank the current rank of the Effect
  73279. * @returns The newly affected rank
  73280. */
  73281. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73282. private static _TmpMorphInfluencers;
  73283. /**
  73284. * Prepares the list of attributes required for morph targets according to the effect defines.
  73285. * @param attribs The current list of supported attribs
  73286. * @param mesh The mesh to prepare the morph targets attributes for
  73287. * @param influencers The number of influencers
  73288. */
  73289. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73290. /**
  73291. * Prepares the list of attributes required for morph targets according to the effect defines.
  73292. * @param attribs The current list of supported attribs
  73293. * @param mesh The mesh to prepare the morph targets attributes for
  73294. * @param defines The current Defines of the effect
  73295. */
  73296. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73297. /**
  73298. * Prepares the list of attributes required for bones according to the effect defines.
  73299. * @param attribs The current list of supported attribs
  73300. * @param mesh The mesh to prepare the bones attributes for
  73301. * @param defines The current Defines of the effect
  73302. * @param fallbacks The current efffect fallback strategy
  73303. */
  73304. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73305. /**
  73306. * Check and prepare the list of attributes required for instances according to the effect defines.
  73307. * @param attribs The current list of supported attribs
  73308. * @param defines The current MaterialDefines of the effect
  73309. */
  73310. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73311. /**
  73312. * Add the list of attributes required for instances to the attribs array.
  73313. * @param attribs The current list of supported attribs
  73314. */
  73315. static PushAttributesForInstances(attribs: string[]): void;
  73316. /**
  73317. * Binds the light shadow information to the effect for the given mesh.
  73318. * @param light The light containing the generator
  73319. * @param scene The scene the lights belongs to
  73320. * @param mesh The mesh we are binding the information to render
  73321. * @param lightIndex The light index in the effect used to render the mesh
  73322. * @param effect The effect we are binding the data to
  73323. */
  73324. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73325. /**
  73326. * Binds the light information to the effect.
  73327. * @param light The light containing the generator
  73328. * @param effect The effect we are binding the data to
  73329. * @param lightIndex The light index in the effect used to render
  73330. */
  73331. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73332. /**
  73333. * Binds the lights information from the scene to the effect for the given mesh.
  73334. * @param light Light to bind
  73335. * @param lightIndex Light index
  73336. * @param scene The scene where the light belongs to
  73337. * @param mesh The mesh we are binding the information to render
  73338. * @param effect The effect we are binding the data to
  73339. * @param useSpecular Defines if specular is supported
  73340. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73341. */
  73342. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73343. /**
  73344. * Binds the lights information from the scene to the effect for the given mesh.
  73345. * @param scene The scene the lights belongs to
  73346. * @param mesh The mesh we are binding the information to render
  73347. * @param effect The effect we are binding the data to
  73348. * @param defines The generated defines for the effect
  73349. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73350. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73351. */
  73352. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73353. private static _tempFogColor;
  73354. /**
  73355. * Binds the fog information from the scene to the effect for the given mesh.
  73356. * @param scene The scene the lights belongs to
  73357. * @param mesh The mesh we are binding the information to render
  73358. * @param effect The effect we are binding the data to
  73359. * @param linearSpace Defines if the fog effect is applied in linear space
  73360. */
  73361. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73362. /**
  73363. * Binds the bones information from the mesh to the effect.
  73364. * @param mesh The mesh we are binding the information to render
  73365. * @param effect The effect we are binding the data to
  73366. */
  73367. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73368. /**
  73369. * Binds the morph targets information from the mesh to the effect.
  73370. * @param abstractMesh The mesh we are binding the information to render
  73371. * @param effect The effect we are binding the data to
  73372. */
  73373. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73374. /**
  73375. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73376. * @param defines The generated defines used in the effect
  73377. * @param effect The effect we are binding the data to
  73378. * @param scene The scene we are willing to render with logarithmic scale for
  73379. */
  73380. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73381. /**
  73382. * Binds the clip plane information from the scene to the effect.
  73383. * @param scene The scene the clip plane information are extracted from
  73384. * @param effect The effect we are binding the data to
  73385. */
  73386. static BindClipPlane(effect: Effect, scene: Scene): void;
  73387. }
  73388. }
  73389. declare module BABYLON {
  73390. /** @hidden */
  73391. export var packingFunctions: {
  73392. name: string;
  73393. shader: string;
  73394. };
  73395. }
  73396. declare module BABYLON {
  73397. /** @hidden */
  73398. export var shadowMapPixelShader: {
  73399. name: string;
  73400. shader: string;
  73401. };
  73402. }
  73403. declare module BABYLON {
  73404. /** @hidden */
  73405. export var bonesDeclaration: {
  73406. name: string;
  73407. shader: string;
  73408. };
  73409. }
  73410. declare module BABYLON {
  73411. /** @hidden */
  73412. export var morphTargetsVertexGlobalDeclaration: {
  73413. name: string;
  73414. shader: string;
  73415. };
  73416. }
  73417. declare module BABYLON {
  73418. /** @hidden */
  73419. export var morphTargetsVertexDeclaration: {
  73420. name: string;
  73421. shader: string;
  73422. };
  73423. }
  73424. declare module BABYLON {
  73425. /** @hidden */
  73426. export var instancesDeclaration: {
  73427. name: string;
  73428. shader: string;
  73429. };
  73430. }
  73431. declare module BABYLON {
  73432. /** @hidden */
  73433. export var helperFunctions: {
  73434. name: string;
  73435. shader: string;
  73436. };
  73437. }
  73438. declare module BABYLON {
  73439. /** @hidden */
  73440. export var morphTargetsVertex: {
  73441. name: string;
  73442. shader: string;
  73443. };
  73444. }
  73445. declare module BABYLON {
  73446. /** @hidden */
  73447. export var instancesVertex: {
  73448. name: string;
  73449. shader: string;
  73450. };
  73451. }
  73452. declare module BABYLON {
  73453. /** @hidden */
  73454. export var bonesVertex: {
  73455. name: string;
  73456. shader: string;
  73457. };
  73458. }
  73459. declare module BABYLON {
  73460. /** @hidden */
  73461. export var shadowMapVertexShader: {
  73462. name: string;
  73463. shader: string;
  73464. };
  73465. }
  73466. declare module BABYLON {
  73467. /** @hidden */
  73468. export var depthBoxBlurPixelShader: {
  73469. name: string;
  73470. shader: string;
  73471. };
  73472. }
  73473. declare module BABYLON {
  73474. /**
  73475. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73476. */
  73477. export interface ICustomShaderOptions {
  73478. /**
  73479. * Gets or sets the custom shader name to use
  73480. */
  73481. shaderName: string;
  73482. /**
  73483. * The list of attribute names used in the shader
  73484. */
  73485. attributes?: string[];
  73486. /**
  73487. * The list of unifrom names used in the shader
  73488. */
  73489. uniforms?: string[];
  73490. /**
  73491. * The list of sampler names used in the shader
  73492. */
  73493. samplers?: string[];
  73494. /**
  73495. * The list of defines used in the shader
  73496. */
  73497. defines?: string[];
  73498. }
  73499. /**
  73500. * Interface to implement to create a shadow generator compatible with BJS.
  73501. */
  73502. export interface IShadowGenerator {
  73503. /**
  73504. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73505. * @returns The render target texture if present otherwise, null
  73506. */
  73507. getShadowMap(): Nullable<RenderTargetTexture>;
  73508. /**
  73509. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73510. * @returns The render target texture if the shadow map is present otherwise, null
  73511. */
  73512. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73513. /**
  73514. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73515. * @param subMesh The submesh we want to render in the shadow map
  73516. * @param useInstances Defines wether will draw in the map using instances
  73517. * @returns true if ready otherwise, false
  73518. */
  73519. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73520. /**
  73521. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73522. * @param defines Defines of the material we want to update
  73523. * @param lightIndex Index of the light in the enabled light list of the material
  73524. */
  73525. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73526. /**
  73527. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73528. * defined in the generator but impacting the effect).
  73529. * It implies the unifroms available on the materials are the standard BJS ones.
  73530. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73531. * @param effect The effect we are binfing the information for
  73532. */
  73533. bindShadowLight(lightIndex: string, effect: Effect): void;
  73534. /**
  73535. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73536. * (eq to shadow prjection matrix * light transform matrix)
  73537. * @returns The transform matrix used to create the shadow map
  73538. */
  73539. getTransformMatrix(): Matrix;
  73540. /**
  73541. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73542. * Cube and 2D textures for instance.
  73543. */
  73544. recreateShadowMap(): void;
  73545. /**
  73546. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73547. * @param onCompiled Callback triggered at the and of the effects compilation
  73548. * @param options Sets of optional options forcing the compilation with different modes
  73549. */
  73550. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73551. useInstances: boolean;
  73552. }>): void;
  73553. /**
  73554. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73555. * @param options Sets of optional options forcing the compilation with different modes
  73556. * @returns A promise that resolves when the compilation completes
  73557. */
  73558. forceCompilationAsync(options?: Partial<{
  73559. useInstances: boolean;
  73560. }>): Promise<void>;
  73561. /**
  73562. * Serializes the shadow generator setup to a json object.
  73563. * @returns The serialized JSON object
  73564. */
  73565. serialize(): any;
  73566. /**
  73567. * Disposes the Shadow map and related Textures and effects.
  73568. */
  73569. dispose(): void;
  73570. }
  73571. /**
  73572. * Default implementation IShadowGenerator.
  73573. * This is the main object responsible of generating shadows in the framework.
  73574. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73575. */
  73576. export class ShadowGenerator implements IShadowGenerator {
  73577. /**
  73578. * Shadow generator mode None: no filtering applied.
  73579. */
  73580. static readonly FILTER_NONE: number;
  73581. /**
  73582. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73583. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73584. */
  73585. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73586. /**
  73587. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73588. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73589. */
  73590. static readonly FILTER_POISSONSAMPLING: number;
  73591. /**
  73592. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73593. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73594. */
  73595. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73596. /**
  73597. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73598. * edge artifacts on steep falloff.
  73599. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73600. */
  73601. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73602. /**
  73603. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73604. * edge artifacts on steep falloff.
  73605. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73606. */
  73607. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73608. /**
  73609. * Shadow generator mode PCF: Percentage Closer Filtering
  73610. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73611. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73612. */
  73613. static readonly FILTER_PCF: number;
  73614. /**
  73615. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73616. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73617. * Contact Hardening
  73618. */
  73619. static readonly FILTER_PCSS: number;
  73620. /**
  73621. * Reserved for PCF and PCSS
  73622. * Highest Quality.
  73623. *
  73624. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73625. *
  73626. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73627. */
  73628. static readonly QUALITY_HIGH: number;
  73629. /**
  73630. * Reserved for PCF and PCSS
  73631. * Good tradeoff for quality/perf cross devices
  73632. *
  73633. * Execute PCF on a 3*3 kernel.
  73634. *
  73635. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73636. */
  73637. static readonly QUALITY_MEDIUM: number;
  73638. /**
  73639. * Reserved for PCF and PCSS
  73640. * The lowest quality but the fastest.
  73641. *
  73642. * Execute PCF on a 1*1 kernel.
  73643. *
  73644. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73645. */
  73646. static readonly QUALITY_LOW: number;
  73647. /** Gets or sets the custom shader name to use */
  73648. customShaderOptions: ICustomShaderOptions;
  73649. /**
  73650. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73651. */
  73652. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73653. /**
  73654. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73655. */
  73656. onAfterShadowMapRenderObservable: Observable<Effect>;
  73657. /**
  73658. * Observable triggered before a mesh is rendered in the shadow map.
  73659. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73660. */
  73661. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73662. /**
  73663. * Observable triggered after a mesh is rendered in the shadow map.
  73664. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73665. */
  73666. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73667. private _bias;
  73668. /**
  73669. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73670. */
  73671. /**
  73672. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73673. */
  73674. bias: number;
  73675. private _normalBias;
  73676. /**
  73677. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73678. */
  73679. /**
  73680. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73681. */
  73682. normalBias: number;
  73683. private _blurBoxOffset;
  73684. /**
  73685. * Gets the blur box offset: offset applied during the blur pass.
  73686. * Only useful if useKernelBlur = false
  73687. */
  73688. /**
  73689. * Sets the blur box offset: offset applied during the blur pass.
  73690. * Only useful if useKernelBlur = false
  73691. */
  73692. blurBoxOffset: number;
  73693. private _blurScale;
  73694. /**
  73695. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73696. * 2 means half of the size.
  73697. */
  73698. /**
  73699. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73700. * 2 means half of the size.
  73701. */
  73702. blurScale: number;
  73703. private _blurKernel;
  73704. /**
  73705. * Gets the blur kernel: kernel size of the blur pass.
  73706. * Only useful if useKernelBlur = true
  73707. */
  73708. /**
  73709. * Sets the blur kernel: kernel size of the blur pass.
  73710. * Only useful if useKernelBlur = true
  73711. */
  73712. blurKernel: number;
  73713. private _useKernelBlur;
  73714. /**
  73715. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73716. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73717. */
  73718. /**
  73719. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73720. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73721. */
  73722. useKernelBlur: boolean;
  73723. private _depthScale;
  73724. /**
  73725. * Gets the depth scale used in ESM mode.
  73726. */
  73727. /**
  73728. * Sets the depth scale used in ESM mode.
  73729. * This can override the scale stored on the light.
  73730. */
  73731. depthScale: number;
  73732. private _filter;
  73733. /**
  73734. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73735. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73736. */
  73737. /**
  73738. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73739. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73740. */
  73741. filter: number;
  73742. /**
  73743. * Gets if the current filter is set to Poisson Sampling.
  73744. */
  73745. /**
  73746. * Sets the current filter to Poisson Sampling.
  73747. */
  73748. usePoissonSampling: boolean;
  73749. /**
  73750. * Gets if the current filter is set to ESM.
  73751. */
  73752. /**
  73753. * Sets the current filter is to ESM.
  73754. */
  73755. useExponentialShadowMap: boolean;
  73756. /**
  73757. * Gets if the current filter is set to filtered ESM.
  73758. */
  73759. /**
  73760. * Gets if the current filter is set to filtered ESM.
  73761. */
  73762. useBlurExponentialShadowMap: boolean;
  73763. /**
  73764. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73765. * exponential to prevent steep falloff artifacts).
  73766. */
  73767. /**
  73768. * Sets the current filter to "close ESM" (using the inverse of the
  73769. * exponential to prevent steep falloff artifacts).
  73770. */
  73771. useCloseExponentialShadowMap: boolean;
  73772. /**
  73773. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73774. * exponential to prevent steep falloff artifacts).
  73775. */
  73776. /**
  73777. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73778. * exponential to prevent steep falloff artifacts).
  73779. */
  73780. useBlurCloseExponentialShadowMap: boolean;
  73781. /**
  73782. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73783. */
  73784. /**
  73785. * Sets the current filter to "PCF" (percentage closer filtering).
  73786. */
  73787. usePercentageCloserFiltering: boolean;
  73788. private _filteringQuality;
  73789. /**
  73790. * Gets the PCF or PCSS Quality.
  73791. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73792. */
  73793. /**
  73794. * Sets the PCF or PCSS Quality.
  73795. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73796. */
  73797. filteringQuality: number;
  73798. /**
  73799. * Gets if the current filter is set to "PCSS" (contact hardening).
  73800. */
  73801. /**
  73802. * Sets the current filter to "PCSS" (contact hardening).
  73803. */
  73804. useContactHardeningShadow: boolean;
  73805. private _contactHardeningLightSizeUVRatio;
  73806. /**
  73807. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73808. * Using a ratio helps keeping shape stability independently of the map size.
  73809. *
  73810. * It does not account for the light projection as it was having too much
  73811. * instability during the light setup or during light position changes.
  73812. *
  73813. * Only valid if useContactHardeningShadow is true.
  73814. */
  73815. /**
  73816. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73817. * Using a ratio helps keeping shape stability independently of the map size.
  73818. *
  73819. * It does not account for the light projection as it was having too much
  73820. * instability during the light setup or during light position changes.
  73821. *
  73822. * Only valid if useContactHardeningShadow is true.
  73823. */
  73824. contactHardeningLightSizeUVRatio: number;
  73825. private _darkness;
  73826. /** Gets or sets the actual darkness of a shadow */
  73827. darkness: number;
  73828. /**
  73829. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73830. * 0 means strongest and 1 would means no shadow.
  73831. * @returns the darkness.
  73832. */
  73833. getDarkness(): number;
  73834. /**
  73835. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73836. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73837. * @returns the shadow generator allowing fluent coding.
  73838. */
  73839. setDarkness(darkness: number): ShadowGenerator;
  73840. private _transparencyShadow;
  73841. /** Gets or sets the ability to have transparent shadow */
  73842. transparencyShadow: boolean;
  73843. /**
  73844. * Sets the ability to have transparent shadow (boolean).
  73845. * @param transparent True if transparent else False
  73846. * @returns the shadow generator allowing fluent coding
  73847. */
  73848. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  73849. private _shadowMap;
  73850. private _shadowMap2;
  73851. /**
  73852. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73853. * @returns The render target texture if present otherwise, null
  73854. */
  73855. getShadowMap(): Nullable<RenderTargetTexture>;
  73856. /**
  73857. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73858. * @returns The render target texture if the shadow map is present otherwise, null
  73859. */
  73860. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73861. /**
  73862. * Gets the class name of that object
  73863. * @returns "ShadowGenerator"
  73864. */
  73865. getClassName(): string;
  73866. /**
  73867. * Helper function to add a mesh and its descendants to the list of shadow casters.
  73868. * @param mesh Mesh to add
  73869. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  73870. * @returns the Shadow Generator itself
  73871. */
  73872. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73873. /**
  73874. * Helper function to remove a mesh and its descendants from the list of shadow casters
  73875. * @param mesh Mesh to remove
  73876. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  73877. * @returns the Shadow Generator itself
  73878. */
  73879. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73880. /**
  73881. * Controls the extent to which the shadows fade out at the edge of the frustum
  73882. * Used only by directionals and spots
  73883. */
  73884. frustumEdgeFalloff: number;
  73885. private _light;
  73886. /**
  73887. * Returns the associated light object.
  73888. * @returns the light generating the shadow
  73889. */
  73890. getLight(): IShadowLight;
  73891. /**
  73892. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  73893. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  73894. * It might on the other hand introduce peter panning.
  73895. */
  73896. forceBackFacesOnly: boolean;
  73897. private _scene;
  73898. private _lightDirection;
  73899. private _effect;
  73900. private _viewMatrix;
  73901. private _projectionMatrix;
  73902. private _transformMatrix;
  73903. private _cachedPosition;
  73904. private _cachedDirection;
  73905. private _cachedDefines;
  73906. private _currentRenderID;
  73907. private _boxBlurPostprocess;
  73908. private _kernelBlurXPostprocess;
  73909. private _kernelBlurYPostprocess;
  73910. private _blurPostProcesses;
  73911. private _mapSize;
  73912. private _currentFaceIndex;
  73913. private _currentFaceIndexCache;
  73914. private _textureType;
  73915. private _defaultTextureMatrix;
  73916. /** @hidden */
  73917. static _SceneComponentInitialization: (scene: Scene) => void;
  73918. /**
  73919. * Creates a ShadowGenerator object.
  73920. * A ShadowGenerator is the required tool to use the shadows.
  73921. * Each light casting shadows needs to use its own ShadowGenerator.
  73922. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  73923. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  73924. * @param light The light object generating the shadows.
  73925. * @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.
  73926. */
  73927. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  73928. private _initializeGenerator;
  73929. private _initializeShadowMap;
  73930. private _initializeBlurRTTAndPostProcesses;
  73931. private _renderForShadowMap;
  73932. private _renderSubMeshForShadowMap;
  73933. private _applyFilterValues;
  73934. /**
  73935. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73936. * @param onCompiled Callback triggered at the and of the effects compilation
  73937. * @param options Sets of optional options forcing the compilation with different modes
  73938. */
  73939. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73940. useInstances: boolean;
  73941. }>): void;
  73942. /**
  73943. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73944. * @param options Sets of optional options forcing the compilation with different modes
  73945. * @returns A promise that resolves when the compilation completes
  73946. */
  73947. forceCompilationAsync(options?: Partial<{
  73948. useInstances: boolean;
  73949. }>): Promise<void>;
  73950. /**
  73951. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73952. * @param subMesh The submesh we want to render in the shadow map
  73953. * @param useInstances Defines wether will draw in the map using instances
  73954. * @returns true if ready otherwise, false
  73955. */
  73956. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73957. /**
  73958. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73959. * @param defines Defines of the material we want to update
  73960. * @param lightIndex Index of the light in the enabled light list of the material
  73961. */
  73962. prepareDefines(defines: any, lightIndex: number): void;
  73963. /**
  73964. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73965. * defined in the generator but impacting the effect).
  73966. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73967. * @param effect The effect we are binfing the information for
  73968. */
  73969. bindShadowLight(lightIndex: string, effect: Effect): void;
  73970. /**
  73971. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73972. * (eq to shadow prjection matrix * light transform matrix)
  73973. * @returns The transform matrix used to create the shadow map
  73974. */
  73975. getTransformMatrix(): Matrix;
  73976. /**
  73977. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73978. * Cube and 2D textures for instance.
  73979. */
  73980. recreateShadowMap(): void;
  73981. private _disposeBlurPostProcesses;
  73982. private _disposeRTTandPostProcesses;
  73983. /**
  73984. * Disposes the ShadowGenerator.
  73985. * Returns nothing.
  73986. */
  73987. dispose(): void;
  73988. /**
  73989. * Serializes the shadow generator setup to a json object.
  73990. * @returns The serialized JSON object
  73991. */
  73992. serialize(): any;
  73993. /**
  73994. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  73995. * @param parsedShadowGenerator The JSON object to parse
  73996. * @param scene The scene to create the shadow map for
  73997. * @returns The parsed shadow generator
  73998. */
  73999. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74000. }
  74001. }
  74002. declare module BABYLON {
  74003. /**
  74004. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74005. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74006. * 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.
  74007. */
  74008. export abstract class Light extends Node {
  74009. /**
  74010. * Falloff Default: light is falling off following the material specification:
  74011. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74012. */
  74013. static readonly FALLOFF_DEFAULT: number;
  74014. /**
  74015. * Falloff Physical: light is falling off following the inverse squared distance law.
  74016. */
  74017. static readonly FALLOFF_PHYSICAL: number;
  74018. /**
  74019. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74020. * to enhance interoperability with other engines.
  74021. */
  74022. static readonly FALLOFF_GLTF: number;
  74023. /**
  74024. * Falloff Standard: light is falling off like in the standard material
  74025. * to enhance interoperability with other materials.
  74026. */
  74027. static readonly FALLOFF_STANDARD: number;
  74028. /**
  74029. * If every light affecting the material is in this lightmapMode,
  74030. * material.lightmapTexture adds or multiplies
  74031. * (depends on material.useLightmapAsShadowmap)
  74032. * after every other light calculations.
  74033. */
  74034. static readonly LIGHTMAP_DEFAULT: number;
  74035. /**
  74036. * material.lightmapTexture as only diffuse lighting from this light
  74037. * adds only specular lighting from this light
  74038. * adds dynamic shadows
  74039. */
  74040. static readonly LIGHTMAP_SPECULAR: number;
  74041. /**
  74042. * material.lightmapTexture as only lighting
  74043. * no light calculation from this light
  74044. * only adds dynamic shadows from this light
  74045. */
  74046. static readonly LIGHTMAP_SHADOWSONLY: number;
  74047. /**
  74048. * Each light type uses the default quantity according to its type:
  74049. * point/spot lights use luminous intensity
  74050. * directional lights use illuminance
  74051. */
  74052. static readonly INTENSITYMODE_AUTOMATIC: number;
  74053. /**
  74054. * lumen (lm)
  74055. */
  74056. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74057. /**
  74058. * candela (lm/sr)
  74059. */
  74060. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74061. /**
  74062. * lux (lm/m^2)
  74063. */
  74064. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74065. /**
  74066. * nit (cd/m^2)
  74067. */
  74068. static readonly INTENSITYMODE_LUMINANCE: number;
  74069. /**
  74070. * Light type const id of the point light.
  74071. */
  74072. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74073. /**
  74074. * Light type const id of the directional light.
  74075. */
  74076. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74077. /**
  74078. * Light type const id of the spot light.
  74079. */
  74080. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74081. /**
  74082. * Light type const id of the hemispheric light.
  74083. */
  74084. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74085. /**
  74086. * Diffuse gives the basic color to an object.
  74087. */
  74088. diffuse: Color3;
  74089. /**
  74090. * Specular produces a highlight color on an object.
  74091. * Note: This is note affecting PBR materials.
  74092. */
  74093. specular: Color3;
  74094. /**
  74095. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74096. * falling off base on range or angle.
  74097. * This can be set to any values in Light.FALLOFF_x.
  74098. *
  74099. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74100. * other types of materials.
  74101. */
  74102. falloffType: number;
  74103. /**
  74104. * Strength of the light.
  74105. * Note: By default it is define in the framework own unit.
  74106. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74107. */
  74108. intensity: number;
  74109. private _range;
  74110. protected _inverseSquaredRange: number;
  74111. /**
  74112. * Defines how far from the source the light is impacting in scene units.
  74113. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74114. */
  74115. /**
  74116. * Defines how far from the source the light is impacting in scene units.
  74117. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74118. */
  74119. range: number;
  74120. /**
  74121. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74122. * of light.
  74123. */
  74124. private _photometricScale;
  74125. private _intensityMode;
  74126. /**
  74127. * Gets the photometric scale used to interpret the intensity.
  74128. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74129. */
  74130. /**
  74131. * Sets the photometric scale used to interpret the intensity.
  74132. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74133. */
  74134. intensityMode: number;
  74135. private _radius;
  74136. /**
  74137. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74138. */
  74139. /**
  74140. * sets the light radius used by PBR Materials to simulate soft area lights.
  74141. */
  74142. radius: number;
  74143. private _renderPriority;
  74144. /**
  74145. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74146. * exceeding the number allowed of the materials.
  74147. */
  74148. renderPriority: number;
  74149. private _shadowEnabled;
  74150. /**
  74151. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74152. * the current shadow generator.
  74153. */
  74154. /**
  74155. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74156. * the current shadow generator.
  74157. */
  74158. shadowEnabled: boolean;
  74159. private _includedOnlyMeshes;
  74160. /**
  74161. * Gets the only meshes impacted by this light.
  74162. */
  74163. /**
  74164. * Sets the only meshes impacted by this light.
  74165. */
  74166. includedOnlyMeshes: AbstractMesh[];
  74167. private _excludedMeshes;
  74168. /**
  74169. * Gets the meshes not impacted by this light.
  74170. */
  74171. /**
  74172. * Sets the meshes not impacted by this light.
  74173. */
  74174. excludedMeshes: AbstractMesh[];
  74175. private _excludeWithLayerMask;
  74176. /**
  74177. * Gets the layer id use to find what meshes are not impacted by the light.
  74178. * Inactive if 0
  74179. */
  74180. /**
  74181. * Sets the layer id use to find what meshes are not impacted by the light.
  74182. * Inactive if 0
  74183. */
  74184. excludeWithLayerMask: number;
  74185. private _includeOnlyWithLayerMask;
  74186. /**
  74187. * Gets the layer id use to find what meshes are impacted by the light.
  74188. * Inactive if 0
  74189. */
  74190. /**
  74191. * Sets the layer id use to find what meshes are impacted by the light.
  74192. * Inactive if 0
  74193. */
  74194. includeOnlyWithLayerMask: number;
  74195. private _lightmapMode;
  74196. /**
  74197. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74198. */
  74199. /**
  74200. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74201. */
  74202. lightmapMode: number;
  74203. /**
  74204. * Shadow generator associted to the light.
  74205. * @hidden Internal use only.
  74206. */
  74207. _shadowGenerator: Nullable<IShadowGenerator>;
  74208. /**
  74209. * @hidden Internal use only.
  74210. */
  74211. _excludedMeshesIds: string[];
  74212. /**
  74213. * @hidden Internal use only.
  74214. */
  74215. _includedOnlyMeshesIds: string[];
  74216. /**
  74217. * The current light unifom buffer.
  74218. * @hidden Internal use only.
  74219. */
  74220. _uniformBuffer: UniformBuffer;
  74221. /**
  74222. * Creates a Light object in the scene.
  74223. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74224. * @param name The firendly name of the light
  74225. * @param scene The scene the light belongs too
  74226. */
  74227. constructor(name: string, scene: Scene);
  74228. protected abstract _buildUniformLayout(): void;
  74229. /**
  74230. * Sets the passed Effect "effect" with the Light information.
  74231. * @param effect The effect to update
  74232. * @param lightIndex The index of the light in the effect to update
  74233. * @returns The light
  74234. */
  74235. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74236. /**
  74237. * Returns the string "Light".
  74238. * @returns the class name
  74239. */
  74240. getClassName(): string;
  74241. /** @hidden */
  74242. readonly _isLight: boolean;
  74243. /**
  74244. * Converts the light information to a readable string for debug purpose.
  74245. * @param fullDetails Supports for multiple levels of logging within scene loading
  74246. * @returns the human readable light info
  74247. */
  74248. toString(fullDetails?: boolean): string;
  74249. /** @hidden */
  74250. protected _syncParentEnabledState(): void;
  74251. /**
  74252. * Set the enabled state of this node.
  74253. * @param value - the new enabled state
  74254. */
  74255. setEnabled(value: boolean): void;
  74256. /**
  74257. * Returns the Light associated shadow generator if any.
  74258. * @return the associated shadow generator.
  74259. */
  74260. getShadowGenerator(): Nullable<IShadowGenerator>;
  74261. /**
  74262. * Returns a Vector3, the absolute light position in the World.
  74263. * @returns the world space position of the light
  74264. */
  74265. getAbsolutePosition(): Vector3;
  74266. /**
  74267. * Specifies if the light will affect the passed mesh.
  74268. * @param mesh The mesh to test against the light
  74269. * @return true the mesh is affected otherwise, false.
  74270. */
  74271. canAffectMesh(mesh: AbstractMesh): boolean;
  74272. /**
  74273. * Sort function to order lights for rendering.
  74274. * @param a First Light object to compare to second.
  74275. * @param b Second Light object to compare first.
  74276. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74277. */
  74278. static CompareLightsPriority(a: Light, b: Light): number;
  74279. /**
  74280. * Releases resources associated with this node.
  74281. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74282. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74283. */
  74284. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74285. /**
  74286. * Returns the light type ID (integer).
  74287. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74288. */
  74289. getTypeID(): number;
  74290. /**
  74291. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74292. * @returns the scaled intensity in intensity mode unit
  74293. */
  74294. getScaledIntensity(): number;
  74295. /**
  74296. * Returns a new Light object, named "name", from the current one.
  74297. * @param name The name of the cloned light
  74298. * @returns the new created light
  74299. */
  74300. clone(name: string): Nullable<Light>;
  74301. /**
  74302. * Serializes the current light into a Serialization object.
  74303. * @returns the serialized object.
  74304. */
  74305. serialize(): any;
  74306. /**
  74307. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74308. * This new light is named "name" and added to the passed scene.
  74309. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74310. * @param name The friendly name of the light
  74311. * @param scene The scene the new light will belong to
  74312. * @returns the constructor function
  74313. */
  74314. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74315. /**
  74316. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74317. * @param parsedLight The JSON representation of the light
  74318. * @param scene The scene to create the parsed light in
  74319. * @returns the created light after parsing
  74320. */
  74321. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74322. private _hookArrayForExcluded;
  74323. private _hookArrayForIncludedOnly;
  74324. private _resyncMeshes;
  74325. /**
  74326. * Forces the meshes to update their light related information in their rendering used effects
  74327. * @hidden Internal Use Only
  74328. */
  74329. _markMeshesAsLightDirty(): void;
  74330. /**
  74331. * Recomputes the cached photometric scale if needed.
  74332. */
  74333. private _computePhotometricScale;
  74334. /**
  74335. * Returns the Photometric Scale according to the light type and intensity mode.
  74336. */
  74337. private _getPhotometricScale;
  74338. /**
  74339. * Reorder the light in the scene according to their defined priority.
  74340. * @hidden Internal Use Only
  74341. */
  74342. _reorderLightsInScene(): void;
  74343. /**
  74344. * Prepares the list of defines specific to the light type.
  74345. * @param defines the list of defines
  74346. * @param lightIndex defines the index of the light for the effect
  74347. */
  74348. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74349. }
  74350. }
  74351. declare module BABYLON {
  74352. /**
  74353. * Interface used to define Action
  74354. */
  74355. export interface IAction {
  74356. /**
  74357. * Trigger for the action
  74358. */
  74359. trigger: number;
  74360. /** Options of the trigger */
  74361. triggerOptions: any;
  74362. /**
  74363. * Gets the trigger parameters
  74364. * @returns the trigger parameters
  74365. */
  74366. getTriggerParameter(): any;
  74367. /**
  74368. * Internal only - executes current action event
  74369. * @hidden
  74370. */
  74371. _executeCurrent(evt?: ActionEvent): void;
  74372. /**
  74373. * Serialize placeholder for child classes
  74374. * @param parent of child
  74375. * @returns the serialized object
  74376. */
  74377. serialize(parent: any): any;
  74378. /**
  74379. * Internal only
  74380. * @hidden
  74381. */
  74382. _prepare(): void;
  74383. /**
  74384. * Internal only - manager for action
  74385. * @hidden
  74386. */
  74387. _actionManager: AbstractActionManager;
  74388. /**
  74389. * Adds action to chain of actions, may be a DoNothingAction
  74390. * @param action defines the next action to execute
  74391. * @returns The action passed in
  74392. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74393. */
  74394. then(action: IAction): IAction;
  74395. }
  74396. /**
  74397. * The action to be carried out following a trigger
  74398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  74399. */
  74400. export class Action implements IAction {
  74401. /** the trigger, with or without parameters, for the action */
  74402. triggerOptions: any;
  74403. /**
  74404. * Trigger for the action
  74405. */
  74406. trigger: number;
  74407. /**
  74408. * Internal only - manager for action
  74409. * @hidden
  74410. */
  74411. _actionManager: ActionManager;
  74412. private _nextActiveAction;
  74413. private _child;
  74414. private _condition?;
  74415. private _triggerParameter;
  74416. /**
  74417. * An event triggered prior to action being executed.
  74418. */
  74419. onBeforeExecuteObservable: Observable<Action>;
  74420. /**
  74421. * Creates a new Action
  74422. * @param triggerOptions the trigger, with or without parameters, for the action
  74423. * @param condition an optional determinant of action
  74424. */
  74425. constructor(
  74426. /** the trigger, with or without parameters, for the action */
  74427. triggerOptions: any, condition?: Condition);
  74428. /**
  74429. * Internal only
  74430. * @hidden
  74431. */
  74432. _prepare(): void;
  74433. /**
  74434. * Gets the trigger parameters
  74435. * @returns the trigger parameters
  74436. */
  74437. getTriggerParameter(): any;
  74438. /**
  74439. * Internal only - executes current action event
  74440. * @hidden
  74441. */
  74442. _executeCurrent(evt?: ActionEvent): void;
  74443. /**
  74444. * Execute placeholder for child classes
  74445. * @param evt optional action event
  74446. */
  74447. execute(evt?: ActionEvent): void;
  74448. /**
  74449. * Skips to next active action
  74450. */
  74451. skipToNextActiveAction(): void;
  74452. /**
  74453. * Adds action to chain of actions, may be a DoNothingAction
  74454. * @param action defines the next action to execute
  74455. * @returns The action passed in
  74456. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74457. */
  74458. then(action: Action): Action;
  74459. /**
  74460. * Internal only
  74461. * @hidden
  74462. */
  74463. _getProperty(propertyPath: string): string;
  74464. /**
  74465. * Internal only
  74466. * @hidden
  74467. */
  74468. _getEffectiveTarget(target: any, propertyPath: string): any;
  74469. /**
  74470. * Serialize placeholder for child classes
  74471. * @param parent of child
  74472. * @returns the serialized object
  74473. */
  74474. serialize(parent: any): any;
  74475. /**
  74476. * Internal only called by serialize
  74477. * @hidden
  74478. */
  74479. protected _serialize(serializedAction: any, parent?: any): any;
  74480. /**
  74481. * Internal only
  74482. * @hidden
  74483. */
  74484. static _SerializeValueAsString: (value: any) => string;
  74485. /**
  74486. * Internal only
  74487. * @hidden
  74488. */
  74489. static _GetTargetProperty: (target: Node | Scene) => {
  74490. name: string;
  74491. targetType: string;
  74492. value: string;
  74493. };
  74494. }
  74495. }
  74496. declare module BABYLON {
  74497. /**
  74498. * A Condition applied to an Action
  74499. */
  74500. export class Condition {
  74501. /**
  74502. * Internal only - manager for action
  74503. * @hidden
  74504. */
  74505. _actionManager: ActionManager;
  74506. /**
  74507. * Internal only
  74508. * @hidden
  74509. */
  74510. _evaluationId: number;
  74511. /**
  74512. * Internal only
  74513. * @hidden
  74514. */
  74515. _currentResult: boolean;
  74516. /**
  74517. * Creates a new Condition
  74518. * @param actionManager the manager of the action the condition is applied to
  74519. */
  74520. constructor(actionManager: ActionManager);
  74521. /**
  74522. * Check if the current condition is valid
  74523. * @returns a boolean
  74524. */
  74525. isValid(): boolean;
  74526. /**
  74527. * Internal only
  74528. * @hidden
  74529. */
  74530. _getProperty(propertyPath: string): string;
  74531. /**
  74532. * Internal only
  74533. * @hidden
  74534. */
  74535. _getEffectiveTarget(target: any, propertyPath: string): any;
  74536. /**
  74537. * Serialize placeholder for child classes
  74538. * @returns the serialized object
  74539. */
  74540. serialize(): any;
  74541. /**
  74542. * Internal only
  74543. * @hidden
  74544. */
  74545. protected _serialize(serializedCondition: any): any;
  74546. }
  74547. /**
  74548. * Defines specific conditional operators as extensions of Condition
  74549. */
  74550. export class ValueCondition extends Condition {
  74551. /** path to specify the property of the target the conditional operator uses */
  74552. propertyPath: string;
  74553. /** the value compared by the conditional operator against the current value of the property */
  74554. value: any;
  74555. /** the conditional operator, default ValueCondition.IsEqual */
  74556. operator: number;
  74557. /**
  74558. * Internal only
  74559. * @hidden
  74560. */
  74561. private static _IsEqual;
  74562. /**
  74563. * Internal only
  74564. * @hidden
  74565. */
  74566. private static _IsDifferent;
  74567. /**
  74568. * Internal only
  74569. * @hidden
  74570. */
  74571. private static _IsGreater;
  74572. /**
  74573. * Internal only
  74574. * @hidden
  74575. */
  74576. private static _IsLesser;
  74577. /**
  74578. * returns the number for IsEqual
  74579. */
  74580. static readonly IsEqual: number;
  74581. /**
  74582. * Returns the number for IsDifferent
  74583. */
  74584. static readonly IsDifferent: number;
  74585. /**
  74586. * Returns the number for IsGreater
  74587. */
  74588. static readonly IsGreater: number;
  74589. /**
  74590. * Returns the number for IsLesser
  74591. */
  74592. static readonly IsLesser: number;
  74593. /**
  74594. * Internal only The action manager for the condition
  74595. * @hidden
  74596. */
  74597. _actionManager: ActionManager;
  74598. /**
  74599. * Internal only
  74600. * @hidden
  74601. */
  74602. private _target;
  74603. /**
  74604. * Internal only
  74605. * @hidden
  74606. */
  74607. private _effectiveTarget;
  74608. /**
  74609. * Internal only
  74610. * @hidden
  74611. */
  74612. private _property;
  74613. /**
  74614. * Creates a new ValueCondition
  74615. * @param actionManager manager for the action the condition applies to
  74616. * @param target for the action
  74617. * @param propertyPath path to specify the property of the target the conditional operator uses
  74618. * @param value the value compared by the conditional operator against the current value of the property
  74619. * @param operator the conditional operator, default ValueCondition.IsEqual
  74620. */
  74621. constructor(actionManager: ActionManager, target: any,
  74622. /** path to specify the property of the target the conditional operator uses */
  74623. propertyPath: string,
  74624. /** the value compared by the conditional operator against the current value of the property */
  74625. value: any,
  74626. /** the conditional operator, default ValueCondition.IsEqual */
  74627. operator?: number);
  74628. /**
  74629. * Compares the given value with the property value for the specified conditional operator
  74630. * @returns the result of the comparison
  74631. */
  74632. isValid(): boolean;
  74633. /**
  74634. * Serialize the ValueCondition into a JSON compatible object
  74635. * @returns serialization object
  74636. */
  74637. serialize(): any;
  74638. /**
  74639. * Gets the name of the conditional operator for the ValueCondition
  74640. * @param operator the conditional operator
  74641. * @returns the name
  74642. */
  74643. static GetOperatorName(operator: number): string;
  74644. }
  74645. /**
  74646. * Defines a predicate condition as an extension of Condition
  74647. */
  74648. export class PredicateCondition extends Condition {
  74649. /** defines the predicate function used to validate the condition */
  74650. predicate: () => boolean;
  74651. /**
  74652. * Internal only - manager for action
  74653. * @hidden
  74654. */
  74655. _actionManager: ActionManager;
  74656. /**
  74657. * Creates a new PredicateCondition
  74658. * @param actionManager manager for the action the condition applies to
  74659. * @param predicate defines the predicate function used to validate the condition
  74660. */
  74661. constructor(actionManager: ActionManager,
  74662. /** defines the predicate function used to validate the condition */
  74663. predicate: () => boolean);
  74664. /**
  74665. * @returns the validity of the predicate condition
  74666. */
  74667. isValid(): boolean;
  74668. }
  74669. /**
  74670. * Defines a state condition as an extension of Condition
  74671. */
  74672. export class StateCondition extends Condition {
  74673. /** Value to compare with target state */
  74674. value: string;
  74675. /**
  74676. * Internal only - manager for action
  74677. * @hidden
  74678. */
  74679. _actionManager: ActionManager;
  74680. /**
  74681. * Internal only
  74682. * @hidden
  74683. */
  74684. private _target;
  74685. /**
  74686. * Creates a new StateCondition
  74687. * @param actionManager manager for the action the condition applies to
  74688. * @param target of the condition
  74689. * @param value to compare with target state
  74690. */
  74691. constructor(actionManager: ActionManager, target: any,
  74692. /** Value to compare with target state */
  74693. value: string);
  74694. /**
  74695. * Gets a boolean indicating if the current condition is met
  74696. * @returns the validity of the state
  74697. */
  74698. isValid(): boolean;
  74699. /**
  74700. * Serialize the StateCondition into a JSON compatible object
  74701. * @returns serialization object
  74702. */
  74703. serialize(): any;
  74704. }
  74705. }
  74706. declare module BABYLON {
  74707. /**
  74708. * This defines an action responsible to toggle a boolean once triggered.
  74709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74710. */
  74711. export class SwitchBooleanAction extends Action {
  74712. /**
  74713. * The path to the boolean property in the target object
  74714. */
  74715. propertyPath: string;
  74716. private _target;
  74717. private _effectiveTarget;
  74718. private _property;
  74719. /**
  74720. * Instantiate the action
  74721. * @param triggerOptions defines the trigger options
  74722. * @param target defines the object containing the boolean
  74723. * @param propertyPath defines the path to the boolean property in the target object
  74724. * @param condition defines the trigger related conditions
  74725. */
  74726. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74727. /** @hidden */
  74728. _prepare(): void;
  74729. /**
  74730. * Execute the action toggle the boolean value.
  74731. */
  74732. execute(): void;
  74733. /**
  74734. * Serializes the actions and its related information.
  74735. * @param parent defines the object to serialize in
  74736. * @returns the serialized object
  74737. */
  74738. serialize(parent: any): any;
  74739. }
  74740. /**
  74741. * This defines an action responsible to set a the state field of the target
  74742. * to a desired value once triggered.
  74743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74744. */
  74745. export class SetStateAction extends Action {
  74746. /**
  74747. * The value to store in the state field.
  74748. */
  74749. value: string;
  74750. private _target;
  74751. /**
  74752. * Instantiate the action
  74753. * @param triggerOptions defines the trigger options
  74754. * @param target defines the object containing the state property
  74755. * @param value defines the value to store in the state field
  74756. * @param condition defines the trigger related conditions
  74757. */
  74758. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74759. /**
  74760. * Execute the action and store the value on the target state property.
  74761. */
  74762. execute(): void;
  74763. /**
  74764. * Serializes the actions and its related information.
  74765. * @param parent defines the object to serialize in
  74766. * @returns the serialized object
  74767. */
  74768. serialize(parent: any): any;
  74769. }
  74770. /**
  74771. * This defines an action responsible to set a property of the target
  74772. * to a desired value once triggered.
  74773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74774. */
  74775. export class SetValueAction extends Action {
  74776. /**
  74777. * The path of the property to set in the target.
  74778. */
  74779. propertyPath: string;
  74780. /**
  74781. * The value to set in the property
  74782. */
  74783. value: any;
  74784. private _target;
  74785. private _effectiveTarget;
  74786. private _property;
  74787. /**
  74788. * Instantiate the action
  74789. * @param triggerOptions defines the trigger options
  74790. * @param target defines the object containing the property
  74791. * @param propertyPath defines the path of the property to set in the target
  74792. * @param value defines the value to set in the property
  74793. * @param condition defines the trigger related conditions
  74794. */
  74795. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74796. /** @hidden */
  74797. _prepare(): void;
  74798. /**
  74799. * Execute the action and set the targetted property to the desired value.
  74800. */
  74801. execute(): void;
  74802. /**
  74803. * Serializes the actions and its related information.
  74804. * @param parent defines the object to serialize in
  74805. * @returns the serialized object
  74806. */
  74807. serialize(parent: any): any;
  74808. }
  74809. /**
  74810. * This defines an action responsible to increment the target value
  74811. * to a desired value once triggered.
  74812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74813. */
  74814. export class IncrementValueAction extends Action {
  74815. /**
  74816. * The path of the property to increment in the target.
  74817. */
  74818. propertyPath: string;
  74819. /**
  74820. * The value we should increment the property by.
  74821. */
  74822. value: any;
  74823. private _target;
  74824. private _effectiveTarget;
  74825. private _property;
  74826. /**
  74827. * Instantiate the action
  74828. * @param triggerOptions defines the trigger options
  74829. * @param target defines the object containing the property
  74830. * @param propertyPath defines the path of the property to increment in the target
  74831. * @param value defines the value value we should increment the property by
  74832. * @param condition defines the trigger related conditions
  74833. */
  74834. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74835. /** @hidden */
  74836. _prepare(): void;
  74837. /**
  74838. * Execute the action and increment the target of the value amount.
  74839. */
  74840. execute(): void;
  74841. /**
  74842. * Serializes the actions and its related information.
  74843. * @param parent defines the object to serialize in
  74844. * @returns the serialized object
  74845. */
  74846. serialize(parent: any): any;
  74847. }
  74848. /**
  74849. * This defines an action responsible to start an animation once triggered.
  74850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74851. */
  74852. export class PlayAnimationAction extends Action {
  74853. /**
  74854. * Where the animation should start (animation frame)
  74855. */
  74856. from: number;
  74857. /**
  74858. * Where the animation should stop (animation frame)
  74859. */
  74860. to: number;
  74861. /**
  74862. * Define if the animation should loop or stop after the first play.
  74863. */
  74864. loop?: boolean;
  74865. private _target;
  74866. /**
  74867. * Instantiate the action
  74868. * @param triggerOptions defines the trigger options
  74869. * @param target defines the target animation or animation name
  74870. * @param from defines from where the animation should start (animation frame)
  74871. * @param end defines where the animation should stop (animation frame)
  74872. * @param loop defines if the animation should loop or stop after the first play
  74873. * @param condition defines the trigger related conditions
  74874. */
  74875. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  74876. /** @hidden */
  74877. _prepare(): void;
  74878. /**
  74879. * Execute the action and play the animation.
  74880. */
  74881. execute(): void;
  74882. /**
  74883. * Serializes the actions and its related information.
  74884. * @param parent defines the object to serialize in
  74885. * @returns the serialized object
  74886. */
  74887. serialize(parent: any): any;
  74888. }
  74889. /**
  74890. * This defines an action responsible to stop an animation once triggered.
  74891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74892. */
  74893. export class StopAnimationAction extends Action {
  74894. private _target;
  74895. /**
  74896. * Instantiate the action
  74897. * @param triggerOptions defines the trigger options
  74898. * @param target defines the target animation or animation name
  74899. * @param condition defines the trigger related conditions
  74900. */
  74901. constructor(triggerOptions: any, target: any, condition?: Condition);
  74902. /** @hidden */
  74903. _prepare(): void;
  74904. /**
  74905. * Execute the action and stop the animation.
  74906. */
  74907. execute(): void;
  74908. /**
  74909. * Serializes the actions and its related information.
  74910. * @param parent defines the object to serialize in
  74911. * @returns the serialized object
  74912. */
  74913. serialize(parent: any): any;
  74914. }
  74915. /**
  74916. * This defines an action responsible that does nothing once triggered.
  74917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74918. */
  74919. export class DoNothingAction extends Action {
  74920. /**
  74921. * Instantiate the action
  74922. * @param triggerOptions defines the trigger options
  74923. * @param condition defines the trigger related conditions
  74924. */
  74925. constructor(triggerOptions?: any, condition?: Condition);
  74926. /**
  74927. * Execute the action and do nothing.
  74928. */
  74929. execute(): void;
  74930. /**
  74931. * Serializes the actions and its related information.
  74932. * @param parent defines the object to serialize in
  74933. * @returns the serialized object
  74934. */
  74935. serialize(parent: any): any;
  74936. }
  74937. /**
  74938. * This defines an action responsible to trigger several actions once triggered.
  74939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74940. */
  74941. export class CombineAction extends Action {
  74942. /**
  74943. * The list of aggregated animations to run.
  74944. */
  74945. children: Action[];
  74946. /**
  74947. * Instantiate the action
  74948. * @param triggerOptions defines the trigger options
  74949. * @param children defines the list of aggregated animations to run
  74950. * @param condition defines the trigger related conditions
  74951. */
  74952. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  74953. /** @hidden */
  74954. _prepare(): void;
  74955. /**
  74956. * Execute the action and executes all the aggregated actions.
  74957. */
  74958. execute(evt: ActionEvent): void;
  74959. /**
  74960. * Serializes the actions and its related information.
  74961. * @param parent defines the object to serialize in
  74962. * @returns the serialized object
  74963. */
  74964. serialize(parent: any): any;
  74965. }
  74966. /**
  74967. * This defines an action responsible to run code (external event) once triggered.
  74968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74969. */
  74970. export class ExecuteCodeAction extends Action {
  74971. /**
  74972. * The callback function to run.
  74973. */
  74974. func: (evt: ActionEvent) => void;
  74975. /**
  74976. * Instantiate the action
  74977. * @param triggerOptions defines the trigger options
  74978. * @param func defines the callback function to run
  74979. * @param condition defines the trigger related conditions
  74980. */
  74981. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  74982. /**
  74983. * Execute the action and run the attached code.
  74984. */
  74985. execute(evt: ActionEvent): void;
  74986. }
  74987. /**
  74988. * This defines an action responsible to set the parent property of the target once triggered.
  74989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74990. */
  74991. export class SetParentAction extends Action {
  74992. private _parent;
  74993. private _target;
  74994. /**
  74995. * Instantiate the action
  74996. * @param triggerOptions defines the trigger options
  74997. * @param target defines the target containing the parent property
  74998. * @param parent defines from where the animation should start (animation frame)
  74999. * @param condition defines the trigger related conditions
  75000. */
  75001. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  75002. /** @hidden */
  75003. _prepare(): void;
  75004. /**
  75005. * Execute the action and set the parent property.
  75006. */
  75007. execute(): void;
  75008. /**
  75009. * Serializes the actions and its related information.
  75010. * @param parent defines the object to serialize in
  75011. * @returns the serialized object
  75012. */
  75013. serialize(parent: any): any;
  75014. }
  75015. }
  75016. declare module BABYLON {
  75017. /**
  75018. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  75019. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  75020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75021. */
  75022. export class ActionManager extends AbstractActionManager {
  75023. /**
  75024. * Nothing
  75025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75026. */
  75027. static readonly NothingTrigger: number;
  75028. /**
  75029. * On pick
  75030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75031. */
  75032. static readonly OnPickTrigger: number;
  75033. /**
  75034. * On left pick
  75035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75036. */
  75037. static readonly OnLeftPickTrigger: number;
  75038. /**
  75039. * On right pick
  75040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75041. */
  75042. static readonly OnRightPickTrigger: number;
  75043. /**
  75044. * On center pick
  75045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75046. */
  75047. static readonly OnCenterPickTrigger: number;
  75048. /**
  75049. * On pick down
  75050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75051. */
  75052. static readonly OnPickDownTrigger: number;
  75053. /**
  75054. * On double pick
  75055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75056. */
  75057. static readonly OnDoublePickTrigger: number;
  75058. /**
  75059. * On pick up
  75060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75061. */
  75062. static readonly OnPickUpTrigger: number;
  75063. /**
  75064. * On pick out.
  75065. * This trigger will only be raised if you also declared a OnPickDown
  75066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75067. */
  75068. static readonly OnPickOutTrigger: number;
  75069. /**
  75070. * On long press
  75071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75072. */
  75073. static readonly OnLongPressTrigger: number;
  75074. /**
  75075. * On pointer over
  75076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75077. */
  75078. static readonly OnPointerOverTrigger: number;
  75079. /**
  75080. * On pointer out
  75081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75082. */
  75083. static readonly OnPointerOutTrigger: number;
  75084. /**
  75085. * On every frame
  75086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75087. */
  75088. static readonly OnEveryFrameTrigger: number;
  75089. /**
  75090. * On intersection enter
  75091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75092. */
  75093. static readonly OnIntersectionEnterTrigger: number;
  75094. /**
  75095. * On intersection exit
  75096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75097. */
  75098. static readonly OnIntersectionExitTrigger: number;
  75099. /**
  75100. * On key down
  75101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75102. */
  75103. static readonly OnKeyDownTrigger: number;
  75104. /**
  75105. * On key up
  75106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75107. */
  75108. static readonly OnKeyUpTrigger: number;
  75109. private _scene;
  75110. /**
  75111. * Creates a new action manager
  75112. * @param scene defines the hosting scene
  75113. */
  75114. constructor(scene: Scene);
  75115. /**
  75116. * Releases all associated resources
  75117. */
  75118. dispose(): void;
  75119. /**
  75120. * Gets hosting scene
  75121. * @returns the hosting scene
  75122. */
  75123. getScene(): Scene;
  75124. /**
  75125. * Does this action manager handles actions of any of the given triggers
  75126. * @param triggers defines the triggers to be tested
  75127. * @return a boolean indicating whether one (or more) of the triggers is handled
  75128. */
  75129. hasSpecificTriggers(triggers: number[]): boolean;
  75130. /**
  75131. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  75132. * speed.
  75133. * @param triggerA defines the trigger to be tested
  75134. * @param triggerB defines the trigger to be tested
  75135. * @return a boolean indicating whether one (or more) of the triggers is handled
  75136. */
  75137. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  75138. /**
  75139. * Does this action manager handles actions of a given trigger
  75140. * @param trigger defines the trigger to be tested
  75141. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  75142. * @return whether the trigger is handled
  75143. */
  75144. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  75145. /**
  75146. * Does this action manager has pointer triggers
  75147. */
  75148. readonly hasPointerTriggers: boolean;
  75149. /**
  75150. * Does this action manager has pick triggers
  75151. */
  75152. readonly hasPickTriggers: boolean;
  75153. /**
  75154. * Registers an action to this action manager
  75155. * @param action defines the action to be registered
  75156. * @return the action amended (prepared) after registration
  75157. */
  75158. registerAction(action: IAction): Nullable<IAction>;
  75159. /**
  75160. * Unregisters an action to this action manager
  75161. * @param action defines the action to be unregistered
  75162. * @return a boolean indicating whether the action has been unregistered
  75163. */
  75164. unregisterAction(action: IAction): Boolean;
  75165. /**
  75166. * Process a specific trigger
  75167. * @param trigger defines the trigger to process
  75168. * @param evt defines the event details to be processed
  75169. */
  75170. processTrigger(trigger: number, evt?: IActionEvent): void;
  75171. /** @hidden */
  75172. _getEffectiveTarget(target: any, propertyPath: string): any;
  75173. /** @hidden */
  75174. _getProperty(propertyPath: string): string;
  75175. /**
  75176. * Serialize this manager to a JSON object
  75177. * @param name defines the property name to store this manager
  75178. * @returns a JSON representation of this manager
  75179. */
  75180. serialize(name: string): any;
  75181. /**
  75182. * Creates a new ActionManager from a JSON data
  75183. * @param parsedActions defines the JSON data to read from
  75184. * @param object defines the hosting mesh
  75185. * @param scene defines the hosting scene
  75186. */
  75187. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  75188. /**
  75189. * Get a trigger name by index
  75190. * @param trigger defines the trigger index
  75191. * @returns a trigger name
  75192. */
  75193. static GetTriggerName(trigger: number): string;
  75194. }
  75195. }
  75196. declare module BABYLON {
  75197. /**
  75198. * Class representing a ray with position and direction
  75199. */
  75200. export class Ray {
  75201. /** origin point */
  75202. origin: Vector3;
  75203. /** direction */
  75204. direction: Vector3;
  75205. /** length of the ray */
  75206. length: number;
  75207. private static readonly TmpVector3;
  75208. private _tmpRay;
  75209. /**
  75210. * Creates a new ray
  75211. * @param origin origin point
  75212. * @param direction direction
  75213. * @param length length of the ray
  75214. */
  75215. constructor(
  75216. /** origin point */
  75217. origin: Vector3,
  75218. /** direction */
  75219. direction: Vector3,
  75220. /** length of the ray */
  75221. length?: number);
  75222. /**
  75223. * Checks if the ray intersects a box
  75224. * @param minimum bound of the box
  75225. * @param maximum bound of the box
  75226. * @param intersectionTreshold extra extend to be added to the box in all direction
  75227. * @returns if the box was hit
  75228. */
  75229. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  75230. /**
  75231. * Checks if the ray intersects a box
  75232. * @param box the bounding box to check
  75233. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  75234. * @returns if the box was hit
  75235. */
  75236. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  75237. /**
  75238. * If the ray hits a sphere
  75239. * @param sphere the bounding sphere to check
  75240. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  75241. * @returns true if it hits the sphere
  75242. */
  75243. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  75244. /**
  75245. * If the ray hits a triange
  75246. * @param vertex0 triangle vertex
  75247. * @param vertex1 triangle vertex
  75248. * @param vertex2 triangle vertex
  75249. * @returns intersection information if hit
  75250. */
  75251. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  75252. /**
  75253. * Checks if ray intersects a plane
  75254. * @param plane the plane to check
  75255. * @returns the distance away it was hit
  75256. */
  75257. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  75258. /**
  75259. * Calculate the intercept of a ray on a given axis
  75260. * @param axis to check 'x' | 'y' | 'z'
  75261. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  75262. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  75263. */
  75264. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  75265. /**
  75266. * Checks if ray intersects a mesh
  75267. * @param mesh the mesh to check
  75268. * @param fastCheck if only the bounding box should checked
  75269. * @returns picking info of the intersecton
  75270. */
  75271. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  75272. /**
  75273. * Checks if ray intersects a mesh
  75274. * @param meshes the meshes to check
  75275. * @param fastCheck if only the bounding box should checked
  75276. * @param results array to store result in
  75277. * @returns Array of picking infos
  75278. */
  75279. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  75280. private _comparePickingInfo;
  75281. private static smallnum;
  75282. private static rayl;
  75283. /**
  75284. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  75285. * @param sega the first point of the segment to test the intersection against
  75286. * @param segb the second point of the segment to test the intersection against
  75287. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  75288. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  75289. */
  75290. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  75291. /**
  75292. * Update the ray from viewport position
  75293. * @param x position
  75294. * @param y y position
  75295. * @param viewportWidth viewport width
  75296. * @param viewportHeight viewport height
  75297. * @param world world matrix
  75298. * @param view view matrix
  75299. * @param projection projection matrix
  75300. * @returns this ray updated
  75301. */
  75302. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75303. /**
  75304. * Creates a ray with origin and direction of 0,0,0
  75305. * @returns the new ray
  75306. */
  75307. static Zero(): Ray;
  75308. /**
  75309. * Creates a new ray from screen space and viewport
  75310. * @param x position
  75311. * @param y y position
  75312. * @param viewportWidth viewport width
  75313. * @param viewportHeight viewport height
  75314. * @param world world matrix
  75315. * @param view view matrix
  75316. * @param projection projection matrix
  75317. * @returns new ray
  75318. */
  75319. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75320. /**
  75321. * 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
  75322. * transformed to the given world matrix.
  75323. * @param origin The origin point
  75324. * @param end The end point
  75325. * @param world a matrix to transform the ray to. Default is the identity matrix.
  75326. * @returns the new ray
  75327. */
  75328. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  75329. /**
  75330. * Transforms a ray by a matrix
  75331. * @param ray ray to transform
  75332. * @param matrix matrix to apply
  75333. * @returns the resulting new ray
  75334. */
  75335. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  75336. /**
  75337. * Transforms a ray by a matrix
  75338. * @param ray ray to transform
  75339. * @param matrix matrix to apply
  75340. * @param result ray to store result in
  75341. */
  75342. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  75343. /**
  75344. * Unproject a ray from screen space to object space
  75345. * @param sourceX defines the screen space x coordinate to use
  75346. * @param sourceY defines the screen space y coordinate to use
  75347. * @param viewportWidth defines the current width of the viewport
  75348. * @param viewportHeight defines the current height of the viewport
  75349. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75350. * @param view defines the view matrix to use
  75351. * @param projection defines the projection matrix to use
  75352. */
  75353. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  75354. }
  75355. /**
  75356. * Type used to define predicate used to select faces when a mesh intersection is detected
  75357. */
  75358. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  75359. interface Scene {
  75360. /** @hidden */
  75361. _tempPickingRay: Nullable<Ray>;
  75362. /** @hidden */
  75363. _cachedRayForTransform: Ray;
  75364. /** @hidden */
  75365. _pickWithRayInverseMatrix: Matrix;
  75366. /** @hidden */
  75367. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  75368. /** @hidden */
  75369. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  75370. }
  75371. }
  75372. declare module BABYLON {
  75373. /**
  75374. * Groups all the scene component constants in one place to ease maintenance.
  75375. * @hidden
  75376. */
  75377. export class SceneComponentConstants {
  75378. static readonly NAME_EFFECTLAYER: string;
  75379. static readonly NAME_LAYER: string;
  75380. static readonly NAME_LENSFLARESYSTEM: string;
  75381. static readonly NAME_BOUNDINGBOXRENDERER: string;
  75382. static readonly NAME_PARTICLESYSTEM: string;
  75383. static readonly NAME_GAMEPAD: string;
  75384. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  75385. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  75386. static readonly NAME_DEPTHRENDERER: string;
  75387. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  75388. static readonly NAME_SPRITE: string;
  75389. static readonly NAME_OUTLINERENDERER: string;
  75390. static readonly NAME_PROCEDURALTEXTURE: string;
  75391. static readonly NAME_SHADOWGENERATOR: string;
  75392. static readonly NAME_OCTREE: string;
  75393. static readonly NAME_PHYSICSENGINE: string;
  75394. static readonly NAME_AUDIO: string;
  75395. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  75396. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75397. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  75398. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75399. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  75400. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  75401. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  75402. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  75403. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  75404. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  75405. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  75406. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  75407. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  75408. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  75409. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  75410. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  75411. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  75412. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  75413. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  75414. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  75415. static readonly STEP_AFTERRENDER_AUDIO: number;
  75416. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  75417. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  75418. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  75419. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  75420. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  75421. static readonly STEP_POINTERMOVE_SPRITE: number;
  75422. static readonly STEP_POINTERDOWN_SPRITE: number;
  75423. static readonly STEP_POINTERUP_SPRITE: number;
  75424. }
  75425. /**
  75426. * This represents a scene component.
  75427. *
  75428. * This is used to decouple the dependency the scene is having on the different workloads like
  75429. * layers, post processes...
  75430. */
  75431. export interface ISceneComponent {
  75432. /**
  75433. * The name of the component. Each component must have a unique name.
  75434. */
  75435. name: string;
  75436. /**
  75437. * The scene the component belongs to.
  75438. */
  75439. scene: Scene;
  75440. /**
  75441. * Register the component to one instance of a scene.
  75442. */
  75443. register(): void;
  75444. /**
  75445. * Rebuilds the elements related to this component in case of
  75446. * context lost for instance.
  75447. */
  75448. rebuild(): void;
  75449. /**
  75450. * Disposes the component and the associated ressources.
  75451. */
  75452. dispose(): void;
  75453. }
  75454. /**
  75455. * This represents a SERIALIZABLE scene component.
  75456. *
  75457. * This extends Scene Component to add Serialization methods on top.
  75458. */
  75459. export interface ISceneSerializableComponent extends ISceneComponent {
  75460. /**
  75461. * Adds all the elements from the container to the scene
  75462. * @param container the container holding the elements
  75463. */
  75464. addFromContainer(container: AbstractScene): void;
  75465. /**
  75466. * Removes all the elements in the container from the scene
  75467. * @param container contains the elements to remove
  75468. * @param dispose if the removed element should be disposed (default: false)
  75469. */
  75470. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75471. /**
  75472. * Serializes the component data to the specified json object
  75473. * @param serializationObject The object to serialize to
  75474. */
  75475. serialize(serializationObject: any): void;
  75476. }
  75477. /**
  75478. * Strong typing of a Mesh related stage step action
  75479. */
  75480. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  75481. /**
  75482. * Strong typing of a Evaluate Sub Mesh related stage step action
  75483. */
  75484. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  75485. /**
  75486. * Strong typing of a Active Mesh related stage step action
  75487. */
  75488. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  75489. /**
  75490. * Strong typing of a Camera related stage step action
  75491. */
  75492. export type CameraStageAction = (camera: Camera) => void;
  75493. /**
  75494. * Strong typing of a Camera Frame buffer related stage step action
  75495. */
  75496. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  75497. /**
  75498. * Strong typing of a Render Target related stage step action
  75499. */
  75500. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  75501. /**
  75502. * Strong typing of a RenderingGroup related stage step action
  75503. */
  75504. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  75505. /**
  75506. * Strong typing of a Mesh Render related stage step action
  75507. */
  75508. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  75509. /**
  75510. * Strong typing of a simple stage step action
  75511. */
  75512. export type SimpleStageAction = () => void;
  75513. /**
  75514. * Strong typing of a render target action.
  75515. */
  75516. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  75517. /**
  75518. * Strong typing of a pointer move action.
  75519. */
  75520. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  75521. /**
  75522. * Strong typing of a pointer up/down action.
  75523. */
  75524. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  75525. /**
  75526. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  75527. * @hidden
  75528. */
  75529. export class Stage<T extends Function> extends Array<{
  75530. index: number;
  75531. component: ISceneComponent;
  75532. action: T;
  75533. }> {
  75534. /**
  75535. * Hide ctor from the rest of the world.
  75536. * @param items The items to add.
  75537. */
  75538. private constructor();
  75539. /**
  75540. * Creates a new Stage.
  75541. * @returns A new instance of a Stage
  75542. */
  75543. static Create<T extends Function>(): Stage<T>;
  75544. /**
  75545. * Registers a step in an ordered way in the targeted stage.
  75546. * @param index Defines the position to register the step in
  75547. * @param component Defines the component attached to the step
  75548. * @param action Defines the action to launch during the step
  75549. */
  75550. registerStep(index: number, component: ISceneComponent, action: T): void;
  75551. /**
  75552. * Clears all the steps from the stage.
  75553. */
  75554. clear(): void;
  75555. }
  75556. }
  75557. declare module BABYLON {
  75558. interface Scene {
  75559. /** @hidden */
  75560. _pointerOverSprite: Nullable<Sprite>;
  75561. /** @hidden */
  75562. _pickedDownSprite: Nullable<Sprite>;
  75563. /** @hidden */
  75564. _tempSpritePickingRay: Nullable<Ray>;
  75565. /**
  75566. * All of the sprite managers added to this scene
  75567. * @see http://doc.babylonjs.com/babylon101/sprites
  75568. */
  75569. spriteManagers: Array<ISpriteManager>;
  75570. /**
  75571. * An event triggered when sprites rendering is about to start
  75572. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75573. */
  75574. onBeforeSpritesRenderingObservable: Observable<Scene>;
  75575. /**
  75576. * An event triggered when sprites rendering is done
  75577. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75578. */
  75579. onAfterSpritesRenderingObservable: Observable<Scene>;
  75580. /** @hidden */
  75581. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75582. /** Launch a ray to try to pick a sprite in the scene
  75583. * @param x position on screen
  75584. * @param y position on screen
  75585. * @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
  75586. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75587. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  75588. * @returns a PickingInfo
  75589. */
  75590. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75591. /** Use the given ray to pick a sprite in the scene
  75592. * @param ray The ray (in world space) to use to pick meshes
  75593. * @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
  75594. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75595. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  75596. * @returns a PickingInfo
  75597. */
  75598. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75599. /**
  75600. * Force the sprite under the pointer
  75601. * @param sprite defines the sprite to use
  75602. */
  75603. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  75604. /**
  75605. * Gets the sprite under the pointer
  75606. * @returns a Sprite or null if no sprite is under the pointer
  75607. */
  75608. getPointerOverSprite(): Nullable<Sprite>;
  75609. }
  75610. /**
  75611. * Defines the sprite scene component responsible to manage sprites
  75612. * in a given scene.
  75613. */
  75614. export class SpriteSceneComponent implements ISceneComponent {
  75615. /**
  75616. * The component name helpfull to identify the component in the list of scene components.
  75617. */
  75618. readonly name: string;
  75619. /**
  75620. * The scene the component belongs to.
  75621. */
  75622. scene: Scene;
  75623. /** @hidden */
  75624. private _spritePredicate;
  75625. /**
  75626. * Creates a new instance of the component for the given scene
  75627. * @param scene Defines the scene to register the component in
  75628. */
  75629. constructor(scene: Scene);
  75630. /**
  75631. * Registers the component in a given scene
  75632. */
  75633. register(): void;
  75634. /**
  75635. * Rebuilds the elements related to this component in case of
  75636. * context lost for instance.
  75637. */
  75638. rebuild(): void;
  75639. /**
  75640. * Disposes the component and the associated ressources.
  75641. */
  75642. dispose(): void;
  75643. private _pickSpriteButKeepRay;
  75644. private _pointerMove;
  75645. private _pointerDown;
  75646. private _pointerUp;
  75647. }
  75648. }
  75649. declare module BABYLON {
  75650. /** @hidden */
  75651. export var fogFragmentDeclaration: {
  75652. name: string;
  75653. shader: string;
  75654. };
  75655. }
  75656. declare module BABYLON {
  75657. /** @hidden */
  75658. export var fogFragment: {
  75659. name: string;
  75660. shader: string;
  75661. };
  75662. }
  75663. declare module BABYLON {
  75664. /** @hidden */
  75665. export var spritesPixelShader: {
  75666. name: string;
  75667. shader: string;
  75668. };
  75669. }
  75670. declare module BABYLON {
  75671. /** @hidden */
  75672. export var fogVertexDeclaration: {
  75673. name: string;
  75674. shader: string;
  75675. };
  75676. }
  75677. declare module BABYLON {
  75678. /** @hidden */
  75679. export var spritesVertexShader: {
  75680. name: string;
  75681. shader: string;
  75682. };
  75683. }
  75684. declare module BABYLON {
  75685. /**
  75686. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75687. */
  75688. export interface ISpriteManager extends IDisposable {
  75689. /**
  75690. * Restricts the camera to viewing objects with the same layerMask.
  75691. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75692. */
  75693. layerMask: number;
  75694. /**
  75695. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75696. */
  75697. isPickable: boolean;
  75698. /**
  75699. * Specifies the rendering group id for this mesh (0 by default)
  75700. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75701. */
  75702. renderingGroupId: number;
  75703. /**
  75704. * Defines the list of sprites managed by the manager.
  75705. */
  75706. sprites: Array<Sprite>;
  75707. /**
  75708. * Tests the intersection of a sprite with a specific ray.
  75709. * @param ray The ray we are sending to test the collision
  75710. * @param camera The camera space we are sending rays in
  75711. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75712. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75713. * @returns picking info or null.
  75714. */
  75715. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75716. /**
  75717. * Renders the list of sprites on screen.
  75718. */
  75719. render(): void;
  75720. }
  75721. /**
  75722. * Class used to manage multiple sprites on the same spritesheet
  75723. * @see http://doc.babylonjs.com/babylon101/sprites
  75724. */
  75725. export class SpriteManager implements ISpriteManager {
  75726. /** defines the manager's name */
  75727. name: string;
  75728. /** Gets the list of sprites */
  75729. sprites: Sprite[];
  75730. /** Gets or sets the rendering group id (0 by default) */
  75731. renderingGroupId: number;
  75732. /** Gets or sets camera layer mask */
  75733. layerMask: number;
  75734. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75735. fogEnabled: boolean;
  75736. /** Gets or sets a boolean indicating if the sprites are pickable */
  75737. isPickable: boolean;
  75738. /** Defines the default width of a cell in the spritesheet */
  75739. cellWidth: number;
  75740. /** Defines the default height of a cell in the spritesheet */
  75741. cellHeight: number;
  75742. /**
  75743. * An event triggered when the manager is disposed.
  75744. */
  75745. onDisposeObservable: Observable<SpriteManager>;
  75746. private _onDisposeObserver;
  75747. /**
  75748. * Callback called when the manager is disposed
  75749. */
  75750. onDispose: () => void;
  75751. private _capacity;
  75752. private _spriteTexture;
  75753. private _epsilon;
  75754. private _scene;
  75755. private _vertexData;
  75756. private _buffer;
  75757. private _vertexBuffers;
  75758. private _indexBuffer;
  75759. private _effectBase;
  75760. private _effectFog;
  75761. /**
  75762. * Gets or sets the spritesheet texture
  75763. */
  75764. texture: Texture;
  75765. /**
  75766. * Creates a new sprite manager
  75767. * @param name defines the manager's name
  75768. * @param imgUrl defines the sprite sheet url
  75769. * @param capacity defines the maximum allowed number of sprites
  75770. * @param cellSize defines the size of a sprite cell
  75771. * @param scene defines the hosting scene
  75772. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75773. * @param samplingMode defines the smapling mode to use with spritesheet
  75774. */
  75775. constructor(
  75776. /** defines the manager's name */
  75777. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  75778. private _appendSpriteVertex;
  75779. /**
  75780. * Intersects the sprites with a ray
  75781. * @param ray defines the ray to intersect with
  75782. * @param camera defines the current active camera
  75783. * @param predicate defines a predicate used to select candidate sprites
  75784. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75785. * @returns null if no hit or a PickingInfo
  75786. */
  75787. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75788. /**
  75789. * Render all child sprites
  75790. */
  75791. render(): void;
  75792. /**
  75793. * Release associated resources
  75794. */
  75795. dispose(): void;
  75796. }
  75797. }
  75798. declare module BABYLON {
  75799. /**
  75800. * Class used to represent a sprite
  75801. * @see http://doc.babylonjs.com/babylon101/sprites
  75802. */
  75803. export class Sprite {
  75804. /** defines the name */
  75805. name: string;
  75806. /** Gets or sets the current world position */
  75807. position: Vector3;
  75808. /** Gets or sets the main color */
  75809. color: Color4;
  75810. /** Gets or sets the width */
  75811. width: number;
  75812. /** Gets or sets the height */
  75813. height: number;
  75814. /** Gets or sets rotation angle */
  75815. angle: number;
  75816. /** Gets or sets the cell index in the sprite sheet */
  75817. cellIndex: number;
  75818. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75819. invertU: number;
  75820. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75821. invertV: number;
  75822. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75823. disposeWhenFinishedAnimating: boolean;
  75824. /** Gets the list of attached animations */
  75825. animations: Animation[];
  75826. /** Gets or sets a boolean indicating if the sprite can be picked */
  75827. isPickable: boolean;
  75828. /**
  75829. * Gets or sets the associated action manager
  75830. */
  75831. actionManager: Nullable<ActionManager>;
  75832. private _animationStarted;
  75833. private _loopAnimation;
  75834. private _fromIndex;
  75835. private _toIndex;
  75836. private _delay;
  75837. private _direction;
  75838. private _manager;
  75839. private _time;
  75840. private _onAnimationEnd;
  75841. /**
  75842. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  75843. */
  75844. isVisible: boolean;
  75845. /**
  75846. * Gets or sets the sprite size
  75847. */
  75848. size: number;
  75849. /**
  75850. * Creates a new Sprite
  75851. * @param name defines the name
  75852. * @param manager defines the manager
  75853. */
  75854. constructor(
  75855. /** defines the name */
  75856. name: string, manager: ISpriteManager);
  75857. /**
  75858. * Starts an animation
  75859. * @param from defines the initial key
  75860. * @param to defines the end key
  75861. * @param loop defines if the animation must loop
  75862. * @param delay defines the start delay (in ms)
  75863. * @param onAnimationEnd defines a callback to call when animation ends
  75864. */
  75865. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  75866. /** Stops current animation (if any) */
  75867. stopAnimation(): void;
  75868. /** @hidden */
  75869. _animate(deltaTime: number): void;
  75870. /** Release associated resources */
  75871. dispose(): void;
  75872. }
  75873. }
  75874. declare module BABYLON {
  75875. /**
  75876. * Information about the result of picking within a scene
  75877. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  75878. */
  75879. export class PickingInfo {
  75880. /** @hidden */
  75881. _pickingUnavailable: boolean;
  75882. /**
  75883. * If the pick collided with an object
  75884. */
  75885. hit: boolean;
  75886. /**
  75887. * Distance away where the pick collided
  75888. */
  75889. distance: number;
  75890. /**
  75891. * The location of pick collision
  75892. */
  75893. pickedPoint: Nullable<Vector3>;
  75894. /**
  75895. * The mesh corresponding the the pick collision
  75896. */
  75897. pickedMesh: Nullable<AbstractMesh>;
  75898. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  75899. bu: number;
  75900. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  75901. bv: number;
  75902. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  75903. faceId: number;
  75904. /** Id of the the submesh that was picked */
  75905. subMeshId: number;
  75906. /** If a sprite was picked, this will be the sprite the pick collided with */
  75907. pickedSprite: Nullable<Sprite>;
  75908. /**
  75909. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  75910. */
  75911. originMesh: Nullable<AbstractMesh>;
  75912. /**
  75913. * The ray that was used to perform the picking.
  75914. */
  75915. ray: Nullable<Ray>;
  75916. /**
  75917. * Gets the normal correspodning to the face the pick collided with
  75918. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  75919. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  75920. * @returns The normal correspodning to the face the pick collided with
  75921. */
  75922. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  75923. /**
  75924. * Gets the texture coordinates of where the pick occured
  75925. * @returns the vector containing the coordnates of the texture
  75926. */
  75927. getTextureCoordinates(): Nullable<Vector2>;
  75928. }
  75929. }
  75930. declare module BABYLON {
  75931. /**
  75932. * Gather the list of pointer event types as constants.
  75933. */
  75934. export class PointerEventTypes {
  75935. /**
  75936. * 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.
  75937. */
  75938. static readonly POINTERDOWN: number;
  75939. /**
  75940. * The pointerup event is fired when a pointer is no longer active.
  75941. */
  75942. static readonly POINTERUP: number;
  75943. /**
  75944. * The pointermove event is fired when a pointer changes coordinates.
  75945. */
  75946. static readonly POINTERMOVE: number;
  75947. /**
  75948. * The pointerwheel event is fired when a mouse wheel has been rotated.
  75949. */
  75950. static readonly POINTERWHEEL: number;
  75951. /**
  75952. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  75953. */
  75954. static readonly POINTERPICK: number;
  75955. /**
  75956. * The pointertap event is fired when a the object has been touched and released without drag.
  75957. */
  75958. static readonly POINTERTAP: number;
  75959. /**
  75960. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  75961. */
  75962. static readonly POINTERDOUBLETAP: number;
  75963. }
  75964. /**
  75965. * Base class of pointer info types.
  75966. */
  75967. export class PointerInfoBase {
  75968. /**
  75969. * Defines the type of event (PointerEventTypes)
  75970. */
  75971. type: number;
  75972. /**
  75973. * Defines the related dom event
  75974. */
  75975. event: PointerEvent | MouseWheelEvent;
  75976. /**
  75977. * Instantiates the base class of pointers info.
  75978. * @param type Defines the type of event (PointerEventTypes)
  75979. * @param event Defines the related dom event
  75980. */
  75981. constructor(
  75982. /**
  75983. * Defines the type of event (PointerEventTypes)
  75984. */
  75985. type: number,
  75986. /**
  75987. * Defines the related dom event
  75988. */
  75989. event: PointerEvent | MouseWheelEvent);
  75990. }
  75991. /**
  75992. * This class is used to store pointer related info for the onPrePointerObservable event.
  75993. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  75994. */
  75995. export class PointerInfoPre extends PointerInfoBase {
  75996. /**
  75997. * Ray from a pointer if availible (eg. 6dof controller)
  75998. */
  75999. ray: Nullable<Ray>;
  76000. /**
  76001. * Defines the local position of the pointer on the canvas.
  76002. */
  76003. localPosition: Vector2;
  76004. /**
  76005. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  76006. */
  76007. skipOnPointerObservable: boolean;
  76008. /**
  76009. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  76010. * @param type Defines the type of event (PointerEventTypes)
  76011. * @param event Defines the related dom event
  76012. * @param localX Defines the local x coordinates of the pointer when the event occured
  76013. * @param localY Defines the local y coordinates of the pointer when the event occured
  76014. */
  76015. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  76016. }
  76017. /**
  76018. * This type contains all the data related to a pointer event in Babylon.js.
  76019. * 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.
  76020. */
  76021. export class PointerInfo extends PointerInfoBase {
  76022. /**
  76023. * Defines the picking info associated to the info (if any)\
  76024. */
  76025. pickInfo: Nullable<PickingInfo>;
  76026. /**
  76027. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  76028. * @param type Defines the type of event (PointerEventTypes)
  76029. * @param event Defines the related dom event
  76030. * @param pickInfo Defines the picking info associated to the info (if any)\
  76031. */
  76032. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  76033. /**
  76034. * Defines the picking info associated to the info (if any)\
  76035. */
  76036. pickInfo: Nullable<PickingInfo>);
  76037. }
  76038. /**
  76039. * Data relating to a touch event on the screen.
  76040. */
  76041. export interface PointerTouch {
  76042. /**
  76043. * X coordinate of touch.
  76044. */
  76045. x: number;
  76046. /**
  76047. * Y coordinate of touch.
  76048. */
  76049. y: number;
  76050. /**
  76051. * Id of touch. Unique for each finger.
  76052. */
  76053. pointerId: number;
  76054. /**
  76055. * Event type passed from DOM.
  76056. */
  76057. type: any;
  76058. }
  76059. }
  76060. declare module BABYLON {
  76061. /**
  76062. * Manage the mouse inputs to control the movement of a free camera.
  76063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76064. */
  76065. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  76066. /**
  76067. * Define if touch is enabled in the mouse input
  76068. */
  76069. touchEnabled: boolean;
  76070. /**
  76071. * Defines the camera the input is attached to.
  76072. */
  76073. camera: FreeCamera;
  76074. /**
  76075. * Defines the buttons associated with the input to handle camera move.
  76076. */
  76077. buttons: number[];
  76078. /**
  76079. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  76080. */
  76081. angularSensibility: number;
  76082. private _pointerInput;
  76083. private _onMouseMove;
  76084. private _observer;
  76085. private previousPosition;
  76086. /**
  76087. * Observable for when a pointer move event occurs containing the move offset
  76088. */
  76089. onPointerMovedObservable: Observable<{
  76090. offsetX: number;
  76091. offsetY: number;
  76092. }>;
  76093. /**
  76094. * @hidden
  76095. * If the camera should be rotated automatically based on pointer movement
  76096. */
  76097. _allowCameraRotation: boolean;
  76098. /**
  76099. * Manage the mouse inputs to control the movement of a free camera.
  76100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76101. * @param touchEnabled Defines if touch is enabled or not
  76102. */
  76103. constructor(
  76104. /**
  76105. * Define if touch is enabled in the mouse input
  76106. */
  76107. touchEnabled?: boolean);
  76108. /**
  76109. * Attach the input controls to a specific dom element to get the input from.
  76110. * @param element Defines the element the controls should be listened from
  76111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76112. */
  76113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76114. /**
  76115. * Called on JS contextmenu event.
  76116. * Override this method to provide functionality.
  76117. */
  76118. protected onContextMenu(evt: PointerEvent): void;
  76119. /**
  76120. * Detach the current controls from the specified dom element.
  76121. * @param element Defines the element to stop listening the inputs from
  76122. */
  76123. detachControl(element: Nullable<HTMLElement>): void;
  76124. /**
  76125. * Gets the class name of the current intput.
  76126. * @returns the class name
  76127. */
  76128. getClassName(): string;
  76129. /**
  76130. * Get the friendly name associated with the input class.
  76131. * @returns the input friendly name
  76132. */
  76133. getSimpleName(): string;
  76134. }
  76135. }
  76136. declare module BABYLON {
  76137. /**
  76138. * Manage the touch inputs to control the movement of a free camera.
  76139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76140. */
  76141. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  76142. /**
  76143. * Defines the camera the input is attached to.
  76144. */
  76145. camera: FreeCamera;
  76146. /**
  76147. * Defines the touch sensibility for rotation.
  76148. * The higher the faster.
  76149. */
  76150. touchAngularSensibility: number;
  76151. /**
  76152. * Defines the touch sensibility for move.
  76153. * The higher the faster.
  76154. */
  76155. touchMoveSensibility: number;
  76156. private _offsetX;
  76157. private _offsetY;
  76158. private _pointerPressed;
  76159. private _pointerInput;
  76160. private _observer;
  76161. private _onLostFocus;
  76162. /**
  76163. * Attach the input controls to a specific dom element to get the input from.
  76164. * @param element Defines the element the controls should be listened from
  76165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76166. */
  76167. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76168. /**
  76169. * Detach the current controls from the specified dom element.
  76170. * @param element Defines the element to stop listening the inputs from
  76171. */
  76172. detachControl(element: Nullable<HTMLElement>): void;
  76173. /**
  76174. * Update the current camera state depending on the inputs that have been used this frame.
  76175. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76176. */
  76177. checkInputs(): void;
  76178. /**
  76179. * Gets the class name of the current intput.
  76180. * @returns the class name
  76181. */
  76182. getClassName(): string;
  76183. /**
  76184. * Get the friendly name associated with the input class.
  76185. * @returns the input friendly name
  76186. */
  76187. getSimpleName(): string;
  76188. }
  76189. }
  76190. declare module BABYLON {
  76191. /**
  76192. * Default Inputs manager for the FreeCamera.
  76193. * It groups all the default supported inputs for ease of use.
  76194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76195. */
  76196. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  76197. /**
  76198. * @hidden
  76199. */
  76200. _mouseInput: Nullable<FreeCameraMouseInput>;
  76201. /**
  76202. * Instantiates a new FreeCameraInputsManager.
  76203. * @param camera Defines the camera the inputs belong to
  76204. */
  76205. constructor(camera: FreeCamera);
  76206. /**
  76207. * Add keyboard input support to the input manager.
  76208. * @returns the current input manager
  76209. */
  76210. addKeyboard(): FreeCameraInputsManager;
  76211. /**
  76212. * Add mouse input support to the input manager.
  76213. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  76214. * @returns the current input manager
  76215. */
  76216. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  76217. /**
  76218. * Removes the mouse input support from the manager
  76219. * @returns the current input manager
  76220. */
  76221. removeMouse(): FreeCameraInputsManager;
  76222. /**
  76223. * Add touch input support to the input manager.
  76224. * @returns the current input manager
  76225. */
  76226. addTouch(): FreeCameraInputsManager;
  76227. /**
  76228. * Remove all attached input methods from a camera
  76229. */
  76230. clear(): void;
  76231. }
  76232. }
  76233. declare module BABYLON {
  76234. /**
  76235. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76236. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  76237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76238. */
  76239. export class FreeCamera extends TargetCamera {
  76240. /**
  76241. * Define the collision ellipsoid of the camera.
  76242. * This is helpful to simulate a camera body like the player body around the camera
  76243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  76244. */
  76245. ellipsoid: Vector3;
  76246. /**
  76247. * Define an offset for the position of the ellipsoid around the camera.
  76248. * This can be helpful to determine the center of the body near the gravity center of the body
  76249. * instead of its head.
  76250. */
  76251. ellipsoidOffset: Vector3;
  76252. /**
  76253. * Enable or disable collisions of the camera with the rest of the scene objects.
  76254. */
  76255. checkCollisions: boolean;
  76256. /**
  76257. * Enable or disable gravity on the camera.
  76258. */
  76259. applyGravity: boolean;
  76260. /**
  76261. * Define the input manager associated to the camera.
  76262. */
  76263. inputs: FreeCameraInputsManager;
  76264. /**
  76265. * Gets the input sensibility for a mouse input. (default is 2000.0)
  76266. * Higher values reduce sensitivity.
  76267. */
  76268. /**
  76269. * Sets the input sensibility for a mouse input. (default is 2000.0)
  76270. * Higher values reduce sensitivity.
  76271. */
  76272. angularSensibility: number;
  76273. /**
  76274. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76275. */
  76276. keysUp: number[];
  76277. /**
  76278. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76279. */
  76280. keysDown: number[];
  76281. /**
  76282. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76283. */
  76284. keysLeft: number[];
  76285. /**
  76286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76287. */
  76288. keysRight: number[];
  76289. /**
  76290. * Event raised when the camera collide with a mesh in the scene.
  76291. */
  76292. onCollide: (collidedMesh: AbstractMesh) => void;
  76293. private _collider;
  76294. private _needMoveForGravity;
  76295. private _oldPosition;
  76296. private _diffPosition;
  76297. private _newPosition;
  76298. /** @hidden */
  76299. _localDirection: Vector3;
  76300. /** @hidden */
  76301. _transformedDirection: Vector3;
  76302. /**
  76303. * Instantiates a Free Camera.
  76304. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76305. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  76306. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76307. * @param name Define the name of the camera in the scene
  76308. * @param position Define the start position of the camera in the scene
  76309. * @param scene Define the scene the camera belongs to
  76310. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76311. */
  76312. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76313. /**
  76314. * Attached controls to the current camera.
  76315. * @param element Defines the element the controls should be listened from
  76316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76317. */
  76318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76319. /**
  76320. * Detach the current controls from the camera.
  76321. * The camera will stop reacting to inputs.
  76322. * @param element Defines the element to stop listening the inputs from
  76323. */
  76324. detachControl(element: HTMLElement): void;
  76325. private _collisionMask;
  76326. /**
  76327. * Define a collision mask to limit the list of object the camera can collide with
  76328. */
  76329. collisionMask: number;
  76330. /** @hidden */
  76331. _collideWithWorld(displacement: Vector3): void;
  76332. private _onCollisionPositionChange;
  76333. /** @hidden */
  76334. _checkInputs(): void;
  76335. /** @hidden */
  76336. _decideIfNeedsToMove(): boolean;
  76337. /** @hidden */
  76338. _updatePosition(): void;
  76339. /**
  76340. * Destroy the camera and release the current resources hold by it.
  76341. */
  76342. dispose(): void;
  76343. /**
  76344. * Gets the current object class name.
  76345. * @return the class name
  76346. */
  76347. getClassName(): string;
  76348. }
  76349. }
  76350. declare module BABYLON {
  76351. /**
  76352. * Represents a gamepad control stick position
  76353. */
  76354. export class StickValues {
  76355. /**
  76356. * The x component of the control stick
  76357. */
  76358. x: number;
  76359. /**
  76360. * The y component of the control stick
  76361. */
  76362. y: number;
  76363. /**
  76364. * Initializes the gamepad x and y control stick values
  76365. * @param x The x component of the gamepad control stick value
  76366. * @param y The y component of the gamepad control stick value
  76367. */
  76368. constructor(
  76369. /**
  76370. * The x component of the control stick
  76371. */
  76372. x: number,
  76373. /**
  76374. * The y component of the control stick
  76375. */
  76376. y: number);
  76377. }
  76378. /**
  76379. * An interface which manages callbacks for gamepad button changes
  76380. */
  76381. export interface GamepadButtonChanges {
  76382. /**
  76383. * Called when a gamepad has been changed
  76384. */
  76385. changed: boolean;
  76386. /**
  76387. * Called when a gamepad press event has been triggered
  76388. */
  76389. pressChanged: boolean;
  76390. /**
  76391. * Called when a touch event has been triggered
  76392. */
  76393. touchChanged: boolean;
  76394. /**
  76395. * Called when a value has changed
  76396. */
  76397. valueChanged: boolean;
  76398. }
  76399. /**
  76400. * Represents a gamepad
  76401. */
  76402. export class Gamepad {
  76403. /**
  76404. * The id of the gamepad
  76405. */
  76406. id: string;
  76407. /**
  76408. * The index of the gamepad
  76409. */
  76410. index: number;
  76411. /**
  76412. * The browser gamepad
  76413. */
  76414. browserGamepad: any;
  76415. /**
  76416. * Specifies what type of gamepad this represents
  76417. */
  76418. type: number;
  76419. private _leftStick;
  76420. private _rightStick;
  76421. /** @hidden */
  76422. _isConnected: boolean;
  76423. private _leftStickAxisX;
  76424. private _leftStickAxisY;
  76425. private _rightStickAxisX;
  76426. private _rightStickAxisY;
  76427. /**
  76428. * Triggered when the left control stick has been changed
  76429. */
  76430. private _onleftstickchanged;
  76431. /**
  76432. * Triggered when the right control stick has been changed
  76433. */
  76434. private _onrightstickchanged;
  76435. /**
  76436. * Represents a gamepad controller
  76437. */
  76438. static GAMEPAD: number;
  76439. /**
  76440. * Represents a generic controller
  76441. */
  76442. static GENERIC: number;
  76443. /**
  76444. * Represents an XBox controller
  76445. */
  76446. static XBOX: number;
  76447. /**
  76448. * Represents a pose-enabled controller
  76449. */
  76450. static POSE_ENABLED: number;
  76451. /**
  76452. * Represents an Dual Shock controller
  76453. */
  76454. static DUALSHOCK: number;
  76455. /**
  76456. * Specifies whether the left control stick should be Y-inverted
  76457. */
  76458. protected _invertLeftStickY: boolean;
  76459. /**
  76460. * Specifies if the gamepad has been connected
  76461. */
  76462. readonly isConnected: boolean;
  76463. /**
  76464. * Initializes the gamepad
  76465. * @param id The id of the gamepad
  76466. * @param index The index of the gamepad
  76467. * @param browserGamepad The browser gamepad
  76468. * @param leftStickX The x component of the left joystick
  76469. * @param leftStickY The y component of the left joystick
  76470. * @param rightStickX The x component of the right joystick
  76471. * @param rightStickY The y component of the right joystick
  76472. */
  76473. constructor(
  76474. /**
  76475. * The id of the gamepad
  76476. */
  76477. id: string,
  76478. /**
  76479. * The index of the gamepad
  76480. */
  76481. index: number,
  76482. /**
  76483. * The browser gamepad
  76484. */
  76485. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  76486. /**
  76487. * Callback triggered when the left joystick has changed
  76488. * @param callback
  76489. */
  76490. onleftstickchanged(callback: (values: StickValues) => void): void;
  76491. /**
  76492. * Callback triggered when the right joystick has changed
  76493. * @param callback
  76494. */
  76495. onrightstickchanged(callback: (values: StickValues) => void): void;
  76496. /**
  76497. * Gets the left joystick
  76498. */
  76499. /**
  76500. * Sets the left joystick values
  76501. */
  76502. leftStick: StickValues;
  76503. /**
  76504. * Gets the right joystick
  76505. */
  76506. /**
  76507. * Sets the right joystick value
  76508. */
  76509. rightStick: StickValues;
  76510. /**
  76511. * Updates the gamepad joystick positions
  76512. */
  76513. update(): void;
  76514. /**
  76515. * Disposes the gamepad
  76516. */
  76517. dispose(): void;
  76518. }
  76519. /**
  76520. * Represents a generic gamepad
  76521. */
  76522. export class GenericPad extends Gamepad {
  76523. private _buttons;
  76524. private _onbuttondown;
  76525. private _onbuttonup;
  76526. /**
  76527. * Observable triggered when a button has been pressed
  76528. */
  76529. onButtonDownObservable: Observable<number>;
  76530. /**
  76531. * Observable triggered when a button has been released
  76532. */
  76533. onButtonUpObservable: Observable<number>;
  76534. /**
  76535. * Callback triggered when a button has been pressed
  76536. * @param callback Called when a button has been pressed
  76537. */
  76538. onbuttondown(callback: (buttonPressed: number) => void): void;
  76539. /**
  76540. * Callback triggered when a button has been released
  76541. * @param callback Called when a button has been released
  76542. */
  76543. onbuttonup(callback: (buttonReleased: number) => void): void;
  76544. /**
  76545. * Initializes the generic gamepad
  76546. * @param id The id of the generic gamepad
  76547. * @param index The index of the generic gamepad
  76548. * @param browserGamepad The browser gamepad
  76549. */
  76550. constructor(id: string, index: number, browserGamepad: any);
  76551. private _setButtonValue;
  76552. /**
  76553. * Updates the generic gamepad
  76554. */
  76555. update(): void;
  76556. /**
  76557. * Disposes the generic gamepad
  76558. */
  76559. dispose(): void;
  76560. }
  76561. }
  76562. declare module BABYLON {
  76563. interface Engine {
  76564. /**
  76565. * Creates a raw texture
  76566. * @param data defines the data to store in the texture
  76567. * @param width defines the width of the texture
  76568. * @param height defines the height of the texture
  76569. * @param format defines the format of the data
  76570. * @param generateMipMaps defines if the engine should generate the mip levels
  76571. * @param invertY defines if data must be stored with Y axis inverted
  76572. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76573. * @param compression defines the compression used (null by default)
  76574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76575. * @returns the raw texture inside an InternalTexture
  76576. */
  76577. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  76578. /**
  76579. * Update a raw texture
  76580. * @param texture defines the texture to update
  76581. * @param data defines the data to store in the texture
  76582. * @param format defines the format of the data
  76583. * @param invertY defines if data must be stored with Y axis inverted
  76584. */
  76585. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76586. /**
  76587. * Update a raw texture
  76588. * @param texture defines the texture to update
  76589. * @param data defines the data to store in the texture
  76590. * @param format defines the format of the data
  76591. * @param invertY defines if data must be stored with Y axis inverted
  76592. * @param compression defines the compression used (null by default)
  76593. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76594. */
  76595. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  76596. /**
  76597. * Creates a new raw cube texture
  76598. * @param data defines the array of data to use to create each face
  76599. * @param size defines the size of the textures
  76600. * @param format defines the format of the data
  76601. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76602. * @param generateMipMaps defines if the engine should generate the mip levels
  76603. * @param invertY defines if data must be stored with Y axis inverted
  76604. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76605. * @param compression defines the compression used (null by default)
  76606. * @returns the cube texture as an InternalTexture
  76607. */
  76608. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  76609. /**
  76610. * Update a raw cube texture
  76611. * @param texture defines the texture to udpdate
  76612. * @param data defines the data to store
  76613. * @param format defines the data format
  76614. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76615. * @param invertY defines if data must be stored with Y axis inverted
  76616. */
  76617. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  76618. /**
  76619. * Update a raw cube texture
  76620. * @param texture defines the texture to udpdate
  76621. * @param data defines the data to store
  76622. * @param format defines the data format
  76623. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76624. * @param invertY defines if data must be stored with Y axis inverted
  76625. * @param compression defines the compression used (null by default)
  76626. */
  76627. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  76628. /**
  76629. * Update a raw cube texture
  76630. * @param texture defines the texture to udpdate
  76631. * @param data defines the data to store
  76632. * @param format defines the data format
  76633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76634. * @param invertY defines if data must be stored with Y axis inverted
  76635. * @param compression defines the compression used (null by default)
  76636. * @param level defines which level of the texture to update
  76637. */
  76638. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76639. /**
  76640. * Creates a new raw cube texture from a specified url
  76641. * @param url defines the url where the data is located
  76642. * @param scene defines the current scene
  76643. * @param size defines the size of the textures
  76644. * @param format defines the format of the data
  76645. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76646. * @param noMipmap defines if the engine should avoid generating the mip levels
  76647. * @param callback defines a callback used to extract texture data from loaded data
  76648. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76649. * @param onLoad defines a callback called when texture is loaded
  76650. * @param onError defines a callback called if there is an error
  76651. * @returns the cube texture as an InternalTexture
  76652. */
  76653. 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;
  76654. /**
  76655. * Creates a new raw cube texture from a specified url
  76656. * @param url defines the url where the data is located
  76657. * @param scene defines the current scene
  76658. * @param size defines the size of the textures
  76659. * @param format defines the format of the data
  76660. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76661. * @param noMipmap defines if the engine should avoid generating the mip levels
  76662. * @param callback defines a callback used to extract texture data from loaded data
  76663. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76664. * @param onLoad defines a callback called when texture is loaded
  76665. * @param onError defines a callback called if there is an error
  76666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76667. * @param invertY defines if data must be stored with Y axis inverted
  76668. * @returns the cube texture as an InternalTexture
  76669. */
  76670. 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;
  76671. /**
  76672. * Creates a new raw 3D texture
  76673. * @param data defines the data used to create the texture
  76674. * @param width defines the width of the texture
  76675. * @param height defines the height of the texture
  76676. * @param depth defines the depth of the texture
  76677. * @param format defines the format of the texture
  76678. * @param generateMipMaps defines if the engine must generate mip levels
  76679. * @param invertY defines if data must be stored with Y axis inverted
  76680. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76681. * @param compression defines the compressed used (can be null)
  76682. * @param textureType defines the compressed used (can be null)
  76683. * @returns a new raw 3D texture (stored in an InternalTexture)
  76684. */
  76685. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76686. /**
  76687. * Update a raw 3D texture
  76688. * @param texture defines the texture to update
  76689. * @param data defines the data to store
  76690. * @param format defines the data format
  76691. * @param invertY defines if data must be stored with Y axis inverted
  76692. */
  76693. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76694. /**
  76695. * Update a raw 3D texture
  76696. * @param texture defines the texture to update
  76697. * @param data defines the data to store
  76698. * @param format defines the data format
  76699. * @param invertY defines if data must be stored with Y axis inverted
  76700. * @param compression defines the used compression (can be null)
  76701. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76702. */
  76703. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76704. }
  76705. }
  76706. declare module BABYLON {
  76707. /**
  76708. * Raw texture can help creating a texture directly from an array of data.
  76709. * This can be super useful if you either get the data from an uncompressed source or
  76710. * if you wish to create your texture pixel by pixel.
  76711. */
  76712. export class RawTexture extends Texture {
  76713. /**
  76714. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76715. */
  76716. format: number;
  76717. private _engine;
  76718. /**
  76719. * Instantiates a new RawTexture.
  76720. * Raw texture can help creating a texture directly from an array of data.
  76721. * This can be super useful if you either get the data from an uncompressed source or
  76722. * if you wish to create your texture pixel by pixel.
  76723. * @param data define the array of data to use to create the texture
  76724. * @param width define the width of the texture
  76725. * @param height define the height of the texture
  76726. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76727. * @param scene define the scene the texture belongs to
  76728. * @param generateMipMaps define whether mip maps should be generated or not
  76729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76731. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76732. */
  76733. constructor(data: ArrayBufferView, width: number, height: number,
  76734. /**
  76735. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76736. */
  76737. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76738. /**
  76739. * Updates the texture underlying data.
  76740. * @param data Define the new data of the texture
  76741. */
  76742. update(data: ArrayBufferView): void;
  76743. /**
  76744. * Creates a luminance texture from some data.
  76745. * @param data Define the texture data
  76746. * @param width Define the width of the texture
  76747. * @param height Define the height of the texture
  76748. * @param scene Define the scene the texture belongs to
  76749. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76750. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76751. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76752. * @returns the luminance texture
  76753. */
  76754. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76755. /**
  76756. * Creates a luminance alpha texture from some data.
  76757. * @param data Define the texture data
  76758. * @param width Define the width of the texture
  76759. * @param height Define the height of the texture
  76760. * @param scene Define the scene the texture belongs to
  76761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76764. * @returns the luminance alpha texture
  76765. */
  76766. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76767. /**
  76768. * Creates an alpha texture from some data.
  76769. * @param data Define the texture data
  76770. * @param width Define the width of the texture
  76771. * @param height Define the height of the texture
  76772. * @param scene Define the scene the texture belongs to
  76773. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76774. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76775. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76776. * @returns the alpha texture
  76777. */
  76778. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76779. /**
  76780. * Creates a RGB texture from some data.
  76781. * @param data Define the texture data
  76782. * @param width Define the width of the texture
  76783. * @param height Define the height of the texture
  76784. * @param scene Define the scene the texture belongs to
  76785. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76786. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76787. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76788. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76789. * @returns the RGB alpha texture
  76790. */
  76791. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76792. /**
  76793. * Creates a RGBA texture from some data.
  76794. * @param data Define the texture data
  76795. * @param width Define the width of the texture
  76796. * @param height Define the height of the texture
  76797. * @param scene Define the scene the texture belongs to
  76798. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76799. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76800. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76801. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76802. * @returns the RGBA texture
  76803. */
  76804. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76805. /**
  76806. * Creates a R texture from some data.
  76807. * @param data Define the texture data
  76808. * @param width Define the width of the texture
  76809. * @param height Define the height of the texture
  76810. * @param scene Define the scene the texture belongs to
  76811. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76812. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76813. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76814. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76815. * @returns the R texture
  76816. */
  76817. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76818. }
  76819. }
  76820. declare module BABYLON {
  76821. /**
  76822. * Interface for the size containing width and height
  76823. */
  76824. export interface ISize {
  76825. /**
  76826. * Width
  76827. */
  76828. width: number;
  76829. /**
  76830. * Heighht
  76831. */
  76832. height: number;
  76833. }
  76834. /**
  76835. * Size containing widht and height
  76836. */
  76837. export class Size implements ISize {
  76838. /**
  76839. * Width
  76840. */
  76841. width: number;
  76842. /**
  76843. * Height
  76844. */
  76845. height: number;
  76846. /**
  76847. * Creates a Size object from the given width and height (floats).
  76848. * @param width width of the new size
  76849. * @param height height of the new size
  76850. */
  76851. constructor(width: number, height: number);
  76852. /**
  76853. * Returns a string with the Size width and height
  76854. * @returns a string with the Size width and height
  76855. */
  76856. toString(): string;
  76857. /**
  76858. * "Size"
  76859. * @returns the string "Size"
  76860. */
  76861. getClassName(): string;
  76862. /**
  76863. * Returns the Size hash code.
  76864. * @returns a hash code for a unique width and height
  76865. */
  76866. getHashCode(): number;
  76867. /**
  76868. * Updates the current size from the given one.
  76869. * @param src the given size
  76870. */
  76871. copyFrom(src: Size): void;
  76872. /**
  76873. * Updates in place the current Size from the given floats.
  76874. * @param width width of the new size
  76875. * @param height height of the new size
  76876. * @returns the updated Size.
  76877. */
  76878. copyFromFloats(width: number, height: number): Size;
  76879. /**
  76880. * Updates in place the current Size from the given floats.
  76881. * @param width width to set
  76882. * @param height height to set
  76883. * @returns the updated Size.
  76884. */
  76885. set(width: number, height: number): Size;
  76886. /**
  76887. * Multiplies the width and height by numbers
  76888. * @param w factor to multiple the width by
  76889. * @param h factor to multiple the height by
  76890. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  76891. */
  76892. multiplyByFloats(w: number, h: number): Size;
  76893. /**
  76894. * Clones the size
  76895. * @returns a new Size copied from the given one.
  76896. */
  76897. clone(): Size;
  76898. /**
  76899. * True if the current Size and the given one width and height are strictly equal.
  76900. * @param other the other size to compare against
  76901. * @returns True if the current Size and the given one width and height are strictly equal.
  76902. */
  76903. equals(other: Size): boolean;
  76904. /**
  76905. * The surface of the Size : width * height (float).
  76906. */
  76907. readonly surface: number;
  76908. /**
  76909. * Create a new size of zero
  76910. * @returns a new Size set to (0.0, 0.0)
  76911. */
  76912. static Zero(): Size;
  76913. /**
  76914. * Sums the width and height of two sizes
  76915. * @param otherSize size to add to this size
  76916. * @returns a new Size set as the addition result of the current Size and the given one.
  76917. */
  76918. add(otherSize: Size): Size;
  76919. /**
  76920. * Subtracts the width and height of two
  76921. * @param otherSize size to subtract to this size
  76922. * @returns a new Size set as the subtraction result of the given one from the current Size.
  76923. */
  76924. subtract(otherSize: Size): Size;
  76925. /**
  76926. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  76927. * @param start starting size to lerp between
  76928. * @param end end size to lerp between
  76929. * @param amount amount to lerp between the start and end values
  76930. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  76931. */
  76932. static Lerp(start: Size, end: Size, amount: number): Size;
  76933. }
  76934. }
  76935. declare module BABYLON {
  76936. /**
  76937. * Defines a runtime animation
  76938. */
  76939. export class RuntimeAnimation {
  76940. private _events;
  76941. /**
  76942. * The current frame of the runtime animation
  76943. */
  76944. private _currentFrame;
  76945. /**
  76946. * The animation used by the runtime animation
  76947. */
  76948. private _animation;
  76949. /**
  76950. * The target of the runtime animation
  76951. */
  76952. private _target;
  76953. /**
  76954. * The initiating animatable
  76955. */
  76956. private _host;
  76957. /**
  76958. * The original value of the runtime animation
  76959. */
  76960. private _originalValue;
  76961. /**
  76962. * The original blend value of the runtime animation
  76963. */
  76964. private _originalBlendValue;
  76965. /**
  76966. * The offsets cache of the runtime animation
  76967. */
  76968. private _offsetsCache;
  76969. /**
  76970. * The high limits cache of the runtime animation
  76971. */
  76972. private _highLimitsCache;
  76973. /**
  76974. * Specifies if the runtime animation has been stopped
  76975. */
  76976. private _stopped;
  76977. /**
  76978. * The blending factor of the runtime animation
  76979. */
  76980. private _blendingFactor;
  76981. /**
  76982. * The BabylonJS scene
  76983. */
  76984. private _scene;
  76985. /**
  76986. * The current value of the runtime animation
  76987. */
  76988. private _currentValue;
  76989. /** @hidden */
  76990. _animationState: _IAnimationState;
  76991. /**
  76992. * The active target of the runtime animation
  76993. */
  76994. private _activeTargets;
  76995. private _currentActiveTarget;
  76996. private _directTarget;
  76997. /**
  76998. * The target path of the runtime animation
  76999. */
  77000. private _targetPath;
  77001. /**
  77002. * The weight of the runtime animation
  77003. */
  77004. private _weight;
  77005. /**
  77006. * The ratio offset of the runtime animation
  77007. */
  77008. private _ratioOffset;
  77009. /**
  77010. * The previous delay of the runtime animation
  77011. */
  77012. private _previousDelay;
  77013. /**
  77014. * The previous ratio of the runtime animation
  77015. */
  77016. private _previousRatio;
  77017. private _enableBlending;
  77018. private _keys;
  77019. private _minFrame;
  77020. private _maxFrame;
  77021. private _minValue;
  77022. private _maxValue;
  77023. private _targetIsArray;
  77024. /**
  77025. * Gets the current frame of the runtime animation
  77026. */
  77027. readonly currentFrame: number;
  77028. /**
  77029. * Gets the weight of the runtime animation
  77030. */
  77031. readonly weight: number;
  77032. /**
  77033. * Gets the current value of the runtime animation
  77034. */
  77035. readonly currentValue: any;
  77036. /**
  77037. * Gets the target path of the runtime animation
  77038. */
  77039. readonly targetPath: string;
  77040. /**
  77041. * Gets the actual target of the runtime animation
  77042. */
  77043. readonly target: any;
  77044. /** @hidden */
  77045. _onLoop: () => void;
  77046. /**
  77047. * Create a new RuntimeAnimation object
  77048. * @param target defines the target of the animation
  77049. * @param animation defines the source animation object
  77050. * @param scene defines the hosting scene
  77051. * @param host defines the initiating Animatable
  77052. */
  77053. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77054. private _preparePath;
  77055. /**
  77056. * Gets the animation from the runtime animation
  77057. */
  77058. readonly animation: Animation;
  77059. /**
  77060. * Resets the runtime animation to the beginning
  77061. * @param restoreOriginal defines whether to restore the target property to the original value
  77062. */
  77063. reset(restoreOriginal?: boolean): void;
  77064. /**
  77065. * Specifies if the runtime animation is stopped
  77066. * @returns Boolean specifying if the runtime animation is stopped
  77067. */
  77068. isStopped(): boolean;
  77069. /**
  77070. * Disposes of the runtime animation
  77071. */
  77072. dispose(): void;
  77073. /**
  77074. * Apply the interpolated value to the target
  77075. * @param currentValue defines the value computed by the animation
  77076. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77077. */
  77078. setValue(currentValue: any, weight: number): void;
  77079. private _getOriginalValues;
  77080. private _setValue;
  77081. /**
  77082. * Gets the loop pmode of the runtime animation
  77083. * @returns Loop Mode
  77084. */
  77085. private _getCorrectLoopMode;
  77086. /**
  77087. * Move the current animation to a given frame
  77088. * @param frame defines the frame to move to
  77089. */
  77090. goToFrame(frame: number): void;
  77091. /**
  77092. * @hidden Internal use only
  77093. */
  77094. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77095. /**
  77096. * Execute the current animation
  77097. * @param delay defines the delay to add to the current frame
  77098. * @param from defines the lower bound of the animation range
  77099. * @param to defines the upper bound of the animation range
  77100. * @param loop defines if the current animation must loop
  77101. * @param speedRatio defines the current speed ratio
  77102. * @param weight defines the weight of the animation (default is -1 so no weight)
  77103. * @param onLoop optional callback called when animation loops
  77104. * @returns a boolean indicating if the animation is running
  77105. */
  77106. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  77107. }
  77108. }
  77109. declare module BABYLON {
  77110. /**
  77111. * Class used to store an actual running animation
  77112. */
  77113. export class Animatable {
  77114. /** defines the target object */
  77115. target: any;
  77116. /** defines the starting frame number (default is 0) */
  77117. fromFrame: number;
  77118. /** defines the ending frame number (default is 100) */
  77119. toFrame: number;
  77120. /** defines if the animation must loop (default is false) */
  77121. loopAnimation: boolean;
  77122. /** defines a callback to call when animation ends if it is not looping */
  77123. onAnimationEnd?: (() => void) | null | undefined;
  77124. /** defines a callback to call when animation loops */
  77125. onAnimationLoop?: (() => void) | null | undefined;
  77126. private _localDelayOffset;
  77127. private _pausedDelay;
  77128. private _runtimeAnimations;
  77129. private _paused;
  77130. private _scene;
  77131. private _speedRatio;
  77132. private _weight;
  77133. private _syncRoot;
  77134. /**
  77135. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77136. * This will only apply for non looping animation (default is true)
  77137. */
  77138. disposeOnEnd: boolean;
  77139. /**
  77140. * Gets a boolean indicating if the animation has started
  77141. */
  77142. animationStarted: boolean;
  77143. /**
  77144. * Observer raised when the animation ends
  77145. */
  77146. onAnimationEndObservable: Observable<Animatable>;
  77147. /**
  77148. * Observer raised when the animation loops
  77149. */
  77150. onAnimationLoopObservable: Observable<Animatable>;
  77151. /**
  77152. * Gets the root Animatable used to synchronize and normalize animations
  77153. */
  77154. readonly syncRoot: Nullable<Animatable>;
  77155. /**
  77156. * Gets the current frame of the first RuntimeAnimation
  77157. * Used to synchronize Animatables
  77158. */
  77159. readonly masterFrame: number;
  77160. /**
  77161. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77162. */
  77163. weight: number;
  77164. /**
  77165. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77166. */
  77167. speedRatio: number;
  77168. /**
  77169. * Creates a new Animatable
  77170. * @param scene defines the hosting scene
  77171. * @param target defines the target object
  77172. * @param fromFrame defines the starting frame number (default is 0)
  77173. * @param toFrame defines the ending frame number (default is 100)
  77174. * @param loopAnimation defines if the animation must loop (default is false)
  77175. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77176. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77177. * @param animations defines a group of animation to add to the new Animatable
  77178. * @param onAnimationLoop defines a callback to call when animation loops
  77179. */
  77180. constructor(scene: Scene,
  77181. /** defines the target object */
  77182. target: any,
  77183. /** defines the starting frame number (default is 0) */
  77184. fromFrame?: number,
  77185. /** defines the ending frame number (default is 100) */
  77186. toFrame?: number,
  77187. /** defines if the animation must loop (default is false) */
  77188. loopAnimation?: boolean, speedRatio?: number,
  77189. /** defines a callback to call when animation ends if it is not looping */
  77190. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77191. /** defines a callback to call when animation loops */
  77192. onAnimationLoop?: (() => void) | null | undefined);
  77193. /**
  77194. * Synchronize and normalize current Animatable with a source Animatable
  77195. * This is useful when using animation weights and when animations are not of the same length
  77196. * @param root defines the root Animatable to synchronize with
  77197. * @returns the current Animatable
  77198. */
  77199. syncWith(root: Animatable): Animatable;
  77200. /**
  77201. * Gets the list of runtime animations
  77202. * @returns an array of RuntimeAnimation
  77203. */
  77204. getAnimations(): RuntimeAnimation[];
  77205. /**
  77206. * Adds more animations to the current animatable
  77207. * @param target defines the target of the animations
  77208. * @param animations defines the new animations to add
  77209. */
  77210. appendAnimations(target: any, animations: Animation[]): void;
  77211. /**
  77212. * Gets the source animation for a specific property
  77213. * @param property defines the propertyu to look for
  77214. * @returns null or the source animation for the given property
  77215. */
  77216. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77217. /**
  77218. * Gets the runtime animation for a specific property
  77219. * @param property defines the propertyu to look for
  77220. * @returns null or the runtime animation for the given property
  77221. */
  77222. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77223. /**
  77224. * Resets the animatable to its original state
  77225. */
  77226. reset(): void;
  77227. /**
  77228. * Allows the animatable to blend with current running animations
  77229. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77230. * @param blendingSpeed defines the blending speed to use
  77231. */
  77232. enableBlending(blendingSpeed: number): void;
  77233. /**
  77234. * Disable animation blending
  77235. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77236. */
  77237. disableBlending(): void;
  77238. /**
  77239. * Jump directly to a given frame
  77240. * @param frame defines the frame to jump to
  77241. */
  77242. goToFrame(frame: number): void;
  77243. /**
  77244. * Pause the animation
  77245. */
  77246. pause(): void;
  77247. /**
  77248. * Restart the animation
  77249. */
  77250. restart(): void;
  77251. private _raiseOnAnimationEnd;
  77252. /**
  77253. * Stop and delete the current animation
  77254. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77255. * @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)
  77256. */
  77257. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77258. /**
  77259. * Wait asynchronously for the animation to end
  77260. * @returns a promise which will be fullfilled when the animation ends
  77261. */
  77262. waitAsync(): Promise<Animatable>;
  77263. /** @hidden */
  77264. _animate(delay: number): boolean;
  77265. }
  77266. interface Scene {
  77267. /** @hidden */
  77268. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77269. /** @hidden */
  77270. _processLateAnimationBindingsForMatrices(holder: {
  77271. totalWeight: number;
  77272. animations: RuntimeAnimation[];
  77273. originalValue: Matrix;
  77274. }): any;
  77275. /** @hidden */
  77276. _processLateAnimationBindingsForQuaternions(holder: {
  77277. totalWeight: number;
  77278. animations: RuntimeAnimation[];
  77279. originalValue: Quaternion;
  77280. }, refQuaternion: Quaternion): Quaternion;
  77281. /** @hidden */
  77282. _processLateAnimationBindings(): void;
  77283. /**
  77284. * Will start the animation sequence of a given target
  77285. * @param target defines the target
  77286. * @param from defines from which frame should animation start
  77287. * @param to defines until which frame should animation run.
  77288. * @param weight defines the weight to apply to the animation (1.0 by default)
  77289. * @param loop defines if the animation loops
  77290. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77291. * @param onAnimationEnd defines the function to be executed when the animation ends
  77292. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77293. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77294. * @param onAnimationLoop defines the callback to call when an animation loops
  77295. * @returns the animatable object created for this animation
  77296. */
  77297. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77298. /**
  77299. * Will start the animation sequence of a given target
  77300. * @param target defines the target
  77301. * @param from defines from which frame should animation start
  77302. * @param to defines until which frame should animation run.
  77303. * @param loop defines if the animation loops
  77304. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77305. * @param onAnimationEnd defines the function to be executed when the animation ends
  77306. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77307. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77308. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77309. * @param onAnimationLoop defines the callback to call when an animation loops
  77310. * @returns the animatable object created for this animation
  77311. */
  77312. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77313. /**
  77314. * Will start the animation sequence of a given target and its hierarchy
  77315. * @param target defines the target
  77316. * @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.
  77317. * @param from defines from which frame should animation start
  77318. * @param to defines until which frame should animation run.
  77319. * @param loop defines if the animation loops
  77320. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77321. * @param onAnimationEnd defines the function to be executed when the animation ends
  77322. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77323. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77324. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77325. * @param onAnimationLoop defines the callback to call when an animation loops
  77326. * @returns the list of created animatables
  77327. */
  77328. 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[];
  77329. /**
  77330. * Begin a new animation on a given node
  77331. * @param target defines the target where the animation will take place
  77332. * @param animations defines the list of animations to start
  77333. * @param from defines the initial value
  77334. * @param to defines the final value
  77335. * @param loop defines if you want animation to loop (off by default)
  77336. * @param speedRatio defines the speed ratio to apply to all animations
  77337. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77338. * @param onAnimationLoop defines the callback to call when an animation loops
  77339. * @returns the list of created animatables
  77340. */
  77341. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77342. /**
  77343. * Begin a new animation on a given node and its hierarchy
  77344. * @param target defines the root node where the animation will take place
  77345. * @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.
  77346. * @param animations defines the list of animations to start
  77347. * @param from defines the initial value
  77348. * @param to defines the final value
  77349. * @param loop defines if you want animation to loop (off by default)
  77350. * @param speedRatio defines the speed ratio to apply to all animations
  77351. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77352. * @param onAnimationLoop defines the callback to call when an animation loops
  77353. * @returns the list of animatables created for all nodes
  77354. */
  77355. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77356. /**
  77357. * Gets the animatable associated with a specific target
  77358. * @param target defines the target of the animatable
  77359. * @returns the required animatable if found
  77360. */
  77361. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77362. /**
  77363. * Gets all animatables associated with a given target
  77364. * @param target defines the target to look animatables for
  77365. * @returns an array of Animatables
  77366. */
  77367. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77368. /**
  77369. * Stops and removes all animations that have been applied to the scene
  77370. */
  77371. stopAllAnimations(): void;
  77372. }
  77373. interface Bone {
  77374. /**
  77375. * Copy an animation range from another bone
  77376. * @param source defines the source bone
  77377. * @param rangeName defines the range name to copy
  77378. * @param frameOffset defines the frame offset
  77379. * @param rescaleAsRequired defines if rescaling must be applied if required
  77380. * @param skelDimensionsRatio defines the scaling ratio
  77381. * @returns true if operation was successful
  77382. */
  77383. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77384. }
  77385. }
  77386. declare module BABYLON {
  77387. /**
  77388. * Class used to override all child animations of a given target
  77389. */
  77390. export class AnimationPropertiesOverride {
  77391. /**
  77392. * Gets or sets a value indicating if animation blending must be used
  77393. */
  77394. enableBlending: boolean;
  77395. /**
  77396. * Gets or sets the blending speed to use when enableBlending is true
  77397. */
  77398. blendingSpeed: number;
  77399. /**
  77400. * Gets or sets the default loop mode to use
  77401. */
  77402. loopMode: number;
  77403. }
  77404. }
  77405. declare module BABYLON {
  77406. /**
  77407. * Class used to handle skinning animations
  77408. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77409. */
  77410. export class Skeleton implements IAnimatable {
  77411. /** defines the skeleton name */
  77412. name: string;
  77413. /** defines the skeleton Id */
  77414. id: string;
  77415. /**
  77416. * Defines the list of child bones
  77417. */
  77418. bones: Bone[];
  77419. /**
  77420. * Defines an estimate of the dimension of the skeleton at rest
  77421. */
  77422. dimensionsAtRest: Vector3;
  77423. /**
  77424. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77425. */
  77426. needInitialSkinMatrix: boolean;
  77427. /**
  77428. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77429. */
  77430. overrideMesh: Nullable<AbstractMesh>;
  77431. /**
  77432. * Gets the list of animations attached to this skeleton
  77433. */
  77434. animations: Array<Animation>;
  77435. private _scene;
  77436. private _isDirty;
  77437. private _transformMatrices;
  77438. private _transformMatrixTexture;
  77439. private _meshesWithPoseMatrix;
  77440. private _animatables;
  77441. private _identity;
  77442. private _synchronizedWithMesh;
  77443. private _ranges;
  77444. private _lastAbsoluteTransformsUpdateId;
  77445. private _canUseTextureForBones;
  77446. private _uniqueId;
  77447. /** @hidden */
  77448. _numBonesWithLinkedTransformNode: number;
  77449. /** @hidden */
  77450. _hasWaitingData: Nullable<boolean>;
  77451. /**
  77452. * Specifies if the skeleton should be serialized
  77453. */
  77454. doNotSerialize: boolean;
  77455. private _useTextureToStoreBoneMatrices;
  77456. /**
  77457. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77458. * Please note that this option is not available if the hardware does not support it
  77459. */
  77460. useTextureToStoreBoneMatrices: boolean;
  77461. private _animationPropertiesOverride;
  77462. /**
  77463. * Gets or sets the animation properties override
  77464. */
  77465. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77466. /**
  77467. * List of inspectable custom properties (used by the Inspector)
  77468. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77469. */
  77470. inspectableCustomProperties: IInspectable[];
  77471. /**
  77472. * An observable triggered before computing the skeleton's matrices
  77473. */
  77474. onBeforeComputeObservable: Observable<Skeleton>;
  77475. /**
  77476. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77477. */
  77478. readonly isUsingTextureForMatrices: boolean;
  77479. /**
  77480. * Gets the unique ID of this skeleton
  77481. */
  77482. readonly uniqueId: number;
  77483. /**
  77484. * Creates a new skeleton
  77485. * @param name defines the skeleton name
  77486. * @param id defines the skeleton Id
  77487. * @param scene defines the hosting scene
  77488. */
  77489. constructor(
  77490. /** defines the skeleton name */
  77491. name: string,
  77492. /** defines the skeleton Id */
  77493. id: string, scene: Scene);
  77494. /**
  77495. * Gets the current object class name.
  77496. * @return the class name
  77497. */
  77498. getClassName(): string;
  77499. /**
  77500. * Returns an array containing the root bones
  77501. * @returns an array containing the root bones
  77502. */
  77503. getChildren(): Array<Bone>;
  77504. /**
  77505. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77506. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77507. * @returns a Float32Array containing matrices data
  77508. */
  77509. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77510. /**
  77511. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77512. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77513. * @returns a raw texture containing the data
  77514. */
  77515. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  77516. /**
  77517. * Gets the current hosting scene
  77518. * @returns a scene object
  77519. */
  77520. getScene(): Scene;
  77521. /**
  77522. * Gets a string representing the current skeleton data
  77523. * @param fullDetails defines a boolean indicating if we want a verbose version
  77524. * @returns a string representing the current skeleton data
  77525. */
  77526. toString(fullDetails?: boolean): string;
  77527. /**
  77528. * Get bone's index searching by name
  77529. * @param name defines bone's name to search for
  77530. * @return the indice of the bone. Returns -1 if not found
  77531. */
  77532. getBoneIndexByName(name: string): number;
  77533. /**
  77534. * Creater a new animation range
  77535. * @param name defines the name of the range
  77536. * @param from defines the start key
  77537. * @param to defines the end key
  77538. */
  77539. createAnimationRange(name: string, from: number, to: number): void;
  77540. /**
  77541. * Delete a specific animation range
  77542. * @param name defines the name of the range
  77543. * @param deleteFrames defines if frames must be removed as well
  77544. */
  77545. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77546. /**
  77547. * Gets a specific animation range
  77548. * @param name defines the name of the range to look for
  77549. * @returns the requested animation range or null if not found
  77550. */
  77551. getAnimationRange(name: string): Nullable<AnimationRange>;
  77552. /**
  77553. * Gets the list of all animation ranges defined on this skeleton
  77554. * @returns an array
  77555. */
  77556. getAnimationRanges(): Nullable<AnimationRange>[];
  77557. /**
  77558. * Copy animation range from a source skeleton.
  77559. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77560. * @param source defines the source skeleton
  77561. * @param name defines the name of the range to copy
  77562. * @param rescaleAsRequired defines if rescaling must be applied if required
  77563. * @returns true if operation was successful
  77564. */
  77565. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77566. /**
  77567. * Forces the skeleton to go to rest pose
  77568. */
  77569. returnToRest(): void;
  77570. private _getHighestAnimationFrame;
  77571. /**
  77572. * Begin a specific animation range
  77573. * @param name defines the name of the range to start
  77574. * @param loop defines if looping must be turned on (false by default)
  77575. * @param speedRatio defines the speed ratio to apply (1 by default)
  77576. * @param onAnimationEnd defines a callback which will be called when animation will end
  77577. * @returns a new animatable
  77578. */
  77579. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77580. /** @hidden */
  77581. _markAsDirty(): void;
  77582. /** @hidden */
  77583. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77584. /** @hidden */
  77585. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77586. private _computeTransformMatrices;
  77587. /**
  77588. * Build all resources required to render a skeleton
  77589. */
  77590. prepare(): void;
  77591. /**
  77592. * Gets the list of animatables currently running for this skeleton
  77593. * @returns an array of animatables
  77594. */
  77595. getAnimatables(): IAnimatable[];
  77596. /**
  77597. * Clone the current skeleton
  77598. * @param name defines the name of the new skeleton
  77599. * @param id defines the id of the new skeleton
  77600. * @returns the new skeleton
  77601. */
  77602. clone(name: string, id: string): Skeleton;
  77603. /**
  77604. * Enable animation blending for this skeleton
  77605. * @param blendingSpeed defines the blending speed to apply
  77606. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77607. */
  77608. enableBlending(blendingSpeed?: number): void;
  77609. /**
  77610. * Releases all resources associated with the current skeleton
  77611. */
  77612. dispose(): void;
  77613. /**
  77614. * Serialize the skeleton in a JSON object
  77615. * @returns a JSON object
  77616. */
  77617. serialize(): any;
  77618. /**
  77619. * Creates a new skeleton from serialized data
  77620. * @param parsedSkeleton defines the serialized data
  77621. * @param scene defines the hosting scene
  77622. * @returns a new skeleton
  77623. */
  77624. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77625. /**
  77626. * Compute all node absolute transforms
  77627. * @param forceUpdate defines if computation must be done even if cache is up to date
  77628. */
  77629. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77630. /**
  77631. * Gets the root pose matrix
  77632. * @returns a matrix
  77633. */
  77634. getPoseMatrix(): Nullable<Matrix>;
  77635. /**
  77636. * Sorts bones per internal index
  77637. */
  77638. sortBones(): void;
  77639. private _sortBones;
  77640. }
  77641. }
  77642. declare module BABYLON {
  77643. /**
  77644. * Class used to store bone information
  77645. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77646. */
  77647. export class Bone extends Node {
  77648. /**
  77649. * defines the bone name
  77650. */
  77651. name: string;
  77652. private static _tmpVecs;
  77653. private static _tmpQuat;
  77654. private static _tmpMats;
  77655. /**
  77656. * Gets the list of child bones
  77657. */
  77658. children: Bone[];
  77659. /** Gets the animations associated with this bone */
  77660. animations: Animation[];
  77661. /**
  77662. * Gets or sets bone length
  77663. */
  77664. length: number;
  77665. /**
  77666. * @hidden Internal only
  77667. * Set this value to map this bone to a different index in the transform matrices
  77668. * Set this value to -1 to exclude the bone from the transform matrices
  77669. */
  77670. _index: Nullable<number>;
  77671. private _skeleton;
  77672. private _localMatrix;
  77673. private _restPose;
  77674. private _baseMatrix;
  77675. private _absoluteTransform;
  77676. private _invertedAbsoluteTransform;
  77677. private _parent;
  77678. private _scalingDeterminant;
  77679. private _worldTransform;
  77680. private _localScaling;
  77681. private _localRotation;
  77682. private _localPosition;
  77683. private _needToDecompose;
  77684. private _needToCompose;
  77685. /** @hidden */
  77686. _linkedTransformNode: Nullable<TransformNode>;
  77687. /** @hidden */
  77688. _waitingTransformNodeId: Nullable<string>;
  77689. /** @hidden */
  77690. /** @hidden */
  77691. _matrix: Matrix;
  77692. /**
  77693. * Create a new bone
  77694. * @param name defines the bone name
  77695. * @param skeleton defines the parent skeleton
  77696. * @param parentBone defines the parent (can be null if the bone is the root)
  77697. * @param localMatrix defines the local matrix
  77698. * @param restPose defines the rest pose matrix
  77699. * @param baseMatrix defines the base matrix
  77700. * @param index defines index of the bone in the hiearchy
  77701. */
  77702. constructor(
  77703. /**
  77704. * defines the bone name
  77705. */
  77706. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77707. /**
  77708. * Gets the current object class name.
  77709. * @return the class name
  77710. */
  77711. getClassName(): string;
  77712. /**
  77713. * Gets the parent skeleton
  77714. * @returns a skeleton
  77715. */
  77716. getSkeleton(): Skeleton;
  77717. /**
  77718. * Gets parent bone
  77719. * @returns a bone or null if the bone is the root of the bone hierarchy
  77720. */
  77721. getParent(): Nullable<Bone>;
  77722. /**
  77723. * Returns an array containing the root bones
  77724. * @returns an array containing the root bones
  77725. */
  77726. getChildren(): Array<Bone>;
  77727. /**
  77728. * Sets the parent bone
  77729. * @param parent defines the parent (can be null if the bone is the root)
  77730. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77731. */
  77732. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77733. /**
  77734. * Gets the local matrix
  77735. * @returns a matrix
  77736. */
  77737. getLocalMatrix(): Matrix;
  77738. /**
  77739. * Gets the base matrix (initial matrix which remains unchanged)
  77740. * @returns a matrix
  77741. */
  77742. getBaseMatrix(): Matrix;
  77743. /**
  77744. * Gets the rest pose matrix
  77745. * @returns a matrix
  77746. */
  77747. getRestPose(): Matrix;
  77748. /**
  77749. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77750. */
  77751. getWorldMatrix(): Matrix;
  77752. /**
  77753. * Sets the local matrix to rest pose matrix
  77754. */
  77755. returnToRest(): void;
  77756. /**
  77757. * Gets the inverse of the absolute transform matrix.
  77758. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77759. * @returns a matrix
  77760. */
  77761. getInvertedAbsoluteTransform(): Matrix;
  77762. /**
  77763. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77764. * @returns a matrix
  77765. */
  77766. getAbsoluteTransform(): Matrix;
  77767. /**
  77768. * Links with the given transform node.
  77769. * The local matrix of this bone is copied from the transform node every frame.
  77770. * @param transformNode defines the transform node to link to
  77771. */
  77772. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77773. /**
  77774. * Gets the node used to drive the bone's transformation
  77775. * @returns a transform node or null
  77776. */
  77777. getTransformNode(): Nullable<TransformNode>;
  77778. /** Gets or sets current position (in local space) */
  77779. position: Vector3;
  77780. /** Gets or sets current rotation (in local space) */
  77781. rotation: Vector3;
  77782. /** Gets or sets current rotation quaternion (in local space) */
  77783. rotationQuaternion: Quaternion;
  77784. /** Gets or sets current scaling (in local space) */
  77785. scaling: Vector3;
  77786. /**
  77787. * Gets the animation properties override
  77788. */
  77789. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77790. private _decompose;
  77791. private _compose;
  77792. /**
  77793. * Update the base and local matrices
  77794. * @param matrix defines the new base or local matrix
  77795. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77796. * @param updateLocalMatrix defines if the local matrix should be updated
  77797. */
  77798. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77799. /** @hidden */
  77800. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77801. /**
  77802. * Flag the bone as dirty (Forcing it to update everything)
  77803. */
  77804. markAsDirty(): void;
  77805. /** @hidden */
  77806. _markAsDirtyAndCompose(): void;
  77807. private _markAsDirtyAndDecompose;
  77808. /**
  77809. * Translate the bone in local or world space
  77810. * @param vec The amount to translate the bone
  77811. * @param space The space that the translation is in
  77812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77813. */
  77814. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77815. /**
  77816. * Set the postion of the bone in local or world space
  77817. * @param position The position to set the bone
  77818. * @param space The space that the position is in
  77819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77820. */
  77821. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77822. /**
  77823. * Set the absolute position of the bone (world space)
  77824. * @param position The position to set the bone
  77825. * @param mesh The mesh that this bone is attached to
  77826. */
  77827. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77828. /**
  77829. * Scale the bone on the x, y and z axes (in local space)
  77830. * @param x The amount to scale the bone on the x axis
  77831. * @param y The amount to scale the bone on the y axis
  77832. * @param z The amount to scale the bone on the z axis
  77833. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77834. */
  77835. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  77836. /**
  77837. * Set the bone scaling in local space
  77838. * @param scale defines the scaling vector
  77839. */
  77840. setScale(scale: Vector3): void;
  77841. /**
  77842. * Gets the current scaling in local space
  77843. * @returns the current scaling vector
  77844. */
  77845. getScale(): Vector3;
  77846. /**
  77847. * Gets the current scaling in local space and stores it in a target vector
  77848. * @param result defines the target vector
  77849. */
  77850. getScaleToRef(result: Vector3): void;
  77851. /**
  77852. * Set the yaw, pitch, and roll of the bone in local or world space
  77853. * @param yaw The rotation of the bone on the y axis
  77854. * @param pitch The rotation of the bone on the x axis
  77855. * @param roll The rotation of the bone on the z axis
  77856. * @param space The space that the axes of rotation are in
  77857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77858. */
  77859. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  77860. /**
  77861. * Add a rotation to the bone on an axis in local or world space
  77862. * @param axis The axis to rotate the bone on
  77863. * @param amount The amount to rotate the bone
  77864. * @param space The space that the axis is in
  77865. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77866. */
  77867. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  77868. /**
  77869. * Set the rotation of the bone to a particular axis angle in local or world space
  77870. * @param axis The axis to rotate the bone on
  77871. * @param angle The angle that the bone should be rotated to
  77872. * @param space The space that the axis is in
  77873. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77874. */
  77875. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  77876. /**
  77877. * Set the euler rotation of the bone in local of world space
  77878. * @param rotation The euler rotation that the bone should be set to
  77879. * @param space The space that the rotation is in
  77880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77881. */
  77882. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77883. /**
  77884. * Set the quaternion rotation of the bone in local of world space
  77885. * @param quat The quaternion rotation that the bone should be set to
  77886. * @param space The space that the rotation is in
  77887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77888. */
  77889. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  77890. /**
  77891. * Set the rotation matrix of the bone in local of world space
  77892. * @param rotMat The rotation matrix that the bone should be set to
  77893. * @param space The space that the rotation is in
  77894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77895. */
  77896. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  77897. private _rotateWithMatrix;
  77898. private _getNegativeRotationToRef;
  77899. /**
  77900. * Get the position of the bone in local or world space
  77901. * @param space The space that the returned position is in
  77902. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77903. * @returns The position of the bone
  77904. */
  77905. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77906. /**
  77907. * Copy the position of the bone to a vector3 in local or world space
  77908. * @param space The space that the returned position is in
  77909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77910. * @param result The vector3 to copy the position to
  77911. */
  77912. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  77913. /**
  77914. * Get the absolute position of the bone (world space)
  77915. * @param mesh The mesh that this bone is attached to
  77916. * @returns The absolute position of the bone
  77917. */
  77918. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  77919. /**
  77920. * Copy the absolute position of the bone (world space) to the result param
  77921. * @param mesh The mesh that this bone is attached to
  77922. * @param result The vector3 to copy the absolute position to
  77923. */
  77924. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  77925. /**
  77926. * Compute the absolute transforms of this bone and its children
  77927. */
  77928. computeAbsoluteTransforms(): void;
  77929. /**
  77930. * Get the world direction from an axis that is in the local space of the bone
  77931. * @param localAxis The local direction that is used to compute the world direction
  77932. * @param mesh The mesh that this bone is attached to
  77933. * @returns The world direction
  77934. */
  77935. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77936. /**
  77937. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  77938. * @param localAxis The local direction that is used to compute the world direction
  77939. * @param mesh The mesh that this bone is attached to
  77940. * @param result The vector3 that the world direction will be copied to
  77941. */
  77942. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77943. /**
  77944. * Get the euler rotation of the bone in local or world space
  77945. * @param space The space that the rotation should be in
  77946. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77947. * @returns The euler rotation
  77948. */
  77949. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77950. /**
  77951. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  77952. * @param space The space that the rotation should be in
  77953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77954. * @param result The vector3 that the rotation should be copied to
  77955. */
  77956. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77957. /**
  77958. * Get the quaternion rotation of the bone in either local or world space
  77959. * @param space The space that the rotation should be in
  77960. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77961. * @returns The quaternion rotation
  77962. */
  77963. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  77964. /**
  77965. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  77966. * @param space The space that the rotation should be in
  77967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77968. * @param result The quaternion that the rotation should be copied to
  77969. */
  77970. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  77971. /**
  77972. * Get the rotation matrix of the bone in local or world space
  77973. * @param space The space that the rotation should be in
  77974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77975. * @returns The rotation matrix
  77976. */
  77977. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  77978. /**
  77979. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  77980. * @param space The space that the rotation should be in
  77981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77982. * @param result The quaternion that the rotation should be copied to
  77983. */
  77984. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  77985. /**
  77986. * Get the world position of a point that is in the local space of the bone
  77987. * @param position The local position
  77988. * @param mesh The mesh that this bone is attached to
  77989. * @returns The world position
  77990. */
  77991. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77992. /**
  77993. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  77994. * @param position The local position
  77995. * @param mesh The mesh that this bone is attached to
  77996. * @param result The vector3 that the world position should be copied to
  77997. */
  77998. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77999. /**
  78000. * Get the local position of a point that is in world space
  78001. * @param position The world position
  78002. * @param mesh The mesh that this bone is attached to
  78003. * @returns The local position
  78004. */
  78005. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78006. /**
  78007. * Get the local position of a point that is in world space and copy it to the result param
  78008. * @param position The world position
  78009. * @param mesh The mesh that this bone is attached to
  78010. * @param result The vector3 that the local position should be copied to
  78011. */
  78012. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78013. }
  78014. }
  78015. declare module BABYLON {
  78016. /**
  78017. * 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.
  78018. * @see https://doc.babylonjs.com/how_to/transformnode
  78019. */
  78020. export class TransformNode extends Node {
  78021. /**
  78022. * Object will not rotate to face the camera
  78023. */
  78024. static BILLBOARDMODE_NONE: number;
  78025. /**
  78026. * Object will rotate to face the camera but only on the x axis
  78027. */
  78028. static BILLBOARDMODE_X: number;
  78029. /**
  78030. * Object will rotate to face the camera but only on the y axis
  78031. */
  78032. static BILLBOARDMODE_Y: number;
  78033. /**
  78034. * Object will rotate to face the camera but only on the z axis
  78035. */
  78036. static BILLBOARDMODE_Z: number;
  78037. /**
  78038. * Object will rotate to face the camera
  78039. */
  78040. static BILLBOARDMODE_ALL: number;
  78041. /**
  78042. * Object will rotate to face the camera's position instead of orientation
  78043. */
  78044. static BILLBOARDMODE_USE_POSITION: number;
  78045. private _forward;
  78046. private _forwardInverted;
  78047. private _up;
  78048. private _right;
  78049. private _rightInverted;
  78050. private _position;
  78051. private _rotation;
  78052. private _rotationQuaternion;
  78053. protected _scaling: Vector3;
  78054. protected _isDirty: boolean;
  78055. private _transformToBoneReferal;
  78056. private _isAbsoluteSynced;
  78057. private _billboardMode;
  78058. /**
  78059. * Gets or sets the billboard mode. Default is 0.
  78060. *
  78061. * | Value | Type | Description |
  78062. * | --- | --- | --- |
  78063. * | 0 | BILLBOARDMODE_NONE | |
  78064. * | 1 | BILLBOARDMODE_X | |
  78065. * | 2 | BILLBOARDMODE_Y | |
  78066. * | 4 | BILLBOARDMODE_Z | |
  78067. * | 7 | BILLBOARDMODE_ALL | |
  78068. *
  78069. */
  78070. billboardMode: number;
  78071. private _preserveParentRotationForBillboard;
  78072. /**
  78073. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  78074. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  78075. */
  78076. preserveParentRotationForBillboard: boolean;
  78077. /**
  78078. * 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
  78079. */
  78080. scalingDeterminant: number;
  78081. private _infiniteDistance;
  78082. /**
  78083. * Gets or sets the distance of the object to max, often used by skybox
  78084. */
  78085. infiniteDistance: boolean;
  78086. /**
  78087. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  78088. * By default the system will update normals to compensate
  78089. */
  78090. ignoreNonUniformScaling: boolean;
  78091. /**
  78092. * 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
  78093. */
  78094. reIntegrateRotationIntoRotationQuaternion: boolean;
  78095. /** @hidden */
  78096. _poseMatrix: Nullable<Matrix>;
  78097. /** @hidden */
  78098. _localMatrix: Matrix;
  78099. private _usePivotMatrix;
  78100. private _absolutePosition;
  78101. private _absoluteScaling;
  78102. private _absoluteRotationQuaternion;
  78103. private _pivotMatrix;
  78104. private _pivotMatrixInverse;
  78105. protected _postMultiplyPivotMatrix: boolean;
  78106. protected _isWorldMatrixFrozen: boolean;
  78107. /** @hidden */
  78108. _indexInSceneTransformNodesArray: number;
  78109. /**
  78110. * An event triggered after the world matrix is updated
  78111. */
  78112. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  78113. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  78114. /**
  78115. * Gets a string identifying the name of the class
  78116. * @returns "TransformNode" string
  78117. */
  78118. getClassName(): string;
  78119. /**
  78120. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  78121. */
  78122. position: Vector3;
  78123. /**
  78124. * 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)).
  78125. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  78126. */
  78127. rotation: Vector3;
  78128. /**
  78129. * 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)).
  78130. */
  78131. scaling: Vector3;
  78132. /**
  78133. * 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).
  78134. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  78135. */
  78136. rotationQuaternion: Nullable<Quaternion>;
  78137. /**
  78138. * The forward direction of that transform in world space.
  78139. */
  78140. readonly forward: Vector3;
  78141. /**
  78142. * The up direction of that transform in world space.
  78143. */
  78144. readonly up: Vector3;
  78145. /**
  78146. * The right direction of that transform in world space.
  78147. */
  78148. readonly right: Vector3;
  78149. /**
  78150. * Copies the parameter passed Matrix into the mesh Pose matrix.
  78151. * @param matrix the matrix to copy the pose from
  78152. * @returns this TransformNode.
  78153. */
  78154. updatePoseMatrix(matrix: Matrix): TransformNode;
  78155. /**
  78156. * Returns the mesh Pose matrix.
  78157. * @returns the pose matrix
  78158. */
  78159. getPoseMatrix(): Matrix;
  78160. /** @hidden */
  78161. _isSynchronized(): boolean;
  78162. /** @hidden */
  78163. _initCache(): void;
  78164. /**
  78165. * Flag the transform node as dirty (Forcing it to update everything)
  78166. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  78167. * @returns this transform node
  78168. */
  78169. markAsDirty(property: string): TransformNode;
  78170. /**
  78171. * Returns the current mesh absolute position.
  78172. * Returns a Vector3.
  78173. */
  78174. readonly absolutePosition: Vector3;
  78175. /**
  78176. * Returns the current mesh absolute scaling.
  78177. * Returns a Vector3.
  78178. */
  78179. readonly absoluteScaling: Vector3;
  78180. /**
  78181. * Returns the current mesh absolute rotation.
  78182. * Returns a Quaternion.
  78183. */
  78184. readonly absoluteRotationQuaternion: Quaternion;
  78185. /**
  78186. * Sets a new matrix to apply before all other transformation
  78187. * @param matrix defines the transform matrix
  78188. * @returns the current TransformNode
  78189. */
  78190. setPreTransformMatrix(matrix: Matrix): TransformNode;
  78191. /**
  78192. * Sets a new pivot matrix to the current node
  78193. * @param matrix defines the new pivot matrix to use
  78194. * @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
  78195. * @returns the current TransformNode
  78196. */
  78197. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  78198. /**
  78199. * Returns the mesh pivot matrix.
  78200. * Default : Identity.
  78201. * @returns the matrix
  78202. */
  78203. getPivotMatrix(): Matrix;
  78204. /**
  78205. * Prevents the World matrix to be computed any longer.
  78206. * @returns the TransformNode.
  78207. */
  78208. freezeWorldMatrix(): TransformNode;
  78209. /**
  78210. * Allows back the World matrix computation.
  78211. * @returns the TransformNode.
  78212. */
  78213. unfreezeWorldMatrix(): this;
  78214. /**
  78215. * True if the World matrix has been frozen.
  78216. */
  78217. readonly isWorldMatrixFrozen: boolean;
  78218. /**
  78219. * Retuns the mesh absolute position in the World.
  78220. * @returns a Vector3.
  78221. */
  78222. getAbsolutePosition(): Vector3;
  78223. /**
  78224. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  78225. * @param absolutePosition the absolute position to set
  78226. * @returns the TransformNode.
  78227. */
  78228. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78229. /**
  78230. * Sets the mesh position in its local space.
  78231. * @param vector3 the position to set in localspace
  78232. * @returns the TransformNode.
  78233. */
  78234. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  78235. /**
  78236. * Returns the mesh position in the local space from the current World matrix values.
  78237. * @returns a new Vector3.
  78238. */
  78239. getPositionExpressedInLocalSpace(): Vector3;
  78240. /**
  78241. * Translates the mesh along the passed Vector3 in its local space.
  78242. * @param vector3 the distance to translate in localspace
  78243. * @returns the TransformNode.
  78244. */
  78245. locallyTranslate(vector3: Vector3): TransformNode;
  78246. private static _lookAtVectorCache;
  78247. /**
  78248. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  78249. * @param targetPoint the position (must be in same space as current mesh) to look at
  78250. * @param yawCor optional yaw (y-axis) correction in radians
  78251. * @param pitchCor optional pitch (x-axis) correction in radians
  78252. * @param rollCor optional roll (z-axis) correction in radians
  78253. * @param space the choosen space of the target
  78254. * @returns the TransformNode.
  78255. */
  78256. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  78257. /**
  78258. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78259. * This Vector3 is expressed in the World space.
  78260. * @param localAxis axis to rotate
  78261. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78262. */
  78263. getDirection(localAxis: Vector3): Vector3;
  78264. /**
  78265. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  78266. * localAxis is expressed in the mesh local space.
  78267. * result is computed in the Wordl space from the mesh World matrix.
  78268. * @param localAxis axis to rotate
  78269. * @param result the resulting transformnode
  78270. * @returns this TransformNode.
  78271. */
  78272. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  78273. /**
  78274. * Sets this transform node rotation to the given local axis.
  78275. * @param localAxis the axis in local space
  78276. * @param yawCor optional yaw (y-axis) correction in radians
  78277. * @param pitchCor optional pitch (x-axis) correction in radians
  78278. * @param rollCor optional roll (z-axis) correction in radians
  78279. * @returns this TransformNode
  78280. */
  78281. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  78282. /**
  78283. * Sets a new pivot point to the current node
  78284. * @param point defines the new pivot point to use
  78285. * @param space defines if the point is in world or local space (local by default)
  78286. * @returns the current TransformNode
  78287. */
  78288. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  78289. /**
  78290. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  78291. * @returns the pivot point
  78292. */
  78293. getPivotPoint(): Vector3;
  78294. /**
  78295. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  78296. * @param result the vector3 to store the result
  78297. * @returns this TransformNode.
  78298. */
  78299. getPivotPointToRef(result: Vector3): TransformNode;
  78300. /**
  78301. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  78302. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  78303. */
  78304. getAbsolutePivotPoint(): Vector3;
  78305. /**
  78306. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  78307. * @param result vector3 to store the result
  78308. * @returns this TransformNode.
  78309. */
  78310. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  78311. /**
  78312. * Defines the passed node as the parent of the current node.
  78313. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  78314. * @see https://doc.babylonjs.com/how_to/parenting
  78315. * @param node the node ot set as the parent
  78316. * @returns this TransformNode.
  78317. */
  78318. setParent(node: Nullable<Node>): TransformNode;
  78319. private _nonUniformScaling;
  78320. /**
  78321. * True if the scaling property of this object is non uniform eg. (1,2,1)
  78322. */
  78323. readonly nonUniformScaling: boolean;
  78324. /** @hidden */
  78325. _updateNonUniformScalingState(value: boolean): boolean;
  78326. /**
  78327. * Attach the current TransformNode to another TransformNode associated with a bone
  78328. * @param bone Bone affecting the TransformNode
  78329. * @param affectedTransformNode TransformNode associated with the bone
  78330. * @returns this object
  78331. */
  78332. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  78333. /**
  78334. * Detach the transform node if its associated with a bone
  78335. * @returns this object
  78336. */
  78337. detachFromBone(): TransformNode;
  78338. private static _rotationAxisCache;
  78339. /**
  78340. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  78341. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78342. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78343. * The passed axis is also normalized.
  78344. * @param axis the axis to rotate around
  78345. * @param amount the amount to rotate in radians
  78346. * @param space Space to rotate in (Default: local)
  78347. * @returns the TransformNode.
  78348. */
  78349. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78350. /**
  78351. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  78352. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78353. * The passed axis is also normalized. .
  78354. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  78355. * @param point the point to rotate around
  78356. * @param axis the axis to rotate around
  78357. * @param amount the amount to rotate in radians
  78358. * @returns the TransformNode
  78359. */
  78360. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  78361. /**
  78362. * Translates the mesh along the axis vector for the passed distance in the given space.
  78363. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78364. * @param axis the axis to translate in
  78365. * @param distance the distance to translate
  78366. * @param space Space to rotate in (Default: local)
  78367. * @returns the TransformNode.
  78368. */
  78369. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78370. /**
  78371. * Adds a rotation step to the mesh current rotation.
  78372. * x, y, z are Euler angles expressed in radians.
  78373. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  78374. * This means this rotation is made in the mesh local space only.
  78375. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  78376. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  78377. * ```javascript
  78378. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  78379. * ```
  78380. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  78381. * 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.
  78382. * @param x Rotation to add
  78383. * @param y Rotation to add
  78384. * @param z Rotation to add
  78385. * @returns the TransformNode.
  78386. */
  78387. addRotation(x: number, y: number, z: number): TransformNode;
  78388. /**
  78389. * @hidden
  78390. */
  78391. protected _getEffectiveParent(): Nullable<Node>;
  78392. /**
  78393. * Computes the world matrix of the node
  78394. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78395. * @returns the world matrix
  78396. */
  78397. computeWorldMatrix(force?: boolean): Matrix;
  78398. protected _afterComputeWorldMatrix(): void;
  78399. /**
  78400. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  78401. * @param func callback function to add
  78402. *
  78403. * @returns the TransformNode.
  78404. */
  78405. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78406. /**
  78407. * Removes a registered callback function.
  78408. * @param func callback function to remove
  78409. * @returns the TransformNode.
  78410. */
  78411. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78412. /**
  78413. * Gets the position of the current mesh in camera space
  78414. * @param camera defines the camera to use
  78415. * @returns a position
  78416. */
  78417. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  78418. /**
  78419. * Returns the distance from the mesh to the active camera
  78420. * @param camera defines the camera to use
  78421. * @returns the distance
  78422. */
  78423. getDistanceToCamera(camera?: Nullable<Camera>): number;
  78424. /**
  78425. * Clone the current transform node
  78426. * @param name Name of the new clone
  78427. * @param newParent New parent for the clone
  78428. * @param doNotCloneChildren Do not clone children hierarchy
  78429. * @returns the new transform node
  78430. */
  78431. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  78432. /**
  78433. * Serializes the objects information.
  78434. * @param currentSerializationObject defines the object to serialize in
  78435. * @returns the serialized object
  78436. */
  78437. serialize(currentSerializationObject?: any): any;
  78438. /**
  78439. * Returns a new TransformNode object parsed from the source provided.
  78440. * @param parsedTransformNode is the source.
  78441. * @param scene the scne the object belongs to
  78442. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  78443. * @returns a new TransformNode object parsed from the source provided.
  78444. */
  78445. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  78446. /**
  78447. * Get all child-transformNodes of this node
  78448. * @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
  78449. * @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
  78450. * @returns an array of TransformNode
  78451. */
  78452. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  78453. /**
  78454. * Releases resources associated with this transform node.
  78455. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78456. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78457. */
  78458. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78459. /**
  78460. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  78461. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  78462. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  78463. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  78464. * @returns the current mesh
  78465. */
  78466. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  78467. private _syncAbsoluteScalingAndRotation;
  78468. }
  78469. }
  78470. declare module BABYLON {
  78471. /**
  78472. * Defines the types of pose enabled controllers that are supported
  78473. */
  78474. export enum PoseEnabledControllerType {
  78475. /**
  78476. * HTC Vive
  78477. */
  78478. VIVE = 0,
  78479. /**
  78480. * Oculus Rift
  78481. */
  78482. OCULUS = 1,
  78483. /**
  78484. * Windows mixed reality
  78485. */
  78486. WINDOWS = 2,
  78487. /**
  78488. * Samsung gear VR
  78489. */
  78490. GEAR_VR = 3,
  78491. /**
  78492. * Google Daydream
  78493. */
  78494. DAYDREAM = 4,
  78495. /**
  78496. * Generic
  78497. */
  78498. GENERIC = 5
  78499. }
  78500. /**
  78501. * Defines the MutableGamepadButton interface for the state of a gamepad button
  78502. */
  78503. export interface MutableGamepadButton {
  78504. /**
  78505. * Value of the button/trigger
  78506. */
  78507. value: number;
  78508. /**
  78509. * If the button/trigger is currently touched
  78510. */
  78511. touched: boolean;
  78512. /**
  78513. * If the button/trigger is currently pressed
  78514. */
  78515. pressed: boolean;
  78516. }
  78517. /**
  78518. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  78519. * @hidden
  78520. */
  78521. export interface ExtendedGamepadButton extends GamepadButton {
  78522. /**
  78523. * If the button/trigger is currently pressed
  78524. */
  78525. readonly pressed: boolean;
  78526. /**
  78527. * If the button/trigger is currently touched
  78528. */
  78529. readonly touched: boolean;
  78530. /**
  78531. * Value of the button/trigger
  78532. */
  78533. readonly value: number;
  78534. }
  78535. /** @hidden */
  78536. export interface _GamePadFactory {
  78537. /**
  78538. * Returns wether or not the current gamepad can be created for this type of controller.
  78539. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78540. * @returns true if it can be created, otherwise false
  78541. */
  78542. canCreate(gamepadInfo: any): boolean;
  78543. /**
  78544. * Creates a new instance of the Gamepad.
  78545. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78546. * @returns the new gamepad instance
  78547. */
  78548. create(gamepadInfo: any): Gamepad;
  78549. }
  78550. /**
  78551. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78552. */
  78553. export class PoseEnabledControllerHelper {
  78554. /** @hidden */
  78555. static _ControllerFactories: _GamePadFactory[];
  78556. /** @hidden */
  78557. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  78558. /**
  78559. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78560. * @param vrGamepad the gamepad to initialized
  78561. * @returns a vr controller of the type the gamepad identified as
  78562. */
  78563. static InitiateController(vrGamepad: any): Gamepad;
  78564. }
  78565. /**
  78566. * Defines the PoseEnabledController object that contains state of a vr capable controller
  78567. */
  78568. export class PoseEnabledController extends Gamepad implements PoseControlled {
  78569. /**
  78570. * If the controller is used in a webXR session
  78571. */
  78572. isXR: boolean;
  78573. private _deviceRoomPosition;
  78574. private _deviceRoomRotationQuaternion;
  78575. /**
  78576. * The device position in babylon space
  78577. */
  78578. devicePosition: Vector3;
  78579. /**
  78580. * The device rotation in babylon space
  78581. */
  78582. deviceRotationQuaternion: Quaternion;
  78583. /**
  78584. * The scale factor of the device in babylon space
  78585. */
  78586. deviceScaleFactor: number;
  78587. /**
  78588. * (Likely devicePosition should be used instead) The device position in its room space
  78589. */
  78590. position: Vector3;
  78591. /**
  78592. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  78593. */
  78594. rotationQuaternion: Quaternion;
  78595. /**
  78596. * The type of controller (Eg. Windows mixed reality)
  78597. */
  78598. controllerType: PoseEnabledControllerType;
  78599. protected _calculatedPosition: Vector3;
  78600. private _calculatedRotation;
  78601. /**
  78602. * The raw pose from the device
  78603. */
  78604. rawPose: DevicePose;
  78605. private _trackPosition;
  78606. private _maxRotationDistFromHeadset;
  78607. private _draggedRoomRotation;
  78608. /**
  78609. * @hidden
  78610. */
  78611. _disableTrackPosition(fixedPosition: Vector3): void;
  78612. /**
  78613. * Internal, the mesh attached to the controller
  78614. * @hidden
  78615. */
  78616. _mesh: Nullable<AbstractMesh>;
  78617. private _poseControlledCamera;
  78618. private _leftHandSystemQuaternion;
  78619. /**
  78620. * Internal, matrix used to convert room space to babylon space
  78621. * @hidden
  78622. */
  78623. _deviceToWorld: Matrix;
  78624. /**
  78625. * Node to be used when casting a ray from the controller
  78626. * @hidden
  78627. */
  78628. _pointingPoseNode: Nullable<TransformNode>;
  78629. /**
  78630. * Name of the child mesh that can be used to cast a ray from the controller
  78631. */
  78632. static readonly POINTING_POSE: string;
  78633. /**
  78634. * Creates a new PoseEnabledController from a gamepad
  78635. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  78636. */
  78637. constructor(browserGamepad: any);
  78638. private _workingMatrix;
  78639. /**
  78640. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  78641. */
  78642. update(): void;
  78643. /**
  78644. * Updates only the pose device and mesh without doing any button event checking
  78645. */
  78646. protected _updatePoseAndMesh(): void;
  78647. /**
  78648. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  78649. * @param poseData raw pose fromthe device
  78650. */
  78651. updateFromDevice(poseData: DevicePose): void;
  78652. /**
  78653. * @hidden
  78654. */
  78655. _meshAttachedObservable: Observable<AbstractMesh>;
  78656. /**
  78657. * Attaches a mesh to the controller
  78658. * @param mesh the mesh to be attached
  78659. */
  78660. attachToMesh(mesh: AbstractMesh): void;
  78661. /**
  78662. * Attaches the controllers mesh to a camera
  78663. * @param camera the camera the mesh should be attached to
  78664. */
  78665. attachToPoseControlledCamera(camera: TargetCamera): void;
  78666. /**
  78667. * Disposes of the controller
  78668. */
  78669. dispose(): void;
  78670. /**
  78671. * The mesh that is attached to the controller
  78672. */
  78673. readonly mesh: Nullable<AbstractMesh>;
  78674. /**
  78675. * Gets the ray of the controller in the direction the controller is pointing
  78676. * @param length the length the resulting ray should be
  78677. * @returns a ray in the direction the controller is pointing
  78678. */
  78679. getForwardRay(length?: number): Ray;
  78680. }
  78681. }
  78682. declare module BABYLON {
  78683. /**
  78684. * Defines the WebVRController object that represents controllers tracked in 3D space
  78685. */
  78686. export abstract class WebVRController extends PoseEnabledController {
  78687. /**
  78688. * Internal, the default controller model for the controller
  78689. */
  78690. protected _defaultModel: AbstractMesh;
  78691. /**
  78692. * Fired when the trigger state has changed
  78693. */
  78694. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78695. /**
  78696. * Fired when the main button state has changed
  78697. */
  78698. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78699. /**
  78700. * Fired when the secondary button state has changed
  78701. */
  78702. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78703. /**
  78704. * Fired when the pad state has changed
  78705. */
  78706. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  78707. /**
  78708. * Fired when controllers stick values have changed
  78709. */
  78710. onPadValuesChangedObservable: Observable<StickValues>;
  78711. /**
  78712. * Array of button availible on the controller
  78713. */
  78714. protected _buttons: Array<MutableGamepadButton>;
  78715. private _onButtonStateChange;
  78716. /**
  78717. * Fired when a controller button's state has changed
  78718. * @param callback the callback containing the button that was modified
  78719. */
  78720. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  78721. /**
  78722. * X and Y axis corresponding to the controllers joystick
  78723. */
  78724. pad: StickValues;
  78725. /**
  78726. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  78727. */
  78728. hand: string;
  78729. /**
  78730. * The default controller model for the controller
  78731. */
  78732. readonly defaultModel: AbstractMesh;
  78733. /**
  78734. * Creates a new WebVRController from a gamepad
  78735. * @param vrGamepad the gamepad that the WebVRController should be created from
  78736. */
  78737. constructor(vrGamepad: any);
  78738. /**
  78739. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  78740. */
  78741. update(): void;
  78742. /**
  78743. * Function to be called when a button is modified
  78744. */
  78745. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  78746. /**
  78747. * Loads a mesh and attaches it to the controller
  78748. * @param scene the scene the mesh should be added to
  78749. * @param meshLoaded callback for when the mesh has been loaded
  78750. */
  78751. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  78752. private _setButtonValue;
  78753. private _changes;
  78754. private _checkChanges;
  78755. /**
  78756. * Disposes of th webVRCOntroller
  78757. */
  78758. dispose(): void;
  78759. }
  78760. }
  78761. declare module BABYLON {
  78762. /**
  78763. * The HemisphericLight simulates the ambient environment light,
  78764. * so the passed direction is the light reflection direction, not the incoming direction.
  78765. */
  78766. export class HemisphericLight extends Light {
  78767. /**
  78768. * The groundColor is the light in the opposite direction to the one specified during creation.
  78769. * 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.
  78770. */
  78771. groundColor: Color3;
  78772. /**
  78773. * The light reflection direction, not the incoming direction.
  78774. */
  78775. direction: Vector3;
  78776. /**
  78777. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78778. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78779. * The HemisphericLight can't cast shadows.
  78780. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78781. * @param name The friendly name of the light
  78782. * @param direction The direction of the light reflection
  78783. * @param scene The scene the light belongs to
  78784. */
  78785. constructor(name: string, direction: Vector3, scene: Scene);
  78786. protected _buildUniformLayout(): void;
  78787. /**
  78788. * Returns the string "HemisphericLight".
  78789. * @return The class name
  78790. */
  78791. getClassName(): string;
  78792. /**
  78793. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78794. * Returns the updated direction.
  78795. * @param target The target the direction should point to
  78796. * @return The computed direction
  78797. */
  78798. setDirectionToTarget(target: Vector3): Vector3;
  78799. /**
  78800. * Returns the shadow generator associated to the light.
  78801. * @returns Always null for hemispheric lights because it does not support shadows.
  78802. */
  78803. getShadowGenerator(): Nullable<IShadowGenerator>;
  78804. /**
  78805. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78806. * @param effect The effect to update
  78807. * @param lightIndex The index of the light in the effect to update
  78808. * @returns The hemispheric light
  78809. */
  78810. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78811. /**
  78812. * Computes the world matrix of the node
  78813. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78814. * @param useWasUpdatedFlag defines a reserved property
  78815. * @returns the world matrix
  78816. */
  78817. computeWorldMatrix(): Matrix;
  78818. /**
  78819. * Returns the integer 3.
  78820. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78821. */
  78822. getTypeID(): number;
  78823. /**
  78824. * Prepares the list of defines specific to the light type.
  78825. * @param defines the list of defines
  78826. * @param lightIndex defines the index of the light for the effect
  78827. */
  78828. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78829. }
  78830. }
  78831. declare module BABYLON {
  78832. /** @hidden */
  78833. export var vrMultiviewToSingleviewPixelShader: {
  78834. name: string;
  78835. shader: string;
  78836. };
  78837. }
  78838. declare module BABYLON {
  78839. /**
  78840. * Renders to multiple views with a single draw call
  78841. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  78842. */
  78843. export class MultiviewRenderTarget extends RenderTargetTexture {
  78844. /**
  78845. * Creates a multiview render target
  78846. * @param scene scene used with the render target
  78847. * @param size the size of the render target (used for each view)
  78848. */
  78849. constructor(scene: Scene, size?: number | {
  78850. width: number;
  78851. height: number;
  78852. } | {
  78853. ratio: number;
  78854. });
  78855. /**
  78856. * @hidden
  78857. * @param faceIndex the face index, if its a cube texture
  78858. */
  78859. _bindFrameBuffer(faceIndex?: number): void;
  78860. /**
  78861. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78862. * @returns the view count
  78863. */
  78864. getViewCount(): number;
  78865. }
  78866. }
  78867. declare module BABYLON {
  78868. /**
  78869. * Reprasents a camera frustum
  78870. */
  78871. export class Frustum {
  78872. /**
  78873. * Gets the planes representing the frustum
  78874. * @param transform matrix to be applied to the returned planes
  78875. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  78876. */
  78877. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  78878. /**
  78879. * Gets the near frustum plane transformed by the transform matrix
  78880. * @param transform transformation matrix to be applied to the resulting frustum plane
  78881. * @param frustumPlane the resuling frustum plane
  78882. */
  78883. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78884. /**
  78885. * Gets the far frustum plane transformed by the transform matrix
  78886. * @param transform transformation matrix to be applied to the resulting frustum plane
  78887. * @param frustumPlane the resuling frustum plane
  78888. */
  78889. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78890. /**
  78891. * Gets the left frustum plane transformed by the transform matrix
  78892. * @param transform transformation matrix to be applied to the resulting frustum plane
  78893. * @param frustumPlane the resuling frustum plane
  78894. */
  78895. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78896. /**
  78897. * Gets the right frustum plane transformed by the transform matrix
  78898. * @param transform transformation matrix to be applied to the resulting frustum plane
  78899. * @param frustumPlane the resuling frustum plane
  78900. */
  78901. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78902. /**
  78903. * Gets the top frustum plane transformed by the transform matrix
  78904. * @param transform transformation matrix to be applied to the resulting frustum plane
  78905. * @param frustumPlane the resuling frustum plane
  78906. */
  78907. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78908. /**
  78909. * Gets the bottom frustum plane transformed by the transform matrix
  78910. * @param transform transformation matrix to be applied to the resulting frustum plane
  78911. * @param frustumPlane the resuling frustum plane
  78912. */
  78913. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78914. /**
  78915. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  78916. * @param transform transformation matrix to be applied to the resulting frustum planes
  78917. * @param frustumPlanes the resuling frustum planes
  78918. */
  78919. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  78920. }
  78921. }
  78922. declare module BABYLON {
  78923. interface Engine {
  78924. /**
  78925. * Creates a new multiview render target
  78926. * @param width defines the width of the texture
  78927. * @param height defines the height of the texture
  78928. * @returns the created multiview texture
  78929. */
  78930. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  78931. /**
  78932. * Binds a multiview framebuffer to be drawn to
  78933. * @param multiviewTexture texture to bind
  78934. */
  78935. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  78936. }
  78937. interface Camera {
  78938. /**
  78939. * @hidden
  78940. * 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)
  78941. */
  78942. _useMultiviewToSingleView: boolean;
  78943. /**
  78944. * @hidden
  78945. * 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)
  78946. */
  78947. _multiviewTexture: Nullable<RenderTargetTexture>;
  78948. /**
  78949. * @hidden
  78950. * ensures the multiview texture of the camera exists and has the specified width/height
  78951. * @param width height to set on the multiview texture
  78952. * @param height width to set on the multiview texture
  78953. */
  78954. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  78955. }
  78956. interface Scene {
  78957. /** @hidden */
  78958. _transformMatrixR: Matrix;
  78959. /** @hidden */
  78960. _multiviewSceneUbo: Nullable<UniformBuffer>;
  78961. /** @hidden */
  78962. _createMultiviewUbo(): void;
  78963. /** @hidden */
  78964. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  78965. /** @hidden */
  78966. _renderMultiviewToSingleView(camera: Camera): void;
  78967. }
  78968. }
  78969. declare module BABYLON {
  78970. /**
  78971. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  78972. * This will not be used for webXR as it supports displaying texture arrays directly
  78973. */
  78974. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  78975. /**
  78976. * Initializes a VRMultiviewToSingleview
  78977. * @param name name of the post process
  78978. * @param camera camera to be applied to
  78979. * @param scaleFactor scaling factor to the size of the output texture
  78980. */
  78981. constructor(name: string, camera: Camera, scaleFactor: number);
  78982. }
  78983. }
  78984. declare module BABYLON {
  78985. interface Engine {
  78986. /** @hidden */
  78987. _vrDisplay: any;
  78988. /** @hidden */
  78989. _vrSupported: boolean;
  78990. /** @hidden */
  78991. _oldSize: Size;
  78992. /** @hidden */
  78993. _oldHardwareScaleFactor: number;
  78994. /** @hidden */
  78995. _vrExclusivePointerMode: boolean;
  78996. /** @hidden */
  78997. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  78998. /** @hidden */
  78999. _onVRDisplayPointerRestricted: () => void;
  79000. /** @hidden */
  79001. _onVRDisplayPointerUnrestricted: () => void;
  79002. /** @hidden */
  79003. _onVrDisplayConnect: Nullable<(display: any) => void>;
  79004. /** @hidden */
  79005. _onVrDisplayDisconnect: Nullable<() => void>;
  79006. /** @hidden */
  79007. _onVrDisplayPresentChange: Nullable<() => void>;
  79008. /**
  79009. * Observable signaled when VR display mode changes
  79010. */
  79011. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  79012. /**
  79013. * Observable signaled when VR request present is complete
  79014. */
  79015. onVRRequestPresentComplete: Observable<boolean>;
  79016. /**
  79017. * Observable signaled when VR request present starts
  79018. */
  79019. onVRRequestPresentStart: Observable<Engine>;
  79020. /**
  79021. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  79022. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  79023. */
  79024. isInVRExclusivePointerMode: boolean;
  79025. /**
  79026. * Gets a boolean indicating if a webVR device was detected
  79027. * @returns true if a webVR device was detected
  79028. */
  79029. isVRDevicePresent(): boolean;
  79030. /**
  79031. * Gets the current webVR device
  79032. * @returns the current webVR device (or null)
  79033. */
  79034. getVRDevice(): any;
  79035. /**
  79036. * Initializes a webVR display and starts listening to display change events
  79037. * The onVRDisplayChangedObservable will be notified upon these changes
  79038. * @returns A promise containing a VRDisplay and if vr is supported
  79039. */
  79040. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  79041. /** @hidden */
  79042. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  79043. /**
  79044. * Call this function to switch to webVR mode
  79045. * Will do nothing if webVR is not supported or if there is no webVR device
  79046. * @see http://doc.babylonjs.com/how_to/webvr_camera
  79047. */
  79048. enableVR(): void;
  79049. /** @hidden */
  79050. _onVRFullScreenTriggered(): void;
  79051. }
  79052. }
  79053. declare module BABYLON {
  79054. /**
  79055. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  79056. * IMPORTANT!! The data is right-hand data.
  79057. * @export
  79058. * @interface DevicePose
  79059. */
  79060. export interface DevicePose {
  79061. /**
  79062. * The position of the device, values in array are [x,y,z].
  79063. */
  79064. readonly position: Nullable<Float32Array>;
  79065. /**
  79066. * The linearVelocity of the device, values in array are [x,y,z].
  79067. */
  79068. readonly linearVelocity: Nullable<Float32Array>;
  79069. /**
  79070. * The linearAcceleration of the device, values in array are [x,y,z].
  79071. */
  79072. readonly linearAcceleration: Nullable<Float32Array>;
  79073. /**
  79074. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  79075. */
  79076. readonly orientation: Nullable<Float32Array>;
  79077. /**
  79078. * The angularVelocity of the device, values in array are [x,y,z].
  79079. */
  79080. readonly angularVelocity: Nullable<Float32Array>;
  79081. /**
  79082. * The angularAcceleration of the device, values in array are [x,y,z].
  79083. */
  79084. readonly angularAcceleration: Nullable<Float32Array>;
  79085. }
  79086. /**
  79087. * Interface representing a pose controlled object in Babylon.
  79088. * A pose controlled object has both regular pose values as well as pose values
  79089. * from an external device such as a VR head mounted display
  79090. */
  79091. export interface PoseControlled {
  79092. /**
  79093. * The position of the object in babylon space.
  79094. */
  79095. position: Vector3;
  79096. /**
  79097. * The rotation quaternion of the object in babylon space.
  79098. */
  79099. rotationQuaternion: Quaternion;
  79100. /**
  79101. * The position of the device in babylon space.
  79102. */
  79103. devicePosition?: Vector3;
  79104. /**
  79105. * The rotation quaternion of the device in babylon space.
  79106. */
  79107. deviceRotationQuaternion: Quaternion;
  79108. /**
  79109. * The raw pose coming from the device.
  79110. */
  79111. rawPose: Nullable<DevicePose>;
  79112. /**
  79113. * The scale of the device to be used when translating from device space to babylon space.
  79114. */
  79115. deviceScaleFactor: number;
  79116. /**
  79117. * Updates the poseControlled values based on the input device pose.
  79118. * @param poseData the pose data to update the object with
  79119. */
  79120. updateFromDevice(poseData: DevicePose): void;
  79121. }
  79122. /**
  79123. * Set of options to customize the webVRCamera
  79124. */
  79125. export interface WebVROptions {
  79126. /**
  79127. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  79128. */
  79129. trackPosition?: boolean;
  79130. /**
  79131. * Sets the scale of the vrDevice in babylon space. (default: 1)
  79132. */
  79133. positionScale?: number;
  79134. /**
  79135. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  79136. */
  79137. displayName?: string;
  79138. /**
  79139. * Should the native controller meshes be initialized. (default: true)
  79140. */
  79141. controllerMeshes?: boolean;
  79142. /**
  79143. * Creating a default HemiLight only on controllers. (default: true)
  79144. */
  79145. defaultLightingOnControllers?: boolean;
  79146. /**
  79147. * If you don't want to use the default VR button of the helper. (default: false)
  79148. */
  79149. useCustomVRButton?: boolean;
  79150. /**
  79151. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  79152. */
  79153. customVRButton?: HTMLButtonElement;
  79154. /**
  79155. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  79156. */
  79157. rayLength?: number;
  79158. /**
  79159. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  79160. */
  79161. defaultHeight?: number;
  79162. /**
  79163. * If multiview should be used if availible (default: false)
  79164. */
  79165. useMultiview?: boolean;
  79166. }
  79167. /**
  79168. * This represents a WebVR camera.
  79169. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  79170. * @example http://doc.babylonjs.com/how_to/webvr_camera
  79171. */
  79172. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  79173. private webVROptions;
  79174. /**
  79175. * @hidden
  79176. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  79177. */
  79178. _vrDevice: any;
  79179. /**
  79180. * The rawPose of the vrDevice.
  79181. */
  79182. rawPose: Nullable<DevicePose>;
  79183. private _onVREnabled;
  79184. private _specsVersion;
  79185. private _attached;
  79186. private _frameData;
  79187. protected _descendants: Array<Node>;
  79188. private _deviceRoomPosition;
  79189. /** @hidden */
  79190. _deviceRoomRotationQuaternion: Quaternion;
  79191. private _standingMatrix;
  79192. /**
  79193. * Represents device position in babylon space.
  79194. */
  79195. devicePosition: Vector3;
  79196. /**
  79197. * Represents device rotation in babylon space.
  79198. */
  79199. deviceRotationQuaternion: Quaternion;
  79200. /**
  79201. * The scale of the device to be used when translating from device space to babylon space.
  79202. */
  79203. deviceScaleFactor: number;
  79204. private _deviceToWorld;
  79205. private _worldToDevice;
  79206. /**
  79207. * References to the webVR controllers for the vrDevice.
  79208. */
  79209. controllers: Array<WebVRController>;
  79210. /**
  79211. * Emits an event when a controller is attached.
  79212. */
  79213. onControllersAttachedObservable: Observable<WebVRController[]>;
  79214. /**
  79215. * Emits an event when a controller's mesh has been loaded;
  79216. */
  79217. onControllerMeshLoadedObservable: Observable<WebVRController>;
  79218. /**
  79219. * Emits an event when the HMD's pose has been updated.
  79220. */
  79221. onPoseUpdatedFromDeviceObservable: Observable<any>;
  79222. private _poseSet;
  79223. /**
  79224. * If the rig cameras be used as parent instead of this camera.
  79225. */
  79226. rigParenting: boolean;
  79227. private _lightOnControllers;
  79228. private _defaultHeight?;
  79229. /**
  79230. * Instantiates a WebVRFreeCamera.
  79231. * @param name The name of the WebVRFreeCamera
  79232. * @param position The starting anchor position for the camera
  79233. * @param scene The scene the camera belongs to
  79234. * @param webVROptions a set of customizable options for the webVRCamera
  79235. */
  79236. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  79237. /**
  79238. * Gets the device distance from the ground in meters.
  79239. * @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.
  79240. */
  79241. deviceDistanceToRoomGround(): number;
  79242. /**
  79243. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79244. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  79245. */
  79246. useStandingMatrix(callback?: (bool: boolean) => void): void;
  79247. /**
  79248. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79249. * @returns A promise with a boolean set to if the standing matrix is supported.
  79250. */
  79251. useStandingMatrixAsync(): Promise<boolean>;
  79252. /**
  79253. * Disposes the camera
  79254. */
  79255. dispose(): void;
  79256. /**
  79257. * Gets a vrController by name.
  79258. * @param name The name of the controller to retreive
  79259. * @returns the controller matching the name specified or null if not found
  79260. */
  79261. getControllerByName(name: string): Nullable<WebVRController>;
  79262. private _leftController;
  79263. /**
  79264. * The controller corresponding to the users left hand.
  79265. */
  79266. readonly leftController: Nullable<WebVRController>;
  79267. private _rightController;
  79268. /**
  79269. * The controller corresponding to the users right hand.
  79270. */
  79271. readonly rightController: Nullable<WebVRController>;
  79272. /**
  79273. * Casts a ray forward from the vrCamera's gaze.
  79274. * @param length Length of the ray (default: 100)
  79275. * @returns the ray corresponding to the gaze
  79276. */
  79277. getForwardRay(length?: number): Ray;
  79278. /**
  79279. * @hidden
  79280. * Updates the camera based on device's frame data
  79281. */
  79282. _checkInputs(): void;
  79283. /**
  79284. * Updates the poseControlled values based on the input device pose.
  79285. * @param poseData Pose coming from the device
  79286. */
  79287. updateFromDevice(poseData: DevicePose): void;
  79288. private _htmlElementAttached;
  79289. private _detachIfAttached;
  79290. /**
  79291. * WebVR's attach control will start broadcasting frames to the device.
  79292. * Note that in certain browsers (chrome for example) this function must be called
  79293. * within a user-interaction callback. Example:
  79294. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  79295. *
  79296. * @param element html element to attach the vrDevice to
  79297. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  79298. */
  79299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79300. /**
  79301. * Detaches the camera from the html element and disables VR
  79302. *
  79303. * @param element html element to detach from
  79304. */
  79305. detachControl(element: HTMLElement): void;
  79306. /**
  79307. * @returns the name of this class
  79308. */
  79309. getClassName(): string;
  79310. /**
  79311. * Calls resetPose on the vrDisplay
  79312. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  79313. */
  79314. resetToCurrentRotation(): void;
  79315. /**
  79316. * @hidden
  79317. * Updates the rig cameras (left and right eye)
  79318. */
  79319. _updateRigCameras(): void;
  79320. private _workingVector;
  79321. private _oneVector;
  79322. private _workingMatrix;
  79323. private updateCacheCalled;
  79324. private _correctPositionIfNotTrackPosition;
  79325. /**
  79326. * @hidden
  79327. * Updates the cached values of the camera
  79328. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  79329. */
  79330. _updateCache(ignoreParentClass?: boolean): void;
  79331. /**
  79332. * @hidden
  79333. * Get current device position in babylon world
  79334. */
  79335. _computeDevicePosition(): void;
  79336. /**
  79337. * Updates the current device position and rotation in the babylon world
  79338. */
  79339. update(): void;
  79340. /**
  79341. * @hidden
  79342. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  79343. * @returns an identity matrix
  79344. */
  79345. _getViewMatrix(): Matrix;
  79346. private _tmpMatrix;
  79347. /**
  79348. * This function is called by the two RIG cameras.
  79349. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  79350. * @hidden
  79351. */
  79352. _getWebVRViewMatrix(): Matrix;
  79353. /** @hidden */
  79354. _getWebVRProjectionMatrix(): Matrix;
  79355. private _onGamepadConnectedObserver;
  79356. private _onGamepadDisconnectedObserver;
  79357. private _updateCacheWhenTrackingDisabledObserver;
  79358. /**
  79359. * Initializes the controllers and their meshes
  79360. */
  79361. initControllers(): void;
  79362. }
  79363. }
  79364. declare module BABYLON {
  79365. /**
  79366. * Size options for a post process
  79367. */
  79368. export type PostProcessOptions = {
  79369. width: number;
  79370. height: number;
  79371. };
  79372. /**
  79373. * PostProcess can be used to apply a shader to a texture after it has been rendered
  79374. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79375. */
  79376. export class PostProcess {
  79377. /** Name of the PostProcess. */
  79378. name: string;
  79379. /**
  79380. * Gets or sets the unique id of the post process
  79381. */
  79382. uniqueId: number;
  79383. /**
  79384. * Width of the texture to apply the post process on
  79385. */
  79386. width: number;
  79387. /**
  79388. * Height of the texture to apply the post process on
  79389. */
  79390. height: number;
  79391. /**
  79392. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  79393. * @hidden
  79394. */
  79395. _outputTexture: Nullable<InternalTexture>;
  79396. /**
  79397. * Sampling mode used by the shader
  79398. * See https://doc.babylonjs.com/classes/3.1/texture
  79399. */
  79400. renderTargetSamplingMode: number;
  79401. /**
  79402. * Clear color to use when screen clearing
  79403. */
  79404. clearColor: Color4;
  79405. /**
  79406. * If the buffer needs to be cleared before applying the post process. (default: true)
  79407. * Should be set to false if shader will overwrite all previous pixels.
  79408. */
  79409. autoClear: boolean;
  79410. /**
  79411. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  79412. */
  79413. alphaMode: number;
  79414. /**
  79415. * Sets the setAlphaBlendConstants of the babylon engine
  79416. */
  79417. alphaConstants: Color4;
  79418. /**
  79419. * Animations to be used for the post processing
  79420. */
  79421. animations: Animation[];
  79422. /**
  79423. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  79424. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  79425. */
  79426. enablePixelPerfectMode: boolean;
  79427. /**
  79428. * Force the postprocess to be applied without taking in account viewport
  79429. */
  79430. forceFullscreenViewport: boolean;
  79431. /**
  79432. * List of inspectable custom properties (used by the Inspector)
  79433. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79434. */
  79435. inspectableCustomProperties: IInspectable[];
  79436. /**
  79437. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  79438. *
  79439. * | Value | Type | Description |
  79440. * | ----- | ----------------------------------- | ----------- |
  79441. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  79442. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  79443. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  79444. *
  79445. */
  79446. scaleMode: number;
  79447. /**
  79448. * Force textures to be a power of two (default: false)
  79449. */
  79450. alwaysForcePOT: boolean;
  79451. private _samples;
  79452. /**
  79453. * Number of sample textures (default: 1)
  79454. */
  79455. samples: number;
  79456. /**
  79457. * Modify the scale of the post process to be the same as the viewport (default: false)
  79458. */
  79459. adaptScaleToCurrentViewport: boolean;
  79460. private _camera;
  79461. private _scene;
  79462. private _engine;
  79463. private _options;
  79464. private _reusable;
  79465. private _textureType;
  79466. /**
  79467. * Smart array of input and output textures for the post process.
  79468. * @hidden
  79469. */
  79470. _textures: SmartArray<InternalTexture>;
  79471. /**
  79472. * The index in _textures that corresponds to the output texture.
  79473. * @hidden
  79474. */
  79475. _currentRenderTextureInd: number;
  79476. private _effect;
  79477. private _samplers;
  79478. private _fragmentUrl;
  79479. private _vertexUrl;
  79480. private _parameters;
  79481. private _scaleRatio;
  79482. protected _indexParameters: any;
  79483. private _shareOutputWithPostProcess;
  79484. private _texelSize;
  79485. private _forcedOutputTexture;
  79486. /**
  79487. * Returns the fragment url or shader name used in the post process.
  79488. * @returns the fragment url or name in the shader store.
  79489. */
  79490. getEffectName(): string;
  79491. /**
  79492. * An event triggered when the postprocess is activated.
  79493. */
  79494. onActivateObservable: Observable<Camera>;
  79495. private _onActivateObserver;
  79496. /**
  79497. * A function that is added to the onActivateObservable
  79498. */
  79499. onActivate: Nullable<(camera: Camera) => void>;
  79500. /**
  79501. * An event triggered when the postprocess changes its size.
  79502. */
  79503. onSizeChangedObservable: Observable<PostProcess>;
  79504. private _onSizeChangedObserver;
  79505. /**
  79506. * A function that is added to the onSizeChangedObservable
  79507. */
  79508. onSizeChanged: (postProcess: PostProcess) => void;
  79509. /**
  79510. * An event triggered when the postprocess applies its effect.
  79511. */
  79512. onApplyObservable: Observable<Effect>;
  79513. private _onApplyObserver;
  79514. /**
  79515. * A function that is added to the onApplyObservable
  79516. */
  79517. onApply: (effect: Effect) => void;
  79518. /**
  79519. * An event triggered before rendering the postprocess
  79520. */
  79521. onBeforeRenderObservable: Observable<Effect>;
  79522. private _onBeforeRenderObserver;
  79523. /**
  79524. * A function that is added to the onBeforeRenderObservable
  79525. */
  79526. onBeforeRender: (effect: Effect) => void;
  79527. /**
  79528. * An event triggered after rendering the postprocess
  79529. */
  79530. onAfterRenderObservable: Observable<Effect>;
  79531. private _onAfterRenderObserver;
  79532. /**
  79533. * A function that is added to the onAfterRenderObservable
  79534. */
  79535. onAfterRender: (efect: Effect) => void;
  79536. /**
  79537. * 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
  79538. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  79539. */
  79540. inputTexture: InternalTexture;
  79541. /**
  79542. * Gets the camera which post process is applied to.
  79543. * @returns The camera the post process is applied to.
  79544. */
  79545. getCamera(): Camera;
  79546. /**
  79547. * Gets the texel size of the postprocess.
  79548. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  79549. */
  79550. readonly texelSize: Vector2;
  79551. /**
  79552. * Creates a new instance PostProcess
  79553. * @param name The name of the PostProcess.
  79554. * @param fragmentUrl The url of the fragment shader to be used.
  79555. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  79556. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  79557. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79558. * @param camera The camera to apply the render pass to.
  79559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79560. * @param engine The engine which the post process will be applied. (default: current engine)
  79561. * @param reusable If the post process can be reused on the same frame. (default: false)
  79562. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  79563. * @param textureType Type of textures used when performing the post process. (default: 0)
  79564. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  79565. * @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
  79566. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  79567. */
  79568. constructor(
  79569. /** Name of the PostProcess. */
  79570. 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);
  79571. /**
  79572. * Gets a string idenfifying the name of the class
  79573. * @returns "PostProcess" string
  79574. */
  79575. getClassName(): string;
  79576. /**
  79577. * Gets the engine which this post process belongs to.
  79578. * @returns The engine the post process was enabled with.
  79579. */
  79580. getEngine(): Engine;
  79581. /**
  79582. * The effect that is created when initializing the post process.
  79583. * @returns The created effect corresponding the the postprocess.
  79584. */
  79585. getEffect(): Effect;
  79586. /**
  79587. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  79588. * @param postProcess The post process to share the output with.
  79589. * @returns This post process.
  79590. */
  79591. shareOutputWith(postProcess: PostProcess): PostProcess;
  79592. /**
  79593. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  79594. * This should be called if the post process that shares output with this post process is disabled/disposed.
  79595. */
  79596. useOwnOutput(): void;
  79597. /**
  79598. * Updates the effect with the current post process compile time values and recompiles the shader.
  79599. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79600. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79601. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79602. * @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
  79603. * @param onCompiled Called when the shader has been compiled.
  79604. * @param onError Called if there is an error when compiling a shader.
  79605. */
  79606. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79607. /**
  79608. * The post process is reusable if it can be used multiple times within one frame.
  79609. * @returns If the post process is reusable
  79610. */
  79611. isReusable(): boolean;
  79612. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  79613. markTextureDirty(): void;
  79614. /**
  79615. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  79616. * 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.
  79617. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  79618. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  79619. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  79620. * @returns The target texture that was bound to be written to.
  79621. */
  79622. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  79623. /**
  79624. * If the post process is supported.
  79625. */
  79626. readonly isSupported: boolean;
  79627. /**
  79628. * The aspect ratio of the output texture.
  79629. */
  79630. readonly aspectRatio: number;
  79631. /**
  79632. * Get a value indicating if the post-process is ready to be used
  79633. * @returns true if the post-process is ready (shader is compiled)
  79634. */
  79635. isReady(): boolean;
  79636. /**
  79637. * Binds all textures and uniforms to the shader, this will be run on every pass.
  79638. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  79639. */
  79640. apply(): Nullable<Effect>;
  79641. private _disposeTextures;
  79642. /**
  79643. * Disposes the post process.
  79644. * @param camera The camera to dispose the post process on.
  79645. */
  79646. dispose(camera?: Camera): void;
  79647. }
  79648. }
  79649. declare module BABYLON {
  79650. /** @hidden */
  79651. export var kernelBlurVaryingDeclaration: {
  79652. name: string;
  79653. shader: string;
  79654. };
  79655. }
  79656. declare module BABYLON {
  79657. /** @hidden */
  79658. export var kernelBlurFragment: {
  79659. name: string;
  79660. shader: string;
  79661. };
  79662. }
  79663. declare module BABYLON {
  79664. /** @hidden */
  79665. export var kernelBlurFragment2: {
  79666. name: string;
  79667. shader: string;
  79668. };
  79669. }
  79670. declare module BABYLON {
  79671. /** @hidden */
  79672. export var kernelBlurPixelShader: {
  79673. name: string;
  79674. shader: string;
  79675. };
  79676. }
  79677. declare module BABYLON {
  79678. /** @hidden */
  79679. export var kernelBlurVertex: {
  79680. name: string;
  79681. shader: string;
  79682. };
  79683. }
  79684. declare module BABYLON {
  79685. /** @hidden */
  79686. export var kernelBlurVertexShader: {
  79687. name: string;
  79688. shader: string;
  79689. };
  79690. }
  79691. declare module BABYLON {
  79692. /**
  79693. * The Blur Post Process which blurs an image based on a kernel and direction.
  79694. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79695. */
  79696. export class BlurPostProcess extends PostProcess {
  79697. /** The direction in which to blur the image. */
  79698. direction: Vector2;
  79699. private blockCompilation;
  79700. protected _kernel: number;
  79701. protected _idealKernel: number;
  79702. protected _packedFloat: boolean;
  79703. private _staticDefines;
  79704. /**
  79705. * Sets the length in pixels of the blur sample region
  79706. */
  79707. /**
  79708. * Gets the length in pixels of the blur sample region
  79709. */
  79710. kernel: number;
  79711. /**
  79712. * Sets wether or not the blur needs to unpack/repack floats
  79713. */
  79714. /**
  79715. * Gets wether or not the blur is unpacking/repacking floats
  79716. */
  79717. packedFloat: boolean;
  79718. /**
  79719. * Creates a new instance BlurPostProcess
  79720. * @param name The name of the effect.
  79721. * @param direction The direction in which to blur the image.
  79722. * @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.
  79723. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79724. * @param camera The camera to apply the render pass to.
  79725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79726. * @param engine The engine which the post process will be applied. (default: current engine)
  79727. * @param reusable If the post process can be reused on the same frame. (default: false)
  79728. * @param textureType Type of textures used when performing the post process. (default: 0)
  79729. * @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)
  79730. */
  79731. constructor(name: string,
  79732. /** The direction in which to blur the image. */
  79733. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  79734. /**
  79735. * Updates the effect with the current post process compile time values and recompiles the shader.
  79736. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79737. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79738. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79739. * @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
  79740. * @param onCompiled Called when the shader has been compiled.
  79741. * @param onError Called if there is an error when compiling a shader.
  79742. */
  79743. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79744. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79745. /**
  79746. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  79747. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  79748. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  79749. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  79750. * The gaps between physical kernels are compensated for in the weighting of the samples
  79751. * @param idealKernel Ideal blur kernel.
  79752. * @return Nearest best kernel.
  79753. */
  79754. protected _nearestBestKernel(idealKernel: number): number;
  79755. /**
  79756. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79757. * @param x The point on the Gaussian distribution to sample.
  79758. * @return the value of the Gaussian function at x.
  79759. */
  79760. protected _gaussianWeight(x: number): number;
  79761. /**
  79762. * Generates a string that can be used as a floating point number in GLSL.
  79763. * @param x Value to print.
  79764. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79765. * @return GLSL float string.
  79766. */
  79767. protected _glslFloat(x: number, decimalFigures?: number): string;
  79768. }
  79769. }
  79770. declare module BABYLON {
  79771. /**
  79772. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79773. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79774. * You can then easily use it as a reflectionTexture on a flat surface.
  79775. * In case the surface is not a plane, please consider relying on reflection probes.
  79776. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79777. */
  79778. export class MirrorTexture extends RenderTargetTexture {
  79779. private scene;
  79780. /**
  79781. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79782. * 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.
  79783. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79784. */
  79785. mirrorPlane: Plane;
  79786. /**
  79787. * Define the blur ratio used to blur the reflection if needed.
  79788. */
  79789. blurRatio: number;
  79790. /**
  79791. * Define the adaptive blur kernel used to blur the reflection if needed.
  79792. * This will autocompute the closest best match for the `blurKernel`
  79793. */
  79794. adaptiveBlurKernel: number;
  79795. /**
  79796. * Define the blur kernel used to blur the reflection if needed.
  79797. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79798. */
  79799. blurKernel: number;
  79800. /**
  79801. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79802. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79803. */
  79804. blurKernelX: number;
  79805. /**
  79806. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79807. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79808. */
  79809. blurKernelY: number;
  79810. private _autoComputeBlurKernel;
  79811. protected _onRatioRescale(): void;
  79812. private _updateGammaSpace;
  79813. private _imageProcessingConfigChangeObserver;
  79814. private _transformMatrix;
  79815. private _mirrorMatrix;
  79816. private _savedViewMatrix;
  79817. private _blurX;
  79818. private _blurY;
  79819. private _adaptiveBlurKernel;
  79820. private _blurKernelX;
  79821. private _blurKernelY;
  79822. private _blurRatio;
  79823. /**
  79824. * Instantiates a Mirror Texture.
  79825. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79826. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79827. * You can then easily use it as a reflectionTexture on a flat surface.
  79828. * In case the surface is not a plane, please consider relying on reflection probes.
  79829. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79830. * @param name
  79831. * @param size
  79832. * @param scene
  79833. * @param generateMipMaps
  79834. * @param type
  79835. * @param samplingMode
  79836. * @param generateDepthBuffer
  79837. */
  79838. constructor(name: string, size: number | {
  79839. width: number;
  79840. height: number;
  79841. } | {
  79842. ratio: number;
  79843. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  79844. private _preparePostProcesses;
  79845. /**
  79846. * Clone the mirror texture.
  79847. * @returns the cloned texture
  79848. */
  79849. clone(): MirrorTexture;
  79850. /**
  79851. * Serialize the texture to a JSON representation you could use in Parse later on
  79852. * @returns the serialized JSON representation
  79853. */
  79854. serialize(): any;
  79855. /**
  79856. * Dispose the texture and release its associated resources.
  79857. */
  79858. dispose(): void;
  79859. }
  79860. }
  79861. declare module BABYLON {
  79862. /**
  79863. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79864. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79865. */
  79866. export class Texture extends BaseTexture {
  79867. /** @hidden */
  79868. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  79869. /** @hidden */
  79870. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  79871. /** @hidden */
  79872. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  79873. /** nearest is mag = nearest and min = nearest and mip = linear */
  79874. static readonly NEAREST_SAMPLINGMODE: number;
  79875. /** nearest is mag = nearest and min = nearest and mip = linear */
  79876. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  79877. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79878. static readonly BILINEAR_SAMPLINGMODE: number;
  79879. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79880. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  79881. /** Trilinear is mag = linear and min = linear and mip = linear */
  79882. static readonly TRILINEAR_SAMPLINGMODE: number;
  79883. /** Trilinear is mag = linear and min = linear and mip = linear */
  79884. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  79885. /** mag = nearest and min = nearest and mip = nearest */
  79886. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  79887. /** mag = nearest and min = linear and mip = nearest */
  79888. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  79889. /** mag = nearest and min = linear and mip = linear */
  79890. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  79891. /** mag = nearest and min = linear and mip = none */
  79892. static readonly NEAREST_LINEAR: number;
  79893. /** mag = nearest and min = nearest and mip = none */
  79894. static readonly NEAREST_NEAREST: number;
  79895. /** mag = linear and min = nearest and mip = nearest */
  79896. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  79897. /** mag = linear and min = nearest and mip = linear */
  79898. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  79899. /** mag = linear and min = linear and mip = none */
  79900. static readonly LINEAR_LINEAR: number;
  79901. /** mag = linear and min = nearest and mip = none */
  79902. static readonly LINEAR_NEAREST: number;
  79903. /** Explicit coordinates mode */
  79904. static readonly EXPLICIT_MODE: number;
  79905. /** Spherical coordinates mode */
  79906. static readonly SPHERICAL_MODE: number;
  79907. /** Planar coordinates mode */
  79908. static readonly PLANAR_MODE: number;
  79909. /** Cubic coordinates mode */
  79910. static readonly CUBIC_MODE: number;
  79911. /** Projection coordinates mode */
  79912. static readonly PROJECTION_MODE: number;
  79913. /** Inverse Cubic coordinates mode */
  79914. static readonly SKYBOX_MODE: number;
  79915. /** Inverse Cubic coordinates mode */
  79916. static readonly INVCUBIC_MODE: number;
  79917. /** Equirectangular coordinates mode */
  79918. static readonly EQUIRECTANGULAR_MODE: number;
  79919. /** Equirectangular Fixed coordinates mode */
  79920. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  79921. /** Equirectangular Fixed Mirrored coordinates mode */
  79922. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79923. /** Texture is not repeating outside of 0..1 UVs */
  79924. static readonly CLAMP_ADDRESSMODE: number;
  79925. /** Texture is repeating outside of 0..1 UVs */
  79926. static readonly WRAP_ADDRESSMODE: number;
  79927. /** Texture is repeating and mirrored */
  79928. static readonly MIRROR_ADDRESSMODE: number;
  79929. /**
  79930. * 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
  79931. */
  79932. static UseSerializedUrlIfAny: boolean;
  79933. /**
  79934. * Define the url of the texture.
  79935. */
  79936. url: Nullable<string>;
  79937. /**
  79938. * Define an offset on the texture to offset the u coordinates of the UVs
  79939. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79940. */
  79941. uOffset: number;
  79942. /**
  79943. * Define an offset on the texture to offset the v coordinates of the UVs
  79944. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79945. */
  79946. vOffset: number;
  79947. /**
  79948. * Define an offset on the texture to scale the u coordinates of the UVs
  79949. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79950. */
  79951. uScale: number;
  79952. /**
  79953. * Define an offset on the texture to scale the v coordinates of the UVs
  79954. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79955. */
  79956. vScale: number;
  79957. /**
  79958. * Define an offset on the texture to rotate around the u coordinates of the UVs
  79959. * @see http://doc.babylonjs.com/how_to/more_materials
  79960. */
  79961. uAng: number;
  79962. /**
  79963. * Define an offset on the texture to rotate around the v coordinates of the UVs
  79964. * @see http://doc.babylonjs.com/how_to/more_materials
  79965. */
  79966. vAng: number;
  79967. /**
  79968. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  79969. * @see http://doc.babylonjs.com/how_to/more_materials
  79970. */
  79971. wAng: number;
  79972. /**
  79973. * Defines the center of rotation (U)
  79974. */
  79975. uRotationCenter: number;
  79976. /**
  79977. * Defines the center of rotation (V)
  79978. */
  79979. vRotationCenter: number;
  79980. /**
  79981. * Defines the center of rotation (W)
  79982. */
  79983. wRotationCenter: number;
  79984. /**
  79985. * Are mip maps generated for this texture or not.
  79986. */
  79987. readonly noMipmap: boolean;
  79988. /**
  79989. * List of inspectable custom properties (used by the Inspector)
  79990. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79991. */
  79992. inspectableCustomProperties: Nullable<IInspectable[]>;
  79993. private _noMipmap;
  79994. /** @hidden */
  79995. _invertY: boolean;
  79996. private _rowGenerationMatrix;
  79997. private _cachedTextureMatrix;
  79998. private _projectionModeMatrix;
  79999. private _t0;
  80000. private _t1;
  80001. private _t2;
  80002. private _cachedUOffset;
  80003. private _cachedVOffset;
  80004. private _cachedUScale;
  80005. private _cachedVScale;
  80006. private _cachedUAng;
  80007. private _cachedVAng;
  80008. private _cachedWAng;
  80009. private _cachedProjectionMatrixId;
  80010. private _cachedCoordinatesMode;
  80011. /** @hidden */
  80012. protected _initialSamplingMode: number;
  80013. /** @hidden */
  80014. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80015. private _deleteBuffer;
  80016. protected _format: Nullable<number>;
  80017. private _delayedOnLoad;
  80018. private _delayedOnError;
  80019. /**
  80020. * Observable triggered once the texture has been loaded.
  80021. */
  80022. onLoadObservable: Observable<Texture>;
  80023. protected _isBlocking: boolean;
  80024. /**
  80025. * Is the texture preventing material to render while loading.
  80026. * If false, a default texture will be used instead of the loading one during the preparation step.
  80027. */
  80028. isBlocking: boolean;
  80029. /**
  80030. * Get the current sampling mode associated with the texture.
  80031. */
  80032. readonly samplingMode: number;
  80033. /**
  80034. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80035. */
  80036. readonly invertY: boolean;
  80037. /**
  80038. * Instantiates a new texture.
  80039. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80040. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80041. * @param url define the url of the picture to load as a texture
  80042. * @param scene define the scene or engine the texture will belong to
  80043. * @param noMipmap define if the texture will require mip maps or not
  80044. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80045. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80046. * @param onLoad define a callback triggered when the texture has been loaded
  80047. * @param onError define a callback triggered when an error occurred during the loading session
  80048. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80049. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80050. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80051. */
  80052. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, 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);
  80053. /**
  80054. * Update the url (and optional buffer) of this texture if url was null during construction.
  80055. * @param url the url of the texture
  80056. * @param buffer the buffer of the texture (defaults to null)
  80057. * @param onLoad callback called when the texture is loaded (defaults to null)
  80058. */
  80059. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80060. /**
  80061. * Finish the loading sequence of a texture flagged as delayed load.
  80062. * @hidden
  80063. */
  80064. delayLoad(): void;
  80065. private _prepareRowForTextureGeneration;
  80066. /**
  80067. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80068. * @returns the transform matrix of the texture.
  80069. */
  80070. getTextureMatrix(): Matrix;
  80071. /**
  80072. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80073. * @returns The reflection texture transform
  80074. */
  80075. getReflectionTextureMatrix(): Matrix;
  80076. /**
  80077. * Clones the texture.
  80078. * @returns the cloned texture
  80079. */
  80080. clone(): Texture;
  80081. /**
  80082. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80083. * @returns The JSON representation of the texture
  80084. */
  80085. serialize(): any;
  80086. /**
  80087. * Get the current class name of the texture useful for serialization or dynamic coding.
  80088. * @returns "Texture"
  80089. */
  80090. getClassName(): string;
  80091. /**
  80092. * Dispose the texture and release its associated resources.
  80093. */
  80094. dispose(): void;
  80095. /**
  80096. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80097. * @param parsedTexture Define the JSON representation of the texture
  80098. * @param scene Define the scene the parsed texture should be instantiated in
  80099. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80100. * @returns The parsed texture if successful
  80101. */
  80102. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80103. /**
  80104. * Creates a texture from its base 64 representation.
  80105. * @param data Define the base64 payload without the data: prefix
  80106. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80107. * @param scene Define the scene the texture should belong to
  80108. * @param noMipmap Forces the texture to not create mip map information if true
  80109. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80110. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80111. * @param onLoad define a callback triggered when the texture has been loaded
  80112. * @param onError define a callback triggered when an error occurred during the loading session
  80113. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80114. * @returns the created texture
  80115. */
  80116. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80117. /**
  80118. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80119. * @param data Define the base64 payload without the data: prefix
  80120. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80121. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80122. * @param scene Define the scene the texture should belong to
  80123. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80124. * @param noMipmap Forces the texture to not create mip map information if true
  80125. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80126. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80127. * @param onLoad define a callback triggered when the texture has been loaded
  80128. * @param onError define a callback triggered when an error occurred during the loading session
  80129. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80130. * @returns the created texture
  80131. */
  80132. 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;
  80133. }
  80134. }
  80135. declare module BABYLON {
  80136. /**
  80137. * PostProcessManager is used to manage one or more post processes or post process pipelines
  80138. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80139. */
  80140. export class PostProcessManager {
  80141. private _scene;
  80142. private _indexBuffer;
  80143. private _vertexBuffers;
  80144. /**
  80145. * Creates a new instance PostProcess
  80146. * @param scene The scene that the post process is associated with.
  80147. */
  80148. constructor(scene: Scene);
  80149. private _prepareBuffers;
  80150. private _buildIndexBuffer;
  80151. /**
  80152. * Rebuilds the vertex buffers of the manager.
  80153. * @hidden
  80154. */
  80155. _rebuild(): void;
  80156. /**
  80157. * Prepares a frame to be run through a post process.
  80158. * @param sourceTexture The input texture to the post procesess. (default: null)
  80159. * @param postProcesses An array of post processes to be run. (default: null)
  80160. * @returns True if the post processes were able to be run.
  80161. * @hidden
  80162. */
  80163. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  80164. /**
  80165. * Manually render a set of post processes to a texture.
  80166. * @param postProcesses An array of post processes to be run.
  80167. * @param targetTexture The target texture to render to.
  80168. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  80169. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  80170. * @param lodLevel defines which lod of the texture to render to
  80171. */
  80172. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  80173. /**
  80174. * Finalize the result of the output of the postprocesses.
  80175. * @param doNotPresent If true the result will not be displayed to the screen.
  80176. * @param targetTexture The target texture to render to.
  80177. * @param faceIndex The index of the face to bind the target texture to.
  80178. * @param postProcesses The array of post processes to render.
  80179. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  80180. * @hidden
  80181. */
  80182. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  80183. /**
  80184. * Disposes of the post process manager.
  80185. */
  80186. dispose(): void;
  80187. }
  80188. }
  80189. declare module BABYLON {
  80190. /** Interface used by value gradients (color, factor, ...) */
  80191. export interface IValueGradient {
  80192. /**
  80193. * Gets or sets the gradient value (between 0 and 1)
  80194. */
  80195. gradient: number;
  80196. }
  80197. /** Class used to store color4 gradient */
  80198. export class ColorGradient implements IValueGradient {
  80199. /**
  80200. * Gets or sets the gradient value (between 0 and 1)
  80201. */
  80202. gradient: number;
  80203. /**
  80204. * Gets or sets first associated color
  80205. */
  80206. color1: Color4;
  80207. /**
  80208. * Gets or sets second associated color
  80209. */
  80210. color2?: Color4;
  80211. /**
  80212. * Will get a color picked randomly between color1 and color2.
  80213. * If color2 is undefined then color1 will be used
  80214. * @param result defines the target Color4 to store the result in
  80215. */
  80216. getColorToRef(result: Color4): void;
  80217. }
  80218. /** Class used to store color 3 gradient */
  80219. export class Color3Gradient implements IValueGradient {
  80220. /**
  80221. * Gets or sets the gradient value (between 0 and 1)
  80222. */
  80223. gradient: number;
  80224. /**
  80225. * Gets or sets the associated color
  80226. */
  80227. color: Color3;
  80228. }
  80229. /** Class used to store factor gradient */
  80230. export class FactorGradient implements IValueGradient {
  80231. /**
  80232. * Gets or sets the gradient value (between 0 and 1)
  80233. */
  80234. gradient: number;
  80235. /**
  80236. * Gets or sets first associated factor
  80237. */
  80238. factor1: number;
  80239. /**
  80240. * Gets or sets second associated factor
  80241. */
  80242. factor2?: number;
  80243. /**
  80244. * Will get a number picked randomly between factor1 and factor2.
  80245. * If factor2 is undefined then factor1 will be used
  80246. * @returns the picked number
  80247. */
  80248. getFactor(): number;
  80249. }
  80250. /**
  80251. * Helper used to simplify some generic gradient tasks
  80252. */
  80253. export class GradientHelper {
  80254. /**
  80255. * Gets the current gradient from an array of IValueGradient
  80256. * @param ratio defines the current ratio to get
  80257. * @param gradients defines the array of IValueGradient
  80258. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  80259. */
  80260. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  80261. }
  80262. }
  80263. declare module BABYLON {
  80264. interface AbstractScene {
  80265. /**
  80266. * The list of procedural textures added to the scene
  80267. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80268. */
  80269. proceduralTextures: Array<ProceduralTexture>;
  80270. }
  80271. /**
  80272. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  80273. * in a given scene.
  80274. */
  80275. export class ProceduralTextureSceneComponent implements ISceneComponent {
  80276. /**
  80277. * The component name helpfull to identify the component in the list of scene components.
  80278. */
  80279. readonly name: string;
  80280. /**
  80281. * The scene the component belongs to.
  80282. */
  80283. scene: Scene;
  80284. /**
  80285. * Creates a new instance of the component for the given scene
  80286. * @param scene Defines the scene to register the component in
  80287. */
  80288. constructor(scene: Scene);
  80289. /**
  80290. * Registers the component in a given scene
  80291. */
  80292. register(): void;
  80293. /**
  80294. * Rebuilds the elements related to this component in case of
  80295. * context lost for instance.
  80296. */
  80297. rebuild(): void;
  80298. /**
  80299. * Disposes the component and the associated ressources.
  80300. */
  80301. dispose(): void;
  80302. private _beforeClear;
  80303. }
  80304. }
  80305. declare module BABYLON {
  80306. interface Engine {
  80307. /**
  80308. * Creates a new render target cube texture
  80309. * @param size defines the size of the texture
  80310. * @param options defines the options used to create the texture
  80311. * @returns a new render target cube texture stored in an InternalTexture
  80312. */
  80313. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  80314. }
  80315. }
  80316. declare module BABYLON {
  80317. /** @hidden */
  80318. export var proceduralVertexShader: {
  80319. name: string;
  80320. shader: string;
  80321. };
  80322. }
  80323. declare module BABYLON {
  80324. /**
  80325. * 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.
  80326. * This is the base class of any Procedural texture and contains most of the shareable code.
  80327. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80328. */
  80329. export class ProceduralTexture extends Texture {
  80330. isCube: boolean;
  80331. /**
  80332. * Define if the texture is enabled or not (disabled texture will not render)
  80333. */
  80334. isEnabled: boolean;
  80335. /**
  80336. * Define if the texture must be cleared before rendering (default is true)
  80337. */
  80338. autoClear: boolean;
  80339. /**
  80340. * Callback called when the texture is generated
  80341. */
  80342. onGenerated: () => void;
  80343. /**
  80344. * Event raised when the texture is generated
  80345. */
  80346. onGeneratedObservable: Observable<ProceduralTexture>;
  80347. /** @hidden */
  80348. _generateMipMaps: boolean;
  80349. /** @hidden **/
  80350. _effect: Effect;
  80351. /** @hidden */
  80352. _textures: {
  80353. [key: string]: Texture;
  80354. };
  80355. private _size;
  80356. private _currentRefreshId;
  80357. private _refreshRate;
  80358. private _vertexBuffers;
  80359. private _indexBuffer;
  80360. private _uniforms;
  80361. private _samplers;
  80362. private _fragment;
  80363. private _floats;
  80364. private _ints;
  80365. private _floatsArrays;
  80366. private _colors3;
  80367. private _colors4;
  80368. private _vectors2;
  80369. private _vectors3;
  80370. private _matrices;
  80371. private _fallbackTexture;
  80372. private _fallbackTextureUsed;
  80373. private _engine;
  80374. private _cachedDefines;
  80375. private _contentUpdateId;
  80376. private _contentData;
  80377. /**
  80378. * Instantiates a new procedural texture.
  80379. * 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.
  80380. * This is the base class of any Procedural texture and contains most of the shareable code.
  80381. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80382. * @param name Define the name of the texture
  80383. * @param size Define the size of the texture to create
  80384. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  80385. * @param scene Define the scene the texture belongs to
  80386. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  80387. * @param generateMipMaps Define if the texture should creates mip maps or not
  80388. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  80389. */
  80390. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  80391. /**
  80392. * The effect that is created when initializing the post process.
  80393. * @returns The created effect corresponding the the postprocess.
  80394. */
  80395. getEffect(): Effect;
  80396. /**
  80397. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  80398. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  80399. */
  80400. getContent(): Nullable<ArrayBufferView>;
  80401. private _createIndexBuffer;
  80402. /** @hidden */
  80403. _rebuild(): void;
  80404. /**
  80405. * Resets the texture in order to recreate its associated resources.
  80406. * This can be called in case of context loss
  80407. */
  80408. reset(): void;
  80409. protected _getDefines(): string;
  80410. /**
  80411. * Is the texture ready to be used ? (rendered at least once)
  80412. * @returns true if ready, otherwise, false.
  80413. */
  80414. isReady(): boolean;
  80415. /**
  80416. * Resets the refresh counter of the texture and start bak from scratch.
  80417. * Could be useful to regenerate the texture if it is setup to render only once.
  80418. */
  80419. resetRefreshCounter(): void;
  80420. /**
  80421. * Set the fragment shader to use in order to render the texture.
  80422. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  80423. */
  80424. setFragment(fragment: any): void;
  80425. /**
  80426. * Define the refresh rate of the texture or the rendering frequency.
  80427. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  80428. */
  80429. refreshRate: number;
  80430. /** @hidden */
  80431. _shouldRender(): boolean;
  80432. /**
  80433. * Get the size the texture is rendering at.
  80434. * @returns the size (texture is always squared)
  80435. */
  80436. getRenderSize(): number;
  80437. /**
  80438. * Resize the texture to new value.
  80439. * @param size Define the new size the texture should have
  80440. * @param generateMipMaps Define whether the new texture should create mip maps
  80441. */
  80442. resize(size: number, generateMipMaps: boolean): void;
  80443. private _checkUniform;
  80444. /**
  80445. * Set a texture in the shader program used to render.
  80446. * @param name Define the name of the uniform samplers as defined in the shader
  80447. * @param texture Define the texture to bind to this sampler
  80448. * @return the texture itself allowing "fluent" like uniform updates
  80449. */
  80450. setTexture(name: string, texture: Texture): ProceduralTexture;
  80451. /**
  80452. * Set a float in the shader.
  80453. * @param name Define the name of the uniform as defined in the shader
  80454. * @param value Define the value to give to the uniform
  80455. * @return the texture itself allowing "fluent" like uniform updates
  80456. */
  80457. setFloat(name: string, value: number): ProceduralTexture;
  80458. /**
  80459. * Set a int in the shader.
  80460. * @param name Define the name of the uniform as defined in the shader
  80461. * @param value Define the value to give to the uniform
  80462. * @return the texture itself allowing "fluent" like uniform updates
  80463. */
  80464. setInt(name: string, value: number): ProceduralTexture;
  80465. /**
  80466. * Set an array of floats in the shader.
  80467. * @param name Define the name of the uniform as defined in the shader
  80468. * @param value Define the value to give to the uniform
  80469. * @return the texture itself allowing "fluent" like uniform updates
  80470. */
  80471. setFloats(name: string, value: number[]): ProceduralTexture;
  80472. /**
  80473. * Set a vec3 in the shader from a Color3.
  80474. * @param name Define the name of the uniform as defined in the shader
  80475. * @param value Define the value to give to the uniform
  80476. * @return the texture itself allowing "fluent" like uniform updates
  80477. */
  80478. setColor3(name: string, value: Color3): ProceduralTexture;
  80479. /**
  80480. * Set a vec4 in the shader from a Color4.
  80481. * @param name Define the name of the uniform as defined in the shader
  80482. * @param value Define the value to give to the uniform
  80483. * @return the texture itself allowing "fluent" like uniform updates
  80484. */
  80485. setColor4(name: string, value: Color4): ProceduralTexture;
  80486. /**
  80487. * Set a vec2 in the shader from a Vector2.
  80488. * @param name Define the name of the uniform as defined in the shader
  80489. * @param value Define the value to give to the uniform
  80490. * @return the texture itself allowing "fluent" like uniform updates
  80491. */
  80492. setVector2(name: string, value: Vector2): ProceduralTexture;
  80493. /**
  80494. * Set a vec3 in the shader from a Vector3.
  80495. * @param name Define the name of the uniform as defined in the shader
  80496. * @param value Define the value to give to the uniform
  80497. * @return the texture itself allowing "fluent" like uniform updates
  80498. */
  80499. setVector3(name: string, value: Vector3): ProceduralTexture;
  80500. /**
  80501. * Set a mat4 in the shader from a MAtrix.
  80502. * @param name Define the name of the uniform as defined in the shader
  80503. * @param value Define the value to give to the uniform
  80504. * @return the texture itself allowing "fluent" like uniform updates
  80505. */
  80506. setMatrix(name: string, value: Matrix): ProceduralTexture;
  80507. /**
  80508. * Render the texture to its associated render target.
  80509. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  80510. */
  80511. render(useCameraPostProcess?: boolean): void;
  80512. /**
  80513. * Clone the texture.
  80514. * @returns the cloned texture
  80515. */
  80516. clone(): ProceduralTexture;
  80517. /**
  80518. * Dispose the texture and release its asoociated resources.
  80519. */
  80520. dispose(): void;
  80521. }
  80522. }
  80523. declare module BABYLON {
  80524. /**
  80525. * This represents the base class for particle system in Babylon.
  80526. * 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.
  80527. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80528. * @example https://doc.babylonjs.com/babylon101/particles
  80529. */
  80530. export class BaseParticleSystem {
  80531. /**
  80532. * Source color is added to the destination color without alpha affecting the result
  80533. */
  80534. static BLENDMODE_ONEONE: number;
  80535. /**
  80536. * Blend current color and particle color using particle’s alpha
  80537. */
  80538. static BLENDMODE_STANDARD: number;
  80539. /**
  80540. * Add current color and particle color multiplied by particle’s alpha
  80541. */
  80542. static BLENDMODE_ADD: number;
  80543. /**
  80544. * Multiply current color with particle color
  80545. */
  80546. static BLENDMODE_MULTIPLY: number;
  80547. /**
  80548. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  80549. */
  80550. static BLENDMODE_MULTIPLYADD: number;
  80551. /**
  80552. * List of animations used by the particle system.
  80553. */
  80554. animations: Animation[];
  80555. /**
  80556. * The id of the Particle system.
  80557. */
  80558. id: string;
  80559. /**
  80560. * The friendly name of the Particle system.
  80561. */
  80562. name: string;
  80563. /**
  80564. * The rendering group used by the Particle system to chose when to render.
  80565. */
  80566. renderingGroupId: number;
  80567. /**
  80568. * The emitter represents the Mesh or position we are attaching the particle system to.
  80569. */
  80570. emitter: Nullable<AbstractMesh | Vector3>;
  80571. /**
  80572. * The maximum number of particles to emit per frame
  80573. */
  80574. emitRate: number;
  80575. /**
  80576. * If you want to launch only a few particles at once, that can be done, as well.
  80577. */
  80578. manualEmitCount: number;
  80579. /**
  80580. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  80581. */
  80582. updateSpeed: number;
  80583. /**
  80584. * The amount of time the particle system is running (depends of the overall update speed).
  80585. */
  80586. targetStopDuration: number;
  80587. /**
  80588. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  80589. */
  80590. disposeOnStop: boolean;
  80591. /**
  80592. * Minimum power of emitting particles.
  80593. */
  80594. minEmitPower: number;
  80595. /**
  80596. * Maximum power of emitting particles.
  80597. */
  80598. maxEmitPower: number;
  80599. /**
  80600. * Minimum life time of emitting particles.
  80601. */
  80602. minLifeTime: number;
  80603. /**
  80604. * Maximum life time of emitting particles.
  80605. */
  80606. maxLifeTime: number;
  80607. /**
  80608. * Minimum Size of emitting particles.
  80609. */
  80610. minSize: number;
  80611. /**
  80612. * Maximum Size of emitting particles.
  80613. */
  80614. maxSize: number;
  80615. /**
  80616. * Minimum scale of emitting particles on X axis.
  80617. */
  80618. minScaleX: number;
  80619. /**
  80620. * Maximum scale of emitting particles on X axis.
  80621. */
  80622. maxScaleX: number;
  80623. /**
  80624. * Minimum scale of emitting particles on Y axis.
  80625. */
  80626. minScaleY: number;
  80627. /**
  80628. * Maximum scale of emitting particles on Y axis.
  80629. */
  80630. maxScaleY: number;
  80631. /**
  80632. * Gets or sets the minimal initial rotation in radians.
  80633. */
  80634. minInitialRotation: number;
  80635. /**
  80636. * Gets or sets the maximal initial rotation in radians.
  80637. */
  80638. maxInitialRotation: number;
  80639. /**
  80640. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  80641. */
  80642. minAngularSpeed: number;
  80643. /**
  80644. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  80645. */
  80646. maxAngularSpeed: number;
  80647. /**
  80648. * The texture used to render each particle. (this can be a spritesheet)
  80649. */
  80650. particleTexture: Nullable<Texture>;
  80651. /**
  80652. * The layer mask we are rendering the particles through.
  80653. */
  80654. layerMask: number;
  80655. /**
  80656. * This can help using your own shader to render the particle system.
  80657. * The according effect will be created
  80658. */
  80659. customShader: any;
  80660. /**
  80661. * By default particle system starts as soon as they are created. This prevents the
  80662. * automatic start to happen and let you decide when to start emitting particles.
  80663. */
  80664. preventAutoStart: boolean;
  80665. private _noiseTexture;
  80666. /**
  80667. * Gets or sets a texture used to add random noise to particle positions
  80668. */
  80669. noiseTexture: Nullable<ProceduralTexture>;
  80670. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80671. noiseStrength: Vector3;
  80672. /**
  80673. * Callback triggered when the particle animation is ending.
  80674. */
  80675. onAnimationEnd: Nullable<() => void>;
  80676. /**
  80677. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80678. */
  80679. blendMode: number;
  80680. /**
  80681. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80682. * to override the particles.
  80683. */
  80684. forceDepthWrite: boolean;
  80685. /** 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 */
  80686. preWarmCycles: number;
  80687. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80688. preWarmStepOffset: number;
  80689. /**
  80690. * 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)
  80691. */
  80692. spriteCellChangeSpeed: number;
  80693. /**
  80694. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80695. */
  80696. startSpriteCellID: number;
  80697. /**
  80698. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80699. */
  80700. endSpriteCellID: number;
  80701. /**
  80702. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  80703. */
  80704. spriteCellWidth: number;
  80705. /**
  80706. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  80707. */
  80708. spriteCellHeight: number;
  80709. /**
  80710. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  80711. */
  80712. spriteRandomStartCell: boolean;
  80713. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  80714. translationPivot: Vector2;
  80715. /** @hidden */
  80716. protected _isAnimationSheetEnabled: boolean;
  80717. /**
  80718. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  80719. */
  80720. beginAnimationOnStart: boolean;
  80721. /**
  80722. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  80723. */
  80724. beginAnimationFrom: number;
  80725. /**
  80726. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  80727. */
  80728. beginAnimationTo: number;
  80729. /**
  80730. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  80731. */
  80732. beginAnimationLoop: boolean;
  80733. /**
  80734. * Gets or sets a world offset applied to all particles
  80735. */
  80736. worldOffset: Vector3;
  80737. /**
  80738. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  80739. */
  80740. isAnimationSheetEnabled: boolean;
  80741. /**
  80742. * Get hosting scene
  80743. * @returns the scene
  80744. */
  80745. getScene(): Scene;
  80746. /**
  80747. * You can use gravity if you want to give an orientation to your particles.
  80748. */
  80749. gravity: Vector3;
  80750. protected _colorGradients: Nullable<Array<ColorGradient>>;
  80751. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  80752. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80753. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80754. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80755. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80756. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80757. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80758. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80759. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80760. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80761. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80762. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80763. /**
  80764. * Defines the delay in milliseconds before starting the system (0 by default)
  80765. */
  80766. startDelay: number;
  80767. /**
  80768. * Gets the current list of drag gradients.
  80769. * You must use addDragGradient and removeDragGradient to udpate this list
  80770. * @returns the list of drag gradients
  80771. */
  80772. getDragGradients(): Nullable<Array<FactorGradient>>;
  80773. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80774. limitVelocityDamping: number;
  80775. /**
  80776. * Gets the current list of limit velocity gradients.
  80777. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80778. * @returns the list of limit velocity gradients
  80779. */
  80780. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80781. /**
  80782. * Gets the current list of color gradients.
  80783. * You must use addColorGradient and removeColorGradient to udpate this list
  80784. * @returns the list of color gradients
  80785. */
  80786. getColorGradients(): Nullable<Array<ColorGradient>>;
  80787. /**
  80788. * Gets the current list of size gradients.
  80789. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80790. * @returns the list of size gradients
  80791. */
  80792. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80793. /**
  80794. * Gets the current list of color remap gradients.
  80795. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80796. * @returns the list of color remap gradients
  80797. */
  80798. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80799. /**
  80800. * Gets the current list of alpha remap gradients.
  80801. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80802. * @returns the list of alpha remap gradients
  80803. */
  80804. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80805. /**
  80806. * Gets the current list of life time gradients.
  80807. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80808. * @returns the list of life time gradients
  80809. */
  80810. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80811. /**
  80812. * Gets the current list of angular speed gradients.
  80813. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80814. * @returns the list of angular speed gradients
  80815. */
  80816. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80817. /**
  80818. * Gets the current list of velocity gradients.
  80819. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80820. * @returns the list of velocity gradients
  80821. */
  80822. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80823. /**
  80824. * Gets the current list of start size gradients.
  80825. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80826. * @returns the list of start size gradients
  80827. */
  80828. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80829. /**
  80830. * Gets the current list of emit rate gradients.
  80831. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80832. * @returns the list of emit rate gradients
  80833. */
  80834. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  80835. /**
  80836. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80837. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80838. */
  80839. direction1: Vector3;
  80840. /**
  80841. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80842. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80843. */
  80844. direction2: Vector3;
  80845. /**
  80846. * 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.
  80847. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80848. */
  80849. minEmitBox: Vector3;
  80850. /**
  80851. * 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.
  80852. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80853. */
  80854. maxEmitBox: Vector3;
  80855. /**
  80856. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80857. */
  80858. color1: Color4;
  80859. /**
  80860. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80861. */
  80862. color2: Color4;
  80863. /**
  80864. * Color the particle will have at the end of its lifetime
  80865. */
  80866. colorDead: Color4;
  80867. /**
  80868. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  80869. */
  80870. textureMask: Color4;
  80871. /**
  80872. * The particle emitter type defines the emitter used by the particle system.
  80873. * It can be for example box, sphere, or cone...
  80874. */
  80875. particleEmitterType: IParticleEmitterType;
  80876. /** @hidden */
  80877. _isSubEmitter: boolean;
  80878. /**
  80879. * Gets or sets the billboard mode to use when isBillboardBased = true.
  80880. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  80881. */
  80882. billboardMode: number;
  80883. protected _isBillboardBased: boolean;
  80884. /**
  80885. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  80886. */
  80887. isBillboardBased: boolean;
  80888. /**
  80889. * The scene the particle system belongs to.
  80890. */
  80891. protected _scene: Scene;
  80892. /**
  80893. * Local cache of defines for image processing.
  80894. */
  80895. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  80896. /**
  80897. * Default configuration related to image processing available in the standard Material.
  80898. */
  80899. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  80900. /**
  80901. * Gets the image processing configuration used either in this material.
  80902. */
  80903. /**
  80904. * Sets the Default image processing configuration used either in the this material.
  80905. *
  80906. * If sets to null, the scene one is in use.
  80907. */
  80908. imageProcessingConfiguration: ImageProcessingConfiguration;
  80909. /**
  80910. * Attaches a new image processing configuration to the Standard Material.
  80911. * @param configuration
  80912. */
  80913. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  80914. /** @hidden */
  80915. protected _reset(): void;
  80916. /** @hidden */
  80917. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  80918. /**
  80919. * Instantiates a particle system.
  80920. * 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.
  80921. * @param name The name of the particle system
  80922. */
  80923. constructor(name: string);
  80924. /**
  80925. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  80926. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80927. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80928. * @returns the emitter
  80929. */
  80930. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  80931. /**
  80932. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  80933. * @param radius The radius of the hemisphere to emit from
  80934. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80935. * @returns the emitter
  80936. */
  80937. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  80938. /**
  80939. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  80940. * @param radius The radius of the sphere to emit from
  80941. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80942. * @returns the emitter
  80943. */
  80944. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  80945. /**
  80946. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  80947. * @param radius The radius of the sphere to emit from
  80948. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  80949. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  80950. * @returns the emitter
  80951. */
  80952. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  80953. /**
  80954. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  80955. * @param radius The radius of the emission cylinder
  80956. * @param height The height of the emission cylinder
  80957. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  80958. * @param directionRandomizer How much to randomize the particle direction [0-1]
  80959. * @returns the emitter
  80960. */
  80961. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  80962. /**
  80963. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  80964. * @param radius The radius of the cylinder to emit from
  80965. * @param height The height of the emission cylinder
  80966. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80967. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  80968. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  80969. * @returns the emitter
  80970. */
  80971. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  80972. /**
  80973. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  80974. * @param radius The radius of the cone to emit from
  80975. * @param angle The base angle of the cone
  80976. * @returns the emitter
  80977. */
  80978. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  80979. /**
  80980. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  80981. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80982. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80983. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80984. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80985. * @returns the emitter
  80986. */
  80987. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  80988. }
  80989. }
  80990. declare module BABYLON {
  80991. /**
  80992. * Type of sub emitter
  80993. */
  80994. export enum SubEmitterType {
  80995. /**
  80996. * Attached to the particle over it's lifetime
  80997. */
  80998. ATTACHED = 0,
  80999. /**
  81000. * Created when the particle dies
  81001. */
  81002. END = 1
  81003. }
  81004. /**
  81005. * Sub emitter class used to emit particles from an existing particle
  81006. */
  81007. export class SubEmitter {
  81008. /**
  81009. * the particle system to be used by the sub emitter
  81010. */
  81011. particleSystem: ParticleSystem;
  81012. /**
  81013. * Type of the submitter (Default: END)
  81014. */
  81015. type: SubEmitterType;
  81016. /**
  81017. * 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)
  81018. * Note: This only is supported when using an emitter of type Mesh
  81019. */
  81020. inheritDirection: boolean;
  81021. /**
  81022. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  81023. */
  81024. inheritedVelocityAmount: number;
  81025. /**
  81026. * Creates a sub emitter
  81027. * @param particleSystem the particle system to be used by the sub emitter
  81028. */
  81029. constructor(
  81030. /**
  81031. * the particle system to be used by the sub emitter
  81032. */
  81033. particleSystem: ParticleSystem);
  81034. /**
  81035. * Clones the sub emitter
  81036. * @returns the cloned sub emitter
  81037. */
  81038. clone(): SubEmitter;
  81039. /**
  81040. * Serialize current object to a JSON object
  81041. * @returns the serialized object
  81042. */
  81043. serialize(): any;
  81044. /** @hidden */
  81045. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  81046. /**
  81047. * Creates a new SubEmitter from a serialized JSON version
  81048. * @param serializationObject defines the JSON object to read from
  81049. * @param scene defines the hosting scene
  81050. * @param rootUrl defines the rootUrl for data loading
  81051. * @returns a new SubEmitter
  81052. */
  81053. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  81054. /** Release associated resources */
  81055. dispose(): void;
  81056. }
  81057. }
  81058. declare module BABYLON {
  81059. /** @hidden */
  81060. export var clipPlaneFragmentDeclaration: {
  81061. name: string;
  81062. shader: string;
  81063. };
  81064. }
  81065. declare module BABYLON {
  81066. /** @hidden */
  81067. export var imageProcessingDeclaration: {
  81068. name: string;
  81069. shader: string;
  81070. };
  81071. }
  81072. declare module BABYLON {
  81073. /** @hidden */
  81074. export var imageProcessingFunctions: {
  81075. name: string;
  81076. shader: string;
  81077. };
  81078. }
  81079. declare module BABYLON {
  81080. /** @hidden */
  81081. export var clipPlaneFragment: {
  81082. name: string;
  81083. shader: string;
  81084. };
  81085. }
  81086. declare module BABYLON {
  81087. /** @hidden */
  81088. export var particlesPixelShader: {
  81089. name: string;
  81090. shader: string;
  81091. };
  81092. }
  81093. declare module BABYLON {
  81094. /** @hidden */
  81095. export var clipPlaneVertexDeclaration: {
  81096. name: string;
  81097. shader: string;
  81098. };
  81099. }
  81100. declare module BABYLON {
  81101. /** @hidden */
  81102. export var clipPlaneVertex: {
  81103. name: string;
  81104. shader: string;
  81105. };
  81106. }
  81107. declare module BABYLON {
  81108. /** @hidden */
  81109. export var particlesVertexShader: {
  81110. name: string;
  81111. shader: string;
  81112. };
  81113. }
  81114. declare module BABYLON {
  81115. /**
  81116. * This represents a particle system in Babylon.
  81117. * 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.
  81118. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81119. * @example https://doc.babylonjs.com/babylon101/particles
  81120. */
  81121. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  81122. /**
  81123. * Billboard mode will only apply to Y axis
  81124. */
  81125. static readonly BILLBOARDMODE_Y: number;
  81126. /**
  81127. * Billboard mode will apply to all axes
  81128. */
  81129. static readonly BILLBOARDMODE_ALL: number;
  81130. /**
  81131. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81132. */
  81133. static readonly BILLBOARDMODE_STRETCHED: number;
  81134. /**
  81135. * This function can be defined to provide custom update for active particles.
  81136. * This function will be called instead of regular update (age, position, color, etc.).
  81137. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  81138. */
  81139. updateFunction: (particles: Particle[]) => void;
  81140. private _emitterWorldMatrix;
  81141. /**
  81142. * This function can be defined to specify initial direction for every new particle.
  81143. * It by default use the emitterType defined function
  81144. */
  81145. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  81146. /**
  81147. * This function can be defined to specify initial position for every new particle.
  81148. * It by default use the emitterType defined function
  81149. */
  81150. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  81151. /**
  81152. * @hidden
  81153. */
  81154. _inheritedVelocityOffset: Vector3;
  81155. /**
  81156. * An event triggered when the system is disposed
  81157. */
  81158. onDisposeObservable: Observable<ParticleSystem>;
  81159. private _onDisposeObserver;
  81160. /**
  81161. * Sets a callback that will be triggered when the system is disposed
  81162. */
  81163. onDispose: () => void;
  81164. private _particles;
  81165. private _epsilon;
  81166. private _capacity;
  81167. private _stockParticles;
  81168. private _newPartsExcess;
  81169. private _vertexData;
  81170. private _vertexBuffer;
  81171. private _vertexBuffers;
  81172. private _spriteBuffer;
  81173. private _indexBuffer;
  81174. private _effect;
  81175. private _customEffect;
  81176. private _cachedDefines;
  81177. private _scaledColorStep;
  81178. private _colorDiff;
  81179. private _scaledDirection;
  81180. private _scaledGravity;
  81181. private _currentRenderId;
  81182. private _alive;
  81183. private _useInstancing;
  81184. private _started;
  81185. private _stopped;
  81186. private _actualFrame;
  81187. private _scaledUpdateSpeed;
  81188. private _vertexBufferSize;
  81189. /** @hidden */
  81190. _currentEmitRateGradient: Nullable<FactorGradient>;
  81191. /** @hidden */
  81192. _currentEmitRate1: number;
  81193. /** @hidden */
  81194. _currentEmitRate2: number;
  81195. /** @hidden */
  81196. _currentStartSizeGradient: Nullable<FactorGradient>;
  81197. /** @hidden */
  81198. _currentStartSize1: number;
  81199. /** @hidden */
  81200. _currentStartSize2: number;
  81201. private readonly _rawTextureWidth;
  81202. private _rampGradientsTexture;
  81203. private _useRampGradients;
  81204. /** Gets or sets a boolean indicating that ramp gradients must be used
  81205. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81206. */
  81207. useRampGradients: boolean;
  81208. /**
  81209. * 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.
  81210. * 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: [])
  81211. */
  81212. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  81213. private _subEmitters;
  81214. /**
  81215. * @hidden
  81216. * If the particle systems emitter should be disposed when the particle system is disposed
  81217. */
  81218. _disposeEmitterOnDispose: boolean;
  81219. /**
  81220. * The current active Sub-systems, this property is used by the root particle system only.
  81221. */
  81222. activeSubSystems: Array<ParticleSystem>;
  81223. private _rootParticleSystem;
  81224. /**
  81225. * Gets the current list of active particles
  81226. */
  81227. readonly particles: Particle[];
  81228. /**
  81229. * Returns the string "ParticleSystem"
  81230. * @returns a string containing the class name
  81231. */
  81232. getClassName(): string;
  81233. /**
  81234. * Instantiates a particle system.
  81235. * 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.
  81236. * @param name The name of the particle system
  81237. * @param capacity The max number of particles alive at the same time
  81238. * @param scene The scene the particle system belongs to
  81239. * @param customEffect a custom effect used to change the way particles are rendered by default
  81240. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  81241. * @param epsilon Offset used to render the particles
  81242. */
  81243. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  81244. private _addFactorGradient;
  81245. private _removeFactorGradient;
  81246. /**
  81247. * Adds a new life time gradient
  81248. * @param gradient defines the gradient to use (between 0 and 1)
  81249. * @param factor defines the life time factor to affect to the specified gradient
  81250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81251. * @returns the current particle system
  81252. */
  81253. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81254. /**
  81255. * Remove a specific life time gradient
  81256. * @param gradient defines the gradient to remove
  81257. * @returns the current particle system
  81258. */
  81259. removeLifeTimeGradient(gradient: number): IParticleSystem;
  81260. /**
  81261. * Adds a new size gradient
  81262. * @param gradient defines the gradient to use (between 0 and 1)
  81263. * @param factor defines the size factor to affect to the specified gradient
  81264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81265. * @returns the current particle system
  81266. */
  81267. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81268. /**
  81269. * Remove a specific size gradient
  81270. * @param gradient defines the gradient to remove
  81271. * @returns the current particle system
  81272. */
  81273. removeSizeGradient(gradient: number): IParticleSystem;
  81274. /**
  81275. * Adds a new color remap gradient
  81276. * @param gradient defines the gradient to use (between 0 and 1)
  81277. * @param min defines the color remap minimal range
  81278. * @param max defines the color remap maximal range
  81279. * @returns the current particle system
  81280. */
  81281. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81282. /**
  81283. * Remove a specific color remap gradient
  81284. * @param gradient defines the gradient to remove
  81285. * @returns the current particle system
  81286. */
  81287. removeColorRemapGradient(gradient: number): IParticleSystem;
  81288. /**
  81289. * Adds a new alpha remap gradient
  81290. * @param gradient defines the gradient to use (between 0 and 1)
  81291. * @param min defines the alpha remap minimal range
  81292. * @param max defines the alpha remap maximal range
  81293. * @returns the current particle system
  81294. */
  81295. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81296. /**
  81297. * Remove a specific alpha remap gradient
  81298. * @param gradient defines the gradient to remove
  81299. * @returns the current particle system
  81300. */
  81301. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  81302. /**
  81303. * Adds a new angular speed gradient
  81304. * @param gradient defines the gradient to use (between 0 and 1)
  81305. * @param factor defines the angular speed to affect to the specified gradient
  81306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81307. * @returns the current particle system
  81308. */
  81309. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81310. /**
  81311. * Remove a specific angular speed gradient
  81312. * @param gradient defines the gradient to remove
  81313. * @returns the current particle system
  81314. */
  81315. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81316. /**
  81317. * Adds a new velocity gradient
  81318. * @param gradient defines the gradient to use (between 0 and 1)
  81319. * @param factor defines the velocity to affect to the specified gradient
  81320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81321. * @returns the current particle system
  81322. */
  81323. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81324. /**
  81325. * Remove a specific velocity gradient
  81326. * @param gradient defines the gradient to remove
  81327. * @returns the current particle system
  81328. */
  81329. removeVelocityGradient(gradient: number): IParticleSystem;
  81330. /**
  81331. * Adds a new limit velocity gradient
  81332. * @param gradient defines the gradient to use (between 0 and 1)
  81333. * @param factor defines the limit velocity value to affect to the specified gradient
  81334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81335. * @returns the current particle system
  81336. */
  81337. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81338. /**
  81339. * Remove a specific limit velocity gradient
  81340. * @param gradient defines the gradient to remove
  81341. * @returns the current particle system
  81342. */
  81343. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  81344. /**
  81345. * Adds a new drag gradient
  81346. * @param gradient defines the gradient to use (between 0 and 1)
  81347. * @param factor defines the drag value to affect to the specified gradient
  81348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81349. * @returns the current particle system
  81350. */
  81351. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81352. /**
  81353. * Remove a specific drag gradient
  81354. * @param gradient defines the gradient to remove
  81355. * @returns the current particle system
  81356. */
  81357. removeDragGradient(gradient: number): IParticleSystem;
  81358. /**
  81359. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  81360. * @param gradient defines the gradient to use (between 0 and 1)
  81361. * @param factor defines the emit rate value to affect to the specified gradient
  81362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81363. * @returns the current particle system
  81364. */
  81365. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81366. /**
  81367. * Remove a specific emit rate gradient
  81368. * @param gradient defines the gradient to remove
  81369. * @returns the current particle system
  81370. */
  81371. removeEmitRateGradient(gradient: number): IParticleSystem;
  81372. /**
  81373. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  81374. * @param gradient defines the gradient to use (between 0 and 1)
  81375. * @param factor defines the start size value to affect to the specified gradient
  81376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81377. * @returns the current particle system
  81378. */
  81379. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81380. /**
  81381. * Remove a specific start size gradient
  81382. * @param gradient defines the gradient to remove
  81383. * @returns the current particle system
  81384. */
  81385. removeStartSizeGradient(gradient: number): IParticleSystem;
  81386. private _createRampGradientTexture;
  81387. /**
  81388. * Gets the current list of ramp gradients.
  81389. * You must use addRampGradient and removeRampGradient to udpate this list
  81390. * @returns the list of ramp gradients
  81391. */
  81392. getRampGradients(): Nullable<Array<Color3Gradient>>;
  81393. /**
  81394. * Adds a new ramp gradient used to remap particle colors
  81395. * @param gradient defines the gradient to use (between 0 and 1)
  81396. * @param color defines the color to affect to the specified gradient
  81397. * @returns the current particle system
  81398. */
  81399. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  81400. /**
  81401. * Remove a specific ramp gradient
  81402. * @param gradient defines the gradient to remove
  81403. * @returns the current particle system
  81404. */
  81405. removeRampGradient(gradient: number): ParticleSystem;
  81406. /**
  81407. * Adds a new color gradient
  81408. * @param gradient defines the gradient to use (between 0 and 1)
  81409. * @param color1 defines the color to affect to the specified gradient
  81410. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81411. * @returns this particle system
  81412. */
  81413. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81414. /**
  81415. * Remove a specific color gradient
  81416. * @param gradient defines the gradient to remove
  81417. * @returns this particle system
  81418. */
  81419. removeColorGradient(gradient: number): IParticleSystem;
  81420. private _fetchR;
  81421. protected _reset(): void;
  81422. private _resetEffect;
  81423. private _createVertexBuffers;
  81424. private _createIndexBuffer;
  81425. /**
  81426. * Gets the maximum number of particles active at the same time.
  81427. * @returns The max number of active particles.
  81428. */
  81429. getCapacity(): number;
  81430. /**
  81431. * Gets whether there are still active particles in the system.
  81432. * @returns True if it is alive, otherwise false.
  81433. */
  81434. isAlive(): boolean;
  81435. /**
  81436. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81437. * @returns True if it has been started, otherwise false.
  81438. */
  81439. isStarted(): boolean;
  81440. private _prepareSubEmitterInternalArray;
  81441. /**
  81442. * Starts the particle system and begins to emit
  81443. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  81444. */
  81445. start(delay?: number): void;
  81446. /**
  81447. * Stops the particle system.
  81448. * @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.
  81449. */
  81450. stop(stopSubEmitters?: boolean): void;
  81451. /**
  81452. * Remove all active particles
  81453. */
  81454. reset(): void;
  81455. /**
  81456. * @hidden (for internal use only)
  81457. */
  81458. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  81459. /**
  81460. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  81461. * Its lifetime will start back at 0.
  81462. */
  81463. recycleParticle: (particle: Particle) => void;
  81464. private _stopSubEmitters;
  81465. private _createParticle;
  81466. private _removeFromRoot;
  81467. private _emitFromParticle;
  81468. private _update;
  81469. /** @hidden */
  81470. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  81471. /** @hidden */
  81472. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  81473. /** @hidden */
  81474. private _getEffect;
  81475. /**
  81476. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  81477. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  81478. */
  81479. animate(preWarmOnly?: boolean): void;
  81480. private _appendParticleVertices;
  81481. /**
  81482. * Rebuilds the particle system.
  81483. */
  81484. rebuild(): void;
  81485. /**
  81486. * Is this system ready to be used/rendered
  81487. * @return true if the system is ready
  81488. */
  81489. isReady(): boolean;
  81490. private _render;
  81491. /**
  81492. * Renders the particle system in its current state.
  81493. * @returns the current number of particles
  81494. */
  81495. render(): number;
  81496. /**
  81497. * Disposes the particle system and free the associated resources
  81498. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81499. */
  81500. dispose(disposeTexture?: boolean): void;
  81501. /**
  81502. * Clones the particle system.
  81503. * @param name The name of the cloned object
  81504. * @param newEmitter The new emitter to use
  81505. * @returns the cloned particle system
  81506. */
  81507. clone(name: string, newEmitter: any): ParticleSystem;
  81508. /**
  81509. * Serializes the particle system to a JSON object.
  81510. * @returns the JSON object
  81511. */
  81512. serialize(): any;
  81513. /** @hidden */
  81514. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  81515. /** @hidden */
  81516. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  81517. /**
  81518. * Parses a JSON object to create a particle system.
  81519. * @param parsedParticleSystem The JSON object to parse
  81520. * @param scene The scene to create the particle system in
  81521. * @param rootUrl The root url to use to load external dependencies like texture
  81522. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  81523. * @returns the Parsed particle system
  81524. */
  81525. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  81526. }
  81527. }
  81528. declare module BABYLON {
  81529. /**
  81530. * A particle represents one of the element emitted by a particle system.
  81531. * This is mainly define by its coordinates, direction, velocity and age.
  81532. */
  81533. export class Particle {
  81534. /**
  81535. * The particle system the particle belongs to.
  81536. */
  81537. particleSystem: ParticleSystem;
  81538. private static _Count;
  81539. /**
  81540. * Unique ID of the particle
  81541. */
  81542. id: number;
  81543. /**
  81544. * The world position of the particle in the scene.
  81545. */
  81546. position: Vector3;
  81547. /**
  81548. * The world direction of the particle in the scene.
  81549. */
  81550. direction: Vector3;
  81551. /**
  81552. * The color of the particle.
  81553. */
  81554. color: Color4;
  81555. /**
  81556. * The color change of the particle per step.
  81557. */
  81558. colorStep: Color4;
  81559. /**
  81560. * Defines how long will the life of the particle be.
  81561. */
  81562. lifeTime: number;
  81563. /**
  81564. * The current age of the particle.
  81565. */
  81566. age: number;
  81567. /**
  81568. * The current size of the particle.
  81569. */
  81570. size: number;
  81571. /**
  81572. * The current scale of the particle.
  81573. */
  81574. scale: Vector2;
  81575. /**
  81576. * The current angle of the particle.
  81577. */
  81578. angle: number;
  81579. /**
  81580. * Defines how fast is the angle changing.
  81581. */
  81582. angularSpeed: number;
  81583. /**
  81584. * Defines the cell index used by the particle to be rendered from a sprite.
  81585. */
  81586. cellIndex: number;
  81587. /**
  81588. * The information required to support color remapping
  81589. */
  81590. remapData: Vector4;
  81591. /** @hidden */
  81592. _randomCellOffset?: number;
  81593. /** @hidden */
  81594. _initialDirection: Nullable<Vector3>;
  81595. /** @hidden */
  81596. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  81597. /** @hidden */
  81598. _initialStartSpriteCellID: number;
  81599. /** @hidden */
  81600. _initialEndSpriteCellID: number;
  81601. /** @hidden */
  81602. _currentColorGradient: Nullable<ColorGradient>;
  81603. /** @hidden */
  81604. _currentColor1: Color4;
  81605. /** @hidden */
  81606. _currentColor2: Color4;
  81607. /** @hidden */
  81608. _currentSizeGradient: Nullable<FactorGradient>;
  81609. /** @hidden */
  81610. _currentSize1: number;
  81611. /** @hidden */
  81612. _currentSize2: number;
  81613. /** @hidden */
  81614. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  81615. /** @hidden */
  81616. _currentAngularSpeed1: number;
  81617. /** @hidden */
  81618. _currentAngularSpeed2: number;
  81619. /** @hidden */
  81620. _currentVelocityGradient: Nullable<FactorGradient>;
  81621. /** @hidden */
  81622. _currentVelocity1: number;
  81623. /** @hidden */
  81624. _currentVelocity2: number;
  81625. /** @hidden */
  81626. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  81627. /** @hidden */
  81628. _currentLimitVelocity1: number;
  81629. /** @hidden */
  81630. _currentLimitVelocity2: number;
  81631. /** @hidden */
  81632. _currentDragGradient: Nullable<FactorGradient>;
  81633. /** @hidden */
  81634. _currentDrag1: number;
  81635. /** @hidden */
  81636. _currentDrag2: number;
  81637. /** @hidden */
  81638. _randomNoiseCoordinates1: Vector3;
  81639. /** @hidden */
  81640. _randomNoiseCoordinates2: Vector3;
  81641. /**
  81642. * Creates a new instance Particle
  81643. * @param particleSystem the particle system the particle belongs to
  81644. */
  81645. constructor(
  81646. /**
  81647. * The particle system the particle belongs to.
  81648. */
  81649. particleSystem: ParticleSystem);
  81650. private updateCellInfoFromSystem;
  81651. /**
  81652. * Defines how the sprite cell index is updated for the particle
  81653. */
  81654. updateCellIndex(): void;
  81655. /** @hidden */
  81656. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81657. /** @hidden */
  81658. _inheritParticleInfoToSubEmitters(): void;
  81659. /** @hidden */
  81660. _reset(): void;
  81661. /**
  81662. * Copy the properties of particle to another one.
  81663. * @param other the particle to copy the information to.
  81664. */
  81665. copyTo(other: Particle): void;
  81666. }
  81667. }
  81668. declare module BABYLON {
  81669. /**
  81670. * Particle emitter represents a volume emitting particles.
  81671. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81672. */
  81673. export interface IParticleEmitterType {
  81674. /**
  81675. * Called by the particle System when the direction is computed for the created particle.
  81676. * @param worldMatrix is the world matrix of the particle system
  81677. * @param directionToUpdate is the direction vector to update with the result
  81678. * @param particle is the particle we are computed the direction for
  81679. */
  81680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81681. /**
  81682. * Called by the particle System when the position is computed for the created particle.
  81683. * @param worldMatrix is the world matrix of the particle system
  81684. * @param positionToUpdate is the position vector to update with the result
  81685. * @param particle is the particle we are computed the position for
  81686. */
  81687. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81688. /**
  81689. * Clones the current emitter and returns a copy of it
  81690. * @returns the new emitter
  81691. */
  81692. clone(): IParticleEmitterType;
  81693. /**
  81694. * Called by the GPUParticleSystem to setup the update shader
  81695. * @param effect defines the update shader
  81696. */
  81697. applyToShader(effect: Effect): void;
  81698. /**
  81699. * Returns a string to use to update the GPU particles update shader
  81700. * @returns the effect defines string
  81701. */
  81702. getEffectDefines(): string;
  81703. /**
  81704. * Returns a string representing the class name
  81705. * @returns a string containing the class name
  81706. */
  81707. getClassName(): string;
  81708. /**
  81709. * Serializes the particle system to a JSON object.
  81710. * @returns the JSON object
  81711. */
  81712. serialize(): any;
  81713. /**
  81714. * Parse properties from a JSON object
  81715. * @param serializationObject defines the JSON object
  81716. */
  81717. parse(serializationObject: any): void;
  81718. }
  81719. }
  81720. declare module BABYLON {
  81721. /**
  81722. * Particle emitter emitting particles from the inside of a box.
  81723. * It emits the particles randomly between 2 given directions.
  81724. */
  81725. export class BoxParticleEmitter implements IParticleEmitterType {
  81726. /**
  81727. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81728. */
  81729. direction1: Vector3;
  81730. /**
  81731. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81732. */
  81733. direction2: Vector3;
  81734. /**
  81735. * 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.
  81736. */
  81737. minEmitBox: Vector3;
  81738. /**
  81739. * 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.
  81740. */
  81741. maxEmitBox: Vector3;
  81742. /**
  81743. * Creates a new instance BoxParticleEmitter
  81744. */
  81745. constructor();
  81746. /**
  81747. * Called by the particle System when the direction is computed for the created particle.
  81748. * @param worldMatrix is the world matrix of the particle system
  81749. * @param directionToUpdate is the direction vector to update with the result
  81750. * @param particle is the particle we are computed the direction for
  81751. */
  81752. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81753. /**
  81754. * Called by the particle System when the position is computed for the created particle.
  81755. * @param worldMatrix is the world matrix of the particle system
  81756. * @param positionToUpdate is the position vector to update with the result
  81757. * @param particle is the particle we are computed the position for
  81758. */
  81759. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81760. /**
  81761. * Clones the current emitter and returns a copy of it
  81762. * @returns the new emitter
  81763. */
  81764. clone(): BoxParticleEmitter;
  81765. /**
  81766. * Called by the GPUParticleSystem to setup the update shader
  81767. * @param effect defines the update shader
  81768. */
  81769. applyToShader(effect: Effect): void;
  81770. /**
  81771. * Returns a string to use to update the GPU particles update shader
  81772. * @returns a string containng the defines string
  81773. */
  81774. getEffectDefines(): string;
  81775. /**
  81776. * Returns the string "BoxParticleEmitter"
  81777. * @returns a string containing the class name
  81778. */
  81779. getClassName(): string;
  81780. /**
  81781. * Serializes the particle system to a JSON object.
  81782. * @returns the JSON object
  81783. */
  81784. serialize(): any;
  81785. /**
  81786. * Parse properties from a JSON object
  81787. * @param serializationObject defines the JSON object
  81788. */
  81789. parse(serializationObject: any): void;
  81790. }
  81791. }
  81792. declare module BABYLON {
  81793. /**
  81794. * Particle emitter emitting particles from the inside of a cone.
  81795. * It emits the particles alongside the cone volume from the base to the particle.
  81796. * The emission direction might be randomized.
  81797. */
  81798. export class ConeParticleEmitter implements IParticleEmitterType {
  81799. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81800. directionRandomizer: number;
  81801. private _radius;
  81802. private _angle;
  81803. private _height;
  81804. /**
  81805. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81806. */
  81807. radiusRange: number;
  81808. /**
  81809. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81810. */
  81811. heightRange: number;
  81812. /**
  81813. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81814. */
  81815. emitFromSpawnPointOnly: boolean;
  81816. /**
  81817. * Gets or sets the radius of the emission cone
  81818. */
  81819. radius: number;
  81820. /**
  81821. * Gets or sets the angle of the emission cone
  81822. */
  81823. angle: number;
  81824. private _buildHeight;
  81825. /**
  81826. * Creates a new instance ConeParticleEmitter
  81827. * @param radius the radius of the emission cone (1 by default)
  81828. * @param angle the cone base angle (PI by default)
  81829. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81830. */
  81831. constructor(radius?: number, angle?: number,
  81832. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81833. directionRandomizer?: number);
  81834. /**
  81835. * Called by the particle System when the direction is computed for the created particle.
  81836. * @param worldMatrix is the world matrix of the particle system
  81837. * @param directionToUpdate is the direction vector to update with the result
  81838. * @param particle is the particle we are computed the direction for
  81839. */
  81840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81841. /**
  81842. * Called by the particle System when the position is computed for the created particle.
  81843. * @param worldMatrix is the world matrix of the particle system
  81844. * @param positionToUpdate is the position vector to update with the result
  81845. * @param particle is the particle we are computed the position for
  81846. */
  81847. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81848. /**
  81849. * Clones the current emitter and returns a copy of it
  81850. * @returns the new emitter
  81851. */
  81852. clone(): ConeParticleEmitter;
  81853. /**
  81854. * Called by the GPUParticleSystem to setup the update shader
  81855. * @param effect defines the update shader
  81856. */
  81857. applyToShader(effect: Effect): void;
  81858. /**
  81859. * Returns a string to use to update the GPU particles update shader
  81860. * @returns a string containng the defines string
  81861. */
  81862. getEffectDefines(): string;
  81863. /**
  81864. * Returns the string "ConeParticleEmitter"
  81865. * @returns a string containing the class name
  81866. */
  81867. getClassName(): string;
  81868. /**
  81869. * Serializes the particle system to a JSON object.
  81870. * @returns the JSON object
  81871. */
  81872. serialize(): any;
  81873. /**
  81874. * Parse properties from a JSON object
  81875. * @param serializationObject defines the JSON object
  81876. */
  81877. parse(serializationObject: any): void;
  81878. }
  81879. }
  81880. declare module BABYLON {
  81881. /**
  81882. * Particle emitter emitting particles from the inside of a cylinder.
  81883. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  81884. */
  81885. export class CylinderParticleEmitter implements IParticleEmitterType {
  81886. /**
  81887. * The radius of the emission cylinder.
  81888. */
  81889. radius: number;
  81890. /**
  81891. * The height of the emission cylinder.
  81892. */
  81893. height: number;
  81894. /**
  81895. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81896. */
  81897. radiusRange: number;
  81898. /**
  81899. * How much to randomize the particle direction [0-1].
  81900. */
  81901. directionRandomizer: number;
  81902. /**
  81903. * Creates a new instance CylinderParticleEmitter
  81904. * @param radius the radius of the emission cylinder (1 by default)
  81905. * @param height the height of the emission cylinder (1 by default)
  81906. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81907. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81908. */
  81909. constructor(
  81910. /**
  81911. * The radius of the emission cylinder.
  81912. */
  81913. radius?: number,
  81914. /**
  81915. * The height of the emission cylinder.
  81916. */
  81917. height?: number,
  81918. /**
  81919. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81920. */
  81921. radiusRange?: number,
  81922. /**
  81923. * How much to randomize the particle direction [0-1].
  81924. */
  81925. directionRandomizer?: number);
  81926. /**
  81927. * Called by the particle System when the direction is computed for the created particle.
  81928. * @param worldMatrix is the world matrix of the particle system
  81929. * @param directionToUpdate is the direction vector to update with the result
  81930. * @param particle is the particle we are computed the direction for
  81931. */
  81932. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81933. /**
  81934. * Called by the particle System when the position is computed for the created particle.
  81935. * @param worldMatrix is the world matrix of the particle system
  81936. * @param positionToUpdate is the position vector to update with the result
  81937. * @param particle is the particle we are computed the position for
  81938. */
  81939. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81940. /**
  81941. * Clones the current emitter and returns a copy of it
  81942. * @returns the new emitter
  81943. */
  81944. clone(): CylinderParticleEmitter;
  81945. /**
  81946. * Called by the GPUParticleSystem to setup the update shader
  81947. * @param effect defines the update shader
  81948. */
  81949. applyToShader(effect: Effect): void;
  81950. /**
  81951. * Returns a string to use to update the GPU particles update shader
  81952. * @returns a string containng the defines string
  81953. */
  81954. getEffectDefines(): string;
  81955. /**
  81956. * Returns the string "CylinderParticleEmitter"
  81957. * @returns a string containing the class name
  81958. */
  81959. getClassName(): string;
  81960. /**
  81961. * Serializes the particle system to a JSON object.
  81962. * @returns the JSON object
  81963. */
  81964. serialize(): any;
  81965. /**
  81966. * Parse properties from a JSON object
  81967. * @param serializationObject defines the JSON object
  81968. */
  81969. parse(serializationObject: any): void;
  81970. }
  81971. /**
  81972. * Particle emitter emitting particles from the inside of a cylinder.
  81973. * It emits the particles randomly between two vectors.
  81974. */
  81975. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  81976. /**
  81977. * The min limit of the emission direction.
  81978. */
  81979. direction1: Vector3;
  81980. /**
  81981. * The max limit of the emission direction.
  81982. */
  81983. direction2: Vector3;
  81984. /**
  81985. * Creates a new instance CylinderDirectedParticleEmitter
  81986. * @param radius the radius of the emission cylinder (1 by default)
  81987. * @param height the height of the emission cylinder (1 by default)
  81988. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81989. * @param direction1 the min limit of the emission direction (up vector by default)
  81990. * @param direction2 the max limit of the emission direction (up vector by default)
  81991. */
  81992. constructor(radius?: number, height?: number, radiusRange?: number,
  81993. /**
  81994. * The min limit of the emission direction.
  81995. */
  81996. direction1?: Vector3,
  81997. /**
  81998. * The max limit of the emission direction.
  81999. */
  82000. direction2?: Vector3);
  82001. /**
  82002. * Called by the particle System when the direction is computed for the created particle.
  82003. * @param worldMatrix is the world matrix of the particle system
  82004. * @param directionToUpdate is the direction vector to update with the result
  82005. * @param particle is the particle we are computed the direction for
  82006. */
  82007. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82008. /**
  82009. * Clones the current emitter and returns a copy of it
  82010. * @returns the new emitter
  82011. */
  82012. clone(): CylinderDirectedParticleEmitter;
  82013. /**
  82014. * Called by the GPUParticleSystem to setup the update shader
  82015. * @param effect defines the update shader
  82016. */
  82017. applyToShader(effect: Effect): void;
  82018. /**
  82019. * Returns a string to use to update the GPU particles update shader
  82020. * @returns a string containng the defines string
  82021. */
  82022. getEffectDefines(): string;
  82023. /**
  82024. * Returns the string "CylinderDirectedParticleEmitter"
  82025. * @returns a string containing the class name
  82026. */
  82027. getClassName(): string;
  82028. /**
  82029. * Serializes the particle system to a JSON object.
  82030. * @returns the JSON object
  82031. */
  82032. serialize(): any;
  82033. /**
  82034. * Parse properties from a JSON object
  82035. * @param serializationObject defines the JSON object
  82036. */
  82037. parse(serializationObject: any): void;
  82038. }
  82039. }
  82040. declare module BABYLON {
  82041. /**
  82042. * Particle emitter emitting particles from the inside of a hemisphere.
  82043. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  82044. */
  82045. export class HemisphericParticleEmitter implements IParticleEmitterType {
  82046. /**
  82047. * The radius of the emission hemisphere.
  82048. */
  82049. radius: number;
  82050. /**
  82051. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82052. */
  82053. radiusRange: number;
  82054. /**
  82055. * How much to randomize the particle direction [0-1].
  82056. */
  82057. directionRandomizer: number;
  82058. /**
  82059. * Creates a new instance HemisphericParticleEmitter
  82060. * @param radius the radius of the emission hemisphere (1 by default)
  82061. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82062. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82063. */
  82064. constructor(
  82065. /**
  82066. * The radius of the emission hemisphere.
  82067. */
  82068. radius?: number,
  82069. /**
  82070. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82071. */
  82072. radiusRange?: number,
  82073. /**
  82074. * How much to randomize the particle direction [0-1].
  82075. */
  82076. directionRandomizer?: number);
  82077. /**
  82078. * Called by the particle System when the direction is computed for the created particle.
  82079. * @param worldMatrix is the world matrix of the particle system
  82080. * @param directionToUpdate is the direction vector to update with the result
  82081. * @param particle is the particle we are computed the direction for
  82082. */
  82083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82084. /**
  82085. * Called by the particle System when the position is computed for the created particle.
  82086. * @param worldMatrix is the world matrix of the particle system
  82087. * @param positionToUpdate is the position vector to update with the result
  82088. * @param particle is the particle we are computed the position for
  82089. */
  82090. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82091. /**
  82092. * Clones the current emitter and returns a copy of it
  82093. * @returns the new emitter
  82094. */
  82095. clone(): HemisphericParticleEmitter;
  82096. /**
  82097. * Called by the GPUParticleSystem to setup the update shader
  82098. * @param effect defines the update shader
  82099. */
  82100. applyToShader(effect: Effect): void;
  82101. /**
  82102. * Returns a string to use to update the GPU particles update shader
  82103. * @returns a string containng the defines string
  82104. */
  82105. getEffectDefines(): string;
  82106. /**
  82107. * Returns the string "HemisphericParticleEmitter"
  82108. * @returns a string containing the class name
  82109. */
  82110. getClassName(): string;
  82111. /**
  82112. * Serializes the particle system to a JSON object.
  82113. * @returns the JSON object
  82114. */
  82115. serialize(): any;
  82116. /**
  82117. * Parse properties from a JSON object
  82118. * @param serializationObject defines the JSON object
  82119. */
  82120. parse(serializationObject: any): void;
  82121. }
  82122. }
  82123. declare module BABYLON {
  82124. /**
  82125. * Particle emitter emitting particles from a point.
  82126. * It emits the particles randomly between 2 given directions.
  82127. */
  82128. export class PointParticleEmitter implements IParticleEmitterType {
  82129. /**
  82130. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82131. */
  82132. direction1: Vector3;
  82133. /**
  82134. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82135. */
  82136. direction2: Vector3;
  82137. /**
  82138. * Creates a new instance PointParticleEmitter
  82139. */
  82140. constructor();
  82141. /**
  82142. * Called by the particle System when the direction is computed for the created particle.
  82143. * @param worldMatrix is the world matrix of the particle system
  82144. * @param directionToUpdate is the direction vector to update with the result
  82145. * @param particle is the particle we are computed the direction for
  82146. */
  82147. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82148. /**
  82149. * Called by the particle System when the position is computed for the created particle.
  82150. * @param worldMatrix is the world matrix of the particle system
  82151. * @param positionToUpdate is the position vector to update with the result
  82152. * @param particle is the particle we are computed the position for
  82153. */
  82154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82155. /**
  82156. * Clones the current emitter and returns a copy of it
  82157. * @returns the new emitter
  82158. */
  82159. clone(): PointParticleEmitter;
  82160. /**
  82161. * Called by the GPUParticleSystem to setup the update shader
  82162. * @param effect defines the update shader
  82163. */
  82164. applyToShader(effect: Effect): void;
  82165. /**
  82166. * Returns a string to use to update the GPU particles update shader
  82167. * @returns a string containng the defines string
  82168. */
  82169. getEffectDefines(): string;
  82170. /**
  82171. * Returns the string "PointParticleEmitter"
  82172. * @returns a string containing the class name
  82173. */
  82174. getClassName(): string;
  82175. /**
  82176. * Serializes the particle system to a JSON object.
  82177. * @returns the JSON object
  82178. */
  82179. serialize(): any;
  82180. /**
  82181. * Parse properties from a JSON object
  82182. * @param serializationObject defines the JSON object
  82183. */
  82184. parse(serializationObject: any): void;
  82185. }
  82186. }
  82187. declare module BABYLON {
  82188. /**
  82189. * Particle emitter emitting particles from the inside of a sphere.
  82190. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  82191. */
  82192. export class SphereParticleEmitter implements IParticleEmitterType {
  82193. /**
  82194. * The radius of the emission sphere.
  82195. */
  82196. radius: number;
  82197. /**
  82198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82199. */
  82200. radiusRange: number;
  82201. /**
  82202. * How much to randomize the particle direction [0-1].
  82203. */
  82204. directionRandomizer: number;
  82205. /**
  82206. * Creates a new instance SphereParticleEmitter
  82207. * @param radius the radius of the emission sphere (1 by default)
  82208. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82209. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82210. */
  82211. constructor(
  82212. /**
  82213. * The radius of the emission sphere.
  82214. */
  82215. radius?: number,
  82216. /**
  82217. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82218. */
  82219. radiusRange?: number,
  82220. /**
  82221. * How much to randomize the particle direction [0-1].
  82222. */
  82223. directionRandomizer?: number);
  82224. /**
  82225. * Called by the particle System when the direction is computed for the created particle.
  82226. * @param worldMatrix is the world matrix of the particle system
  82227. * @param directionToUpdate is the direction vector to update with the result
  82228. * @param particle is the particle we are computed the direction for
  82229. */
  82230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82231. /**
  82232. * Called by the particle System when the position is computed for the created particle.
  82233. * @param worldMatrix is the world matrix of the particle system
  82234. * @param positionToUpdate is the position vector to update with the result
  82235. * @param particle is the particle we are computed the position for
  82236. */
  82237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82238. /**
  82239. * Clones the current emitter and returns a copy of it
  82240. * @returns the new emitter
  82241. */
  82242. clone(): SphereParticleEmitter;
  82243. /**
  82244. * Called by the GPUParticleSystem to setup the update shader
  82245. * @param effect defines the update shader
  82246. */
  82247. applyToShader(effect: Effect): void;
  82248. /**
  82249. * Returns a string to use to update the GPU particles update shader
  82250. * @returns a string containng the defines string
  82251. */
  82252. getEffectDefines(): string;
  82253. /**
  82254. * Returns the string "SphereParticleEmitter"
  82255. * @returns a string containing the class name
  82256. */
  82257. getClassName(): string;
  82258. /**
  82259. * Serializes the particle system to a JSON object.
  82260. * @returns the JSON object
  82261. */
  82262. serialize(): any;
  82263. /**
  82264. * Parse properties from a JSON object
  82265. * @param serializationObject defines the JSON object
  82266. */
  82267. parse(serializationObject: any): void;
  82268. }
  82269. /**
  82270. * Particle emitter emitting particles from the inside of a sphere.
  82271. * It emits the particles randomly between two vectors.
  82272. */
  82273. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  82274. /**
  82275. * The min limit of the emission direction.
  82276. */
  82277. direction1: Vector3;
  82278. /**
  82279. * The max limit of the emission direction.
  82280. */
  82281. direction2: Vector3;
  82282. /**
  82283. * Creates a new instance SphereDirectedParticleEmitter
  82284. * @param radius the radius of the emission sphere (1 by default)
  82285. * @param direction1 the min limit of the emission direction (up vector by default)
  82286. * @param direction2 the max limit of the emission direction (up vector by default)
  82287. */
  82288. constructor(radius?: number,
  82289. /**
  82290. * The min limit of the emission direction.
  82291. */
  82292. direction1?: Vector3,
  82293. /**
  82294. * The max limit of the emission direction.
  82295. */
  82296. direction2?: Vector3);
  82297. /**
  82298. * Called by the particle System when the direction is computed for the created particle.
  82299. * @param worldMatrix is the world matrix of the particle system
  82300. * @param directionToUpdate is the direction vector to update with the result
  82301. * @param particle is the particle we are computed the direction for
  82302. */
  82303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82304. /**
  82305. * Clones the current emitter and returns a copy of it
  82306. * @returns the new emitter
  82307. */
  82308. clone(): SphereDirectedParticleEmitter;
  82309. /**
  82310. * Called by the GPUParticleSystem to setup the update shader
  82311. * @param effect defines the update shader
  82312. */
  82313. applyToShader(effect: Effect): void;
  82314. /**
  82315. * Returns a string to use to update the GPU particles update shader
  82316. * @returns a string containng the defines string
  82317. */
  82318. getEffectDefines(): string;
  82319. /**
  82320. * Returns the string "SphereDirectedParticleEmitter"
  82321. * @returns a string containing the class name
  82322. */
  82323. getClassName(): string;
  82324. /**
  82325. * Serializes the particle system to a JSON object.
  82326. * @returns the JSON object
  82327. */
  82328. serialize(): any;
  82329. /**
  82330. * Parse properties from a JSON object
  82331. * @param serializationObject defines the JSON object
  82332. */
  82333. parse(serializationObject: any): void;
  82334. }
  82335. }
  82336. declare module BABYLON {
  82337. /**
  82338. * Interface representing a particle system in Babylon.js.
  82339. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  82340. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  82341. */
  82342. export interface IParticleSystem {
  82343. /**
  82344. * List of animations used by the particle system.
  82345. */
  82346. animations: Animation[];
  82347. /**
  82348. * The id of the Particle system.
  82349. */
  82350. id: string;
  82351. /**
  82352. * The name of the Particle system.
  82353. */
  82354. name: string;
  82355. /**
  82356. * The emitter represents the Mesh or position we are attaching the particle system to.
  82357. */
  82358. emitter: Nullable<AbstractMesh | Vector3>;
  82359. /**
  82360. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82361. */
  82362. isBillboardBased: boolean;
  82363. /**
  82364. * The rendering group used by the Particle system to chose when to render.
  82365. */
  82366. renderingGroupId: number;
  82367. /**
  82368. * The layer mask we are rendering the particles through.
  82369. */
  82370. layerMask: number;
  82371. /**
  82372. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82373. */
  82374. updateSpeed: number;
  82375. /**
  82376. * The amount of time the particle system is running (depends of the overall update speed).
  82377. */
  82378. targetStopDuration: number;
  82379. /**
  82380. * The texture used to render each particle. (this can be a spritesheet)
  82381. */
  82382. particleTexture: Nullable<Texture>;
  82383. /**
  82384. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  82385. */
  82386. blendMode: number;
  82387. /**
  82388. * Minimum life time of emitting particles.
  82389. */
  82390. minLifeTime: number;
  82391. /**
  82392. * Maximum life time of emitting particles.
  82393. */
  82394. maxLifeTime: number;
  82395. /**
  82396. * Minimum Size of emitting particles.
  82397. */
  82398. minSize: number;
  82399. /**
  82400. * Maximum Size of emitting particles.
  82401. */
  82402. maxSize: number;
  82403. /**
  82404. * Minimum scale of emitting particles on X axis.
  82405. */
  82406. minScaleX: number;
  82407. /**
  82408. * Maximum scale of emitting particles on X axis.
  82409. */
  82410. maxScaleX: number;
  82411. /**
  82412. * Minimum scale of emitting particles on Y axis.
  82413. */
  82414. minScaleY: number;
  82415. /**
  82416. * Maximum scale of emitting particles on Y axis.
  82417. */
  82418. maxScaleY: number;
  82419. /**
  82420. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82421. */
  82422. color1: Color4;
  82423. /**
  82424. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82425. */
  82426. color2: Color4;
  82427. /**
  82428. * Color the particle will have at the end of its lifetime.
  82429. */
  82430. colorDead: Color4;
  82431. /**
  82432. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  82433. */
  82434. emitRate: number;
  82435. /**
  82436. * You can use gravity if you want to give an orientation to your particles.
  82437. */
  82438. gravity: Vector3;
  82439. /**
  82440. * Minimum power of emitting particles.
  82441. */
  82442. minEmitPower: number;
  82443. /**
  82444. * Maximum power of emitting particles.
  82445. */
  82446. maxEmitPower: number;
  82447. /**
  82448. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82449. */
  82450. minAngularSpeed: number;
  82451. /**
  82452. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82453. */
  82454. maxAngularSpeed: number;
  82455. /**
  82456. * Gets or sets the minimal initial rotation in radians.
  82457. */
  82458. minInitialRotation: number;
  82459. /**
  82460. * Gets or sets the maximal initial rotation in radians.
  82461. */
  82462. maxInitialRotation: number;
  82463. /**
  82464. * The particle emitter type defines the emitter used by the particle system.
  82465. * It can be for example box, sphere, or cone...
  82466. */
  82467. particleEmitterType: Nullable<IParticleEmitterType>;
  82468. /**
  82469. * Defines the delay in milliseconds before starting the system (0 by default)
  82470. */
  82471. startDelay: number;
  82472. /**
  82473. * 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
  82474. */
  82475. preWarmCycles: number;
  82476. /**
  82477. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  82478. */
  82479. preWarmStepOffset: number;
  82480. /**
  82481. * 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)
  82482. */
  82483. spriteCellChangeSpeed: number;
  82484. /**
  82485. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82486. */
  82487. startSpriteCellID: number;
  82488. /**
  82489. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82490. */
  82491. endSpriteCellID: number;
  82492. /**
  82493. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82494. */
  82495. spriteCellWidth: number;
  82496. /**
  82497. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82498. */
  82499. spriteCellHeight: number;
  82500. /**
  82501. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82502. */
  82503. spriteRandomStartCell: boolean;
  82504. /**
  82505. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  82506. */
  82507. isAnimationSheetEnabled: boolean;
  82508. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82509. translationPivot: Vector2;
  82510. /**
  82511. * Gets or sets a texture used to add random noise to particle positions
  82512. */
  82513. noiseTexture: Nullable<BaseTexture>;
  82514. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82515. noiseStrength: Vector3;
  82516. /**
  82517. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82518. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82519. */
  82520. billboardMode: number;
  82521. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82522. limitVelocityDamping: number;
  82523. /**
  82524. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82525. */
  82526. beginAnimationOnStart: boolean;
  82527. /**
  82528. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82529. */
  82530. beginAnimationFrom: number;
  82531. /**
  82532. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82533. */
  82534. beginAnimationTo: number;
  82535. /**
  82536. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82537. */
  82538. beginAnimationLoop: boolean;
  82539. /**
  82540. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82541. */
  82542. disposeOnStop: boolean;
  82543. /**
  82544. * Gets the maximum number of particles active at the same time.
  82545. * @returns The max number of active particles.
  82546. */
  82547. getCapacity(): number;
  82548. /**
  82549. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82550. * @returns True if it has been started, otherwise false.
  82551. */
  82552. isStarted(): boolean;
  82553. /**
  82554. * Animates the particle system for this frame.
  82555. */
  82556. animate(): void;
  82557. /**
  82558. * Renders the particle system in its current state.
  82559. * @returns the current number of particles
  82560. */
  82561. render(): number;
  82562. /**
  82563. * Dispose the particle system and frees its associated resources.
  82564. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82565. */
  82566. dispose(disposeTexture?: boolean): void;
  82567. /**
  82568. * Clones the particle system.
  82569. * @param name The name of the cloned object
  82570. * @param newEmitter The new emitter to use
  82571. * @returns the cloned particle system
  82572. */
  82573. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  82574. /**
  82575. * Serializes the particle system to a JSON object.
  82576. * @returns the JSON object
  82577. */
  82578. serialize(): any;
  82579. /**
  82580. * Rebuild the particle system
  82581. */
  82582. rebuild(): void;
  82583. /**
  82584. * Starts the particle system and begins to emit
  82585. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  82586. */
  82587. start(delay?: number): void;
  82588. /**
  82589. * Stops the particle system.
  82590. */
  82591. stop(): void;
  82592. /**
  82593. * Remove all active particles
  82594. */
  82595. reset(): void;
  82596. /**
  82597. * Is this system ready to be used/rendered
  82598. * @return true if the system is ready
  82599. */
  82600. isReady(): boolean;
  82601. /**
  82602. * Adds a new color gradient
  82603. * @param gradient defines the gradient to use (between 0 and 1)
  82604. * @param color1 defines the color to affect to the specified gradient
  82605. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82606. * @returns the current particle system
  82607. */
  82608. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82609. /**
  82610. * Remove a specific color gradient
  82611. * @param gradient defines the gradient to remove
  82612. * @returns the current particle system
  82613. */
  82614. removeColorGradient(gradient: number): IParticleSystem;
  82615. /**
  82616. * Adds a new size gradient
  82617. * @param gradient defines the gradient to use (between 0 and 1)
  82618. * @param factor defines the size factor to affect to the specified gradient
  82619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82620. * @returns the current particle system
  82621. */
  82622. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82623. /**
  82624. * Remove a specific size gradient
  82625. * @param gradient defines the gradient to remove
  82626. * @returns the current particle system
  82627. */
  82628. removeSizeGradient(gradient: number): IParticleSystem;
  82629. /**
  82630. * Gets the current list of color gradients.
  82631. * You must use addColorGradient and removeColorGradient to udpate this list
  82632. * @returns the list of color gradients
  82633. */
  82634. getColorGradients(): Nullable<Array<ColorGradient>>;
  82635. /**
  82636. * Gets the current list of size gradients.
  82637. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82638. * @returns the list of size gradients
  82639. */
  82640. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82641. /**
  82642. * Gets the current list of angular speed gradients.
  82643. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82644. * @returns the list of angular speed gradients
  82645. */
  82646. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82647. /**
  82648. * Adds a new angular speed gradient
  82649. * @param gradient defines the gradient to use (between 0 and 1)
  82650. * @param factor defines the angular speed to affect to the specified gradient
  82651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82652. * @returns the current particle system
  82653. */
  82654. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82655. /**
  82656. * Remove a specific angular speed gradient
  82657. * @param gradient defines the gradient to remove
  82658. * @returns the current particle system
  82659. */
  82660. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82661. /**
  82662. * Gets the current list of velocity gradients.
  82663. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82664. * @returns the list of velocity gradients
  82665. */
  82666. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82667. /**
  82668. * Adds a new velocity gradient
  82669. * @param gradient defines the gradient to use (between 0 and 1)
  82670. * @param factor defines the velocity to affect to the specified gradient
  82671. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82672. * @returns the current particle system
  82673. */
  82674. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82675. /**
  82676. * Remove a specific velocity gradient
  82677. * @param gradient defines the gradient to remove
  82678. * @returns the current particle system
  82679. */
  82680. removeVelocityGradient(gradient: number): IParticleSystem;
  82681. /**
  82682. * Gets the current list of limit velocity gradients.
  82683. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82684. * @returns the list of limit velocity gradients
  82685. */
  82686. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82687. /**
  82688. * Adds a new limit velocity gradient
  82689. * @param gradient defines the gradient to use (between 0 and 1)
  82690. * @param factor defines the limit velocity to affect to the specified gradient
  82691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82692. * @returns the current particle system
  82693. */
  82694. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82695. /**
  82696. * Remove a specific limit velocity gradient
  82697. * @param gradient defines the gradient to remove
  82698. * @returns the current particle system
  82699. */
  82700. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82701. /**
  82702. * Adds a new drag gradient
  82703. * @param gradient defines the gradient to use (between 0 and 1)
  82704. * @param factor defines the drag to affect to the specified gradient
  82705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82706. * @returns the current particle system
  82707. */
  82708. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82709. /**
  82710. * Remove a specific drag gradient
  82711. * @param gradient defines the gradient to remove
  82712. * @returns the current particle system
  82713. */
  82714. removeDragGradient(gradient: number): IParticleSystem;
  82715. /**
  82716. * Gets the current list of drag gradients.
  82717. * You must use addDragGradient and removeDragGradient to udpate this list
  82718. * @returns the list of drag gradients
  82719. */
  82720. getDragGradients(): Nullable<Array<FactorGradient>>;
  82721. /**
  82722. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82723. * @param gradient defines the gradient to use (between 0 and 1)
  82724. * @param factor defines the emit rate to affect to the specified gradient
  82725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82726. * @returns the current particle system
  82727. */
  82728. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82729. /**
  82730. * Remove a specific emit rate gradient
  82731. * @param gradient defines the gradient to remove
  82732. * @returns the current particle system
  82733. */
  82734. removeEmitRateGradient(gradient: number): IParticleSystem;
  82735. /**
  82736. * Gets the current list of emit rate gradients.
  82737. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82738. * @returns the list of emit rate gradients
  82739. */
  82740. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82741. /**
  82742. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82743. * @param gradient defines the gradient to use (between 0 and 1)
  82744. * @param factor defines the start size to affect to the specified gradient
  82745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82746. * @returns the current particle system
  82747. */
  82748. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82749. /**
  82750. * Remove a specific start size gradient
  82751. * @param gradient defines the gradient to remove
  82752. * @returns the current particle system
  82753. */
  82754. removeStartSizeGradient(gradient: number): IParticleSystem;
  82755. /**
  82756. * Gets the current list of start size gradients.
  82757. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82758. * @returns the list of start size gradients
  82759. */
  82760. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82761. /**
  82762. * Adds a new life time gradient
  82763. * @param gradient defines the gradient to use (between 0 and 1)
  82764. * @param factor defines the life time factor to affect to the specified gradient
  82765. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82766. * @returns the current particle system
  82767. */
  82768. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82769. /**
  82770. * Remove a specific life time gradient
  82771. * @param gradient defines the gradient to remove
  82772. * @returns the current particle system
  82773. */
  82774. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82775. /**
  82776. * Gets the current list of life time gradients.
  82777. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82778. * @returns the list of life time gradients
  82779. */
  82780. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82781. /**
  82782. * Gets the current list of color gradients.
  82783. * You must use addColorGradient and removeColorGradient to udpate this list
  82784. * @returns the list of color gradients
  82785. */
  82786. getColorGradients(): Nullable<Array<ColorGradient>>;
  82787. /**
  82788. * Adds a new ramp gradient used to remap particle colors
  82789. * @param gradient defines the gradient to use (between 0 and 1)
  82790. * @param color defines the color to affect to the specified gradient
  82791. * @returns the current particle system
  82792. */
  82793. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82794. /**
  82795. * Gets the current list of ramp gradients.
  82796. * You must use addRampGradient and removeRampGradient to udpate this list
  82797. * @returns the list of ramp gradients
  82798. */
  82799. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82800. /** Gets or sets a boolean indicating that ramp gradients must be used
  82801. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82802. */
  82803. useRampGradients: boolean;
  82804. /**
  82805. * Adds a new color remap gradient
  82806. * @param gradient defines the gradient to use (between 0 and 1)
  82807. * @param min defines the color remap minimal range
  82808. * @param max defines the color remap maximal range
  82809. * @returns the current particle system
  82810. */
  82811. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82812. /**
  82813. * Gets the current list of color remap gradients.
  82814. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82815. * @returns the list of color remap gradients
  82816. */
  82817. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82818. /**
  82819. * Adds a new alpha remap gradient
  82820. * @param gradient defines the gradient to use (between 0 and 1)
  82821. * @param min defines the alpha remap minimal range
  82822. * @param max defines the alpha remap maximal range
  82823. * @returns the current particle system
  82824. */
  82825. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82826. /**
  82827. * Gets the current list of alpha remap gradients.
  82828. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82829. * @returns the list of alpha remap gradients
  82830. */
  82831. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82832. /**
  82833. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82834. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82835. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82836. * @returns the emitter
  82837. */
  82838. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82839. /**
  82840. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82841. * @param radius The radius of the hemisphere to emit from
  82842. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82843. * @returns the emitter
  82844. */
  82845. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  82846. /**
  82847. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82848. * @param radius The radius of the sphere to emit from
  82849. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82850. * @returns the emitter
  82851. */
  82852. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  82853. /**
  82854. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82855. * @param radius The radius of the sphere to emit from
  82856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82858. * @returns the emitter
  82859. */
  82860. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82861. /**
  82862. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82863. * @param radius The radius of the emission cylinder
  82864. * @param height The height of the emission cylinder
  82865. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82866. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82867. * @returns the emitter
  82868. */
  82869. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  82870. /**
  82871. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82872. * @param radius The radius of the cylinder to emit from
  82873. * @param height The height of the emission cylinder
  82874. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82875. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82876. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82877. * @returns the emitter
  82878. */
  82879. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82880. /**
  82881. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82882. * @param radius The radius of the cone to emit from
  82883. * @param angle The base angle of the cone
  82884. * @returns the emitter
  82885. */
  82886. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  82887. /**
  82888. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82889. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82890. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82891. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82892. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82893. * @returns the emitter
  82894. */
  82895. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82896. /**
  82897. * Get hosting scene
  82898. * @returns the scene
  82899. */
  82900. getScene(): Scene;
  82901. }
  82902. }
  82903. declare module BABYLON {
  82904. /**
  82905. * Creates an instance based on a source mesh.
  82906. */
  82907. export class InstancedMesh extends AbstractMesh {
  82908. private _sourceMesh;
  82909. private _currentLOD;
  82910. /** @hidden */
  82911. _indexInSourceMeshInstanceArray: number;
  82912. constructor(name: string, source: Mesh);
  82913. /**
  82914. * Returns the string "InstancedMesh".
  82915. */
  82916. getClassName(): string;
  82917. /** Gets the list of lights affecting that mesh */
  82918. readonly lightSources: Light[];
  82919. _resyncLightSources(): void;
  82920. _resyncLighSource(light: Light): void;
  82921. _removeLightSource(light: Light): void;
  82922. /**
  82923. * If the source mesh receives shadows
  82924. */
  82925. readonly receiveShadows: boolean;
  82926. /**
  82927. * The material of the source mesh
  82928. */
  82929. readonly material: Nullable<Material>;
  82930. /**
  82931. * Visibility of the source mesh
  82932. */
  82933. readonly visibility: number;
  82934. /**
  82935. * Skeleton of the source mesh
  82936. */
  82937. readonly skeleton: Nullable<Skeleton>;
  82938. /**
  82939. * Rendering ground id of the source mesh
  82940. */
  82941. renderingGroupId: number;
  82942. /**
  82943. * Returns the total number of vertices (integer).
  82944. */
  82945. getTotalVertices(): number;
  82946. /**
  82947. * Returns a positive integer : the total number of indices in this mesh geometry.
  82948. * @returns the numner of indices or zero if the mesh has no geometry.
  82949. */
  82950. getTotalIndices(): number;
  82951. /**
  82952. * The source mesh of the instance
  82953. */
  82954. readonly sourceMesh: Mesh;
  82955. /**
  82956. * Is this node ready to be used/rendered
  82957. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82958. * @return {boolean} is it ready
  82959. */
  82960. isReady(completeCheck?: boolean): boolean;
  82961. /**
  82962. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82963. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  82964. * @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.
  82965. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  82966. */
  82967. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  82968. /**
  82969. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82970. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82971. * The `data` are either a numeric array either a Float32Array.
  82972. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  82973. * 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).
  82974. * Note that a new underlying VertexBuffer object is created each call.
  82975. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82976. *
  82977. * Possible `kind` values :
  82978. * - VertexBuffer.PositionKind
  82979. * - VertexBuffer.UVKind
  82980. * - VertexBuffer.UV2Kind
  82981. * - VertexBuffer.UV3Kind
  82982. * - VertexBuffer.UV4Kind
  82983. * - VertexBuffer.UV5Kind
  82984. * - VertexBuffer.UV6Kind
  82985. * - VertexBuffer.ColorKind
  82986. * - VertexBuffer.MatricesIndicesKind
  82987. * - VertexBuffer.MatricesIndicesExtraKind
  82988. * - VertexBuffer.MatricesWeightsKind
  82989. * - VertexBuffer.MatricesWeightsExtraKind
  82990. *
  82991. * Returns the Mesh.
  82992. */
  82993. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  82994. /**
  82995. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82996. * If the mesh has no geometry, it is simply returned as it is.
  82997. * The `data` are either a numeric array either a Float32Array.
  82998. * No new underlying VertexBuffer object is created.
  82999. * 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.
  83000. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83001. *
  83002. * Possible `kind` values :
  83003. * - VertexBuffer.PositionKind
  83004. * - VertexBuffer.UVKind
  83005. * - VertexBuffer.UV2Kind
  83006. * - VertexBuffer.UV3Kind
  83007. * - VertexBuffer.UV4Kind
  83008. * - VertexBuffer.UV5Kind
  83009. * - VertexBuffer.UV6Kind
  83010. * - VertexBuffer.ColorKind
  83011. * - VertexBuffer.MatricesIndicesKind
  83012. * - VertexBuffer.MatricesIndicesExtraKind
  83013. * - VertexBuffer.MatricesWeightsKind
  83014. * - VertexBuffer.MatricesWeightsExtraKind
  83015. *
  83016. * Returns the Mesh.
  83017. */
  83018. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83019. /**
  83020. * Sets the mesh indices.
  83021. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83022. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83023. * This method creates a new index buffer each call.
  83024. * Returns the Mesh.
  83025. */
  83026. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  83027. /**
  83028. * Boolean : True if the mesh owns the requested kind of data.
  83029. */
  83030. isVerticesDataPresent(kind: string): boolean;
  83031. /**
  83032. * Returns an array of indices (IndicesArray).
  83033. */
  83034. getIndices(): Nullable<IndicesArray>;
  83035. readonly _positions: Nullable<Vector3[]>;
  83036. /**
  83037. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83038. * This means the mesh underlying bounding box and sphere are recomputed.
  83039. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83040. * @returns the current mesh
  83041. */
  83042. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  83043. /** @hidden */
  83044. _preActivate(): InstancedMesh;
  83045. /** @hidden */
  83046. _activate(renderId: number, intermediateRendering: boolean): boolean;
  83047. /** @hidden */
  83048. _postActivate(): void;
  83049. getWorldMatrix(): Matrix;
  83050. readonly isAnInstance: boolean;
  83051. /**
  83052. * Returns the current associated LOD AbstractMesh.
  83053. */
  83054. getLOD(camera: Camera): AbstractMesh;
  83055. /** @hidden */
  83056. _syncSubMeshes(): InstancedMesh;
  83057. /** @hidden */
  83058. _generatePointsArray(): boolean;
  83059. /**
  83060. * Creates a new InstancedMesh from the current mesh.
  83061. * - name (string) : the cloned mesh name
  83062. * - newParent (optional Node) : the optional Node to parent the clone to.
  83063. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83064. *
  83065. * Returns the clone.
  83066. */
  83067. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  83068. /**
  83069. * Disposes the InstancedMesh.
  83070. * Returns nothing.
  83071. */
  83072. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83073. }
  83074. }
  83075. declare module BABYLON {
  83076. /**
  83077. * Defines the options associated with the creation of a shader material.
  83078. */
  83079. export interface IShaderMaterialOptions {
  83080. /**
  83081. * Does the material work in alpha blend mode
  83082. */
  83083. needAlphaBlending: boolean;
  83084. /**
  83085. * Does the material work in alpha test mode
  83086. */
  83087. needAlphaTesting: boolean;
  83088. /**
  83089. * The list of attribute names used in the shader
  83090. */
  83091. attributes: string[];
  83092. /**
  83093. * The list of unifrom names used in the shader
  83094. */
  83095. uniforms: string[];
  83096. /**
  83097. * The list of UBO names used in the shader
  83098. */
  83099. uniformBuffers: string[];
  83100. /**
  83101. * The list of sampler names used in the shader
  83102. */
  83103. samplers: string[];
  83104. /**
  83105. * The list of defines used in the shader
  83106. */
  83107. defines: string[];
  83108. }
  83109. /**
  83110. * 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.
  83111. *
  83112. * This returned material effects how the mesh will look based on the code in the shaders.
  83113. *
  83114. * @see http://doc.babylonjs.com/how_to/shader_material
  83115. */
  83116. export class ShaderMaterial extends Material {
  83117. private _shaderPath;
  83118. private _options;
  83119. private _textures;
  83120. private _textureArrays;
  83121. private _floats;
  83122. private _ints;
  83123. private _floatsArrays;
  83124. private _colors3;
  83125. private _colors3Arrays;
  83126. private _colors4;
  83127. private _colors4Arrays;
  83128. private _vectors2;
  83129. private _vectors3;
  83130. private _vectors4;
  83131. private _matrices;
  83132. private _matrices3x3;
  83133. private _matrices2x2;
  83134. private _vectors2Arrays;
  83135. private _vectors3Arrays;
  83136. private _vectors4Arrays;
  83137. private _cachedWorldViewMatrix;
  83138. private _cachedWorldViewProjectionMatrix;
  83139. private _renderId;
  83140. /**
  83141. * Instantiate a new shader material.
  83142. * 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.
  83143. * This returned material effects how the mesh will look based on the code in the shaders.
  83144. * @see http://doc.babylonjs.com/how_to/shader_material
  83145. * @param name Define the name of the material in the scene
  83146. * @param scene Define the scene the material belongs to
  83147. * @param shaderPath Defines the route to the shader code in one of three ways:
  83148. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  83149. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  83150. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  83151. * @param options Define the options used to create the shader
  83152. */
  83153. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  83154. /**
  83155. * Gets the options used to compile the shader.
  83156. * They can be modified to trigger a new compilation
  83157. */
  83158. readonly options: IShaderMaterialOptions;
  83159. /**
  83160. * Gets the current class name of the material e.g. "ShaderMaterial"
  83161. * Mainly use in serialization.
  83162. * @returns the class name
  83163. */
  83164. getClassName(): string;
  83165. /**
  83166. * Specifies if the material will require alpha blending
  83167. * @returns a boolean specifying if alpha blending is needed
  83168. */
  83169. needAlphaBlending(): boolean;
  83170. /**
  83171. * Specifies if this material should be rendered in alpha test mode
  83172. * @returns a boolean specifying if an alpha test is needed.
  83173. */
  83174. needAlphaTesting(): boolean;
  83175. private _checkUniform;
  83176. /**
  83177. * Set a texture in the shader.
  83178. * @param name Define the name of the uniform samplers as defined in the shader
  83179. * @param texture Define the texture to bind to this sampler
  83180. * @return the material itself allowing "fluent" like uniform updates
  83181. */
  83182. setTexture(name: string, texture: Texture): ShaderMaterial;
  83183. /**
  83184. * Set a texture array in the shader.
  83185. * @param name Define the name of the uniform sampler array as defined in the shader
  83186. * @param textures Define the list of textures to bind to this sampler
  83187. * @return the material itself allowing "fluent" like uniform updates
  83188. */
  83189. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  83190. /**
  83191. * Set a float in the shader.
  83192. * @param name Define the name of the uniform as defined in the shader
  83193. * @param value Define the value to give to the uniform
  83194. * @return the material itself allowing "fluent" like uniform updates
  83195. */
  83196. setFloat(name: string, value: number): ShaderMaterial;
  83197. /**
  83198. * Set a int in the shader.
  83199. * @param name Define the name of the uniform as defined in the shader
  83200. * @param value Define the value to give to the uniform
  83201. * @return the material itself allowing "fluent" like uniform updates
  83202. */
  83203. setInt(name: string, value: number): ShaderMaterial;
  83204. /**
  83205. * Set an array of floats in the shader.
  83206. * @param name Define the name of the uniform as defined in the shader
  83207. * @param value Define the value to give to the uniform
  83208. * @return the material itself allowing "fluent" like uniform updates
  83209. */
  83210. setFloats(name: string, value: number[]): ShaderMaterial;
  83211. /**
  83212. * Set a vec3 in the shader from a Color3.
  83213. * @param name Define the name of the uniform as defined in the shader
  83214. * @param value Define the value to give to the uniform
  83215. * @return the material itself allowing "fluent" like uniform updates
  83216. */
  83217. setColor3(name: string, value: Color3): ShaderMaterial;
  83218. /**
  83219. * Set a vec3 array in the shader from a Color3 array.
  83220. * @param name Define the name of the uniform as defined in the shader
  83221. * @param value Define the value to give to the uniform
  83222. * @return the material itself allowing "fluent" like uniform updates
  83223. */
  83224. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  83225. /**
  83226. * Set a vec4 in the shader from a Color4.
  83227. * @param name Define the name of the uniform as defined in the shader
  83228. * @param value Define the value to give to the uniform
  83229. * @return the material itself allowing "fluent" like uniform updates
  83230. */
  83231. setColor4(name: string, value: Color4): ShaderMaterial;
  83232. /**
  83233. * Set a vec4 array in the shader from a Color4 array.
  83234. * @param name Define the name of the uniform as defined in the shader
  83235. * @param value Define the value to give to the uniform
  83236. * @return the material itself allowing "fluent" like uniform updates
  83237. */
  83238. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  83239. /**
  83240. * Set a vec2 in the shader from a Vector2.
  83241. * @param name Define the name of the uniform as defined in the shader
  83242. * @param value Define the value to give to the uniform
  83243. * @return the material itself allowing "fluent" like uniform updates
  83244. */
  83245. setVector2(name: string, value: Vector2): ShaderMaterial;
  83246. /**
  83247. * Set a vec3 in the shader from a Vector3.
  83248. * @param name Define the name of the uniform as defined in the shader
  83249. * @param value Define the value to give to the uniform
  83250. * @return the material itself allowing "fluent" like uniform updates
  83251. */
  83252. setVector3(name: string, value: Vector3): ShaderMaterial;
  83253. /**
  83254. * Set a vec4 in the shader from a Vector4.
  83255. * @param name Define the name of the uniform as defined in the shader
  83256. * @param value Define the value to give to the uniform
  83257. * @return the material itself allowing "fluent" like uniform updates
  83258. */
  83259. setVector4(name: string, value: Vector4): ShaderMaterial;
  83260. /**
  83261. * Set a mat4 in the shader from a Matrix.
  83262. * @param name Define the name of the uniform as defined in the shader
  83263. * @param value Define the value to give to the uniform
  83264. * @return the material itself allowing "fluent" like uniform updates
  83265. */
  83266. setMatrix(name: string, value: Matrix): ShaderMaterial;
  83267. /**
  83268. * Set a mat3 in the shader from a Float32Array.
  83269. * @param name Define the name of the uniform as defined in the shader
  83270. * @param value Define the value to give to the uniform
  83271. * @return the material itself allowing "fluent" like uniform updates
  83272. */
  83273. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  83274. /**
  83275. * Set a mat2 in the shader from a Float32Array.
  83276. * @param name Define the name of the uniform as defined in the shader
  83277. * @param value Define the value to give to the uniform
  83278. * @return the material itself allowing "fluent" like uniform updates
  83279. */
  83280. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  83281. /**
  83282. * Set a vec2 array in the shader from a number array.
  83283. * @param name Define the name of the uniform as defined in the shader
  83284. * @param value Define the value to give to the uniform
  83285. * @return the material itself allowing "fluent" like uniform updates
  83286. */
  83287. setArray2(name: string, value: number[]): ShaderMaterial;
  83288. /**
  83289. * Set a vec3 array in the shader from a number array.
  83290. * @param name Define the name of the uniform as defined in the shader
  83291. * @param value Define the value to give to the uniform
  83292. * @return the material itself allowing "fluent" like uniform updates
  83293. */
  83294. setArray3(name: string, value: number[]): ShaderMaterial;
  83295. /**
  83296. * Set a vec4 array in the shader from a number array.
  83297. * @param name Define the name of the uniform as defined in the shader
  83298. * @param value Define the value to give to the uniform
  83299. * @return the material itself allowing "fluent" like uniform updates
  83300. */
  83301. setArray4(name: string, value: number[]): ShaderMaterial;
  83302. private _checkCache;
  83303. /**
  83304. * Specifies that the submesh is ready to be used
  83305. * @param mesh defines the mesh to check
  83306. * @param subMesh defines which submesh to check
  83307. * @param useInstances specifies that instances should be used
  83308. * @returns a boolean indicating that the submesh is ready or not
  83309. */
  83310. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83311. /**
  83312. * Checks if the material is ready to render the requested mesh
  83313. * @param mesh Define the mesh to render
  83314. * @param useInstances Define whether or not the material is used with instances
  83315. * @returns true if ready, otherwise false
  83316. */
  83317. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83318. /**
  83319. * Binds the world matrix to the material
  83320. * @param world defines the world transformation matrix
  83321. */
  83322. bindOnlyWorldMatrix(world: Matrix): void;
  83323. /**
  83324. * Binds the material to the mesh
  83325. * @param world defines the world transformation matrix
  83326. * @param mesh defines the mesh to bind the material to
  83327. */
  83328. bind(world: Matrix, mesh?: Mesh): void;
  83329. /**
  83330. * Gets the active textures from the material
  83331. * @returns an array of textures
  83332. */
  83333. getActiveTextures(): BaseTexture[];
  83334. /**
  83335. * Specifies if the material uses a texture
  83336. * @param texture defines the texture to check against the material
  83337. * @returns a boolean specifying if the material uses the texture
  83338. */
  83339. hasTexture(texture: BaseTexture): boolean;
  83340. /**
  83341. * Makes a duplicate of the material, and gives it a new name
  83342. * @param name defines the new name for the duplicated material
  83343. * @returns the cloned material
  83344. */
  83345. clone(name: string): ShaderMaterial;
  83346. /**
  83347. * Disposes the material
  83348. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83349. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  83350. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  83351. */
  83352. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  83353. /**
  83354. * Serializes this material in a JSON representation
  83355. * @returns the serialized material object
  83356. */
  83357. serialize(): any;
  83358. /**
  83359. * Creates a shader material from parsed shader material data
  83360. * @param source defines the JSON represnetation of the material
  83361. * @param scene defines the hosting scene
  83362. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83363. * @returns a new material
  83364. */
  83365. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  83366. }
  83367. }
  83368. declare module BABYLON {
  83369. /** @hidden */
  83370. export var colorPixelShader: {
  83371. name: string;
  83372. shader: string;
  83373. };
  83374. }
  83375. declare module BABYLON {
  83376. /** @hidden */
  83377. export var colorVertexShader: {
  83378. name: string;
  83379. shader: string;
  83380. };
  83381. }
  83382. declare module BABYLON {
  83383. /**
  83384. * Line mesh
  83385. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83386. */
  83387. export class LinesMesh extends Mesh {
  83388. /**
  83389. * If vertex color should be applied to the mesh
  83390. */
  83391. readonly useVertexColor?: boolean | undefined;
  83392. /**
  83393. * If vertex alpha should be applied to the mesh
  83394. */
  83395. readonly useVertexAlpha?: boolean | undefined;
  83396. /**
  83397. * Color of the line (Default: White)
  83398. */
  83399. color: Color3;
  83400. /**
  83401. * Alpha of the line (Default: 1)
  83402. */
  83403. alpha: number;
  83404. /**
  83405. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83406. * This margin is expressed in world space coordinates, so its value may vary.
  83407. * Default value is 0.1
  83408. */
  83409. intersectionThreshold: number;
  83410. private _colorShader;
  83411. private color4;
  83412. /**
  83413. * Creates a new LinesMesh
  83414. * @param name defines the name
  83415. * @param scene defines the hosting scene
  83416. * @param parent defines the parent mesh if any
  83417. * @param source defines the optional source LinesMesh used to clone data from
  83418. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83419. * When false, achieved by calling a clone(), also passing False.
  83420. * This will make creation of children, recursive.
  83421. * @param useVertexColor defines if this LinesMesh supports vertex color
  83422. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83423. */
  83424. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  83425. /**
  83426. * If vertex color should be applied to the mesh
  83427. */
  83428. useVertexColor?: boolean | undefined,
  83429. /**
  83430. * If vertex alpha should be applied to the mesh
  83431. */
  83432. useVertexAlpha?: boolean | undefined);
  83433. private _addClipPlaneDefine;
  83434. private _removeClipPlaneDefine;
  83435. isReady(): boolean;
  83436. /**
  83437. * Returns the string "LineMesh"
  83438. */
  83439. getClassName(): string;
  83440. /**
  83441. * @hidden
  83442. */
  83443. /**
  83444. * @hidden
  83445. */
  83446. material: Material;
  83447. /**
  83448. * @hidden
  83449. */
  83450. readonly checkCollisions: boolean;
  83451. /** @hidden */
  83452. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  83453. /** @hidden */
  83454. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  83455. /**
  83456. * Disposes of the line mesh
  83457. * @param doNotRecurse If children should be disposed
  83458. */
  83459. dispose(doNotRecurse?: boolean): void;
  83460. /**
  83461. * Returns a new LineMesh object cloned from the current one.
  83462. */
  83463. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  83464. /**
  83465. * Creates a new InstancedLinesMesh object from the mesh model.
  83466. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83467. * @param name defines the name of the new instance
  83468. * @returns a new InstancedLinesMesh
  83469. */
  83470. createInstance(name: string): InstancedLinesMesh;
  83471. }
  83472. /**
  83473. * Creates an instance based on a source LinesMesh
  83474. */
  83475. export class InstancedLinesMesh extends InstancedMesh {
  83476. /**
  83477. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83478. * This margin is expressed in world space coordinates, so its value may vary.
  83479. * Initilized with the intersectionThreshold value of the source LinesMesh
  83480. */
  83481. intersectionThreshold: number;
  83482. constructor(name: string, source: LinesMesh);
  83483. /**
  83484. * Returns the string "InstancedLinesMesh".
  83485. */
  83486. getClassName(): string;
  83487. }
  83488. }
  83489. declare module BABYLON {
  83490. /** @hidden */
  83491. export var linePixelShader: {
  83492. name: string;
  83493. shader: string;
  83494. };
  83495. }
  83496. declare module BABYLON {
  83497. /** @hidden */
  83498. export var lineVertexShader: {
  83499. name: string;
  83500. shader: string;
  83501. };
  83502. }
  83503. declare module BABYLON {
  83504. interface AbstractMesh {
  83505. /**
  83506. * Gets the edgesRenderer associated with the mesh
  83507. */
  83508. edgesRenderer: Nullable<EdgesRenderer>;
  83509. }
  83510. interface LinesMesh {
  83511. /**
  83512. * Enables the edge rendering mode on the mesh.
  83513. * This mode makes the mesh edges visible
  83514. * @param epsilon defines the maximal distance between two angles to detect a face
  83515. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83516. * @returns the currentAbstractMesh
  83517. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83518. */
  83519. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83520. }
  83521. interface InstancedLinesMesh {
  83522. /**
  83523. * Enables the edge rendering mode on the mesh.
  83524. * This mode makes the mesh edges visible
  83525. * @param epsilon defines the maximal distance between two angles to detect a face
  83526. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83527. * @returns the current InstancedLinesMesh
  83528. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83529. */
  83530. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83531. }
  83532. /**
  83533. * Defines the minimum contract an Edges renderer should follow.
  83534. */
  83535. export interface IEdgesRenderer extends IDisposable {
  83536. /**
  83537. * Gets or sets a boolean indicating if the edgesRenderer is active
  83538. */
  83539. isEnabled: boolean;
  83540. /**
  83541. * Renders the edges of the attached mesh,
  83542. */
  83543. render(): void;
  83544. /**
  83545. * Checks wether or not the edges renderer is ready to render.
  83546. * @return true if ready, otherwise false.
  83547. */
  83548. isReady(): boolean;
  83549. }
  83550. /**
  83551. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83552. */
  83553. export class EdgesRenderer implements IEdgesRenderer {
  83554. /**
  83555. * Define the size of the edges with an orthographic camera
  83556. */
  83557. edgesWidthScalerForOrthographic: number;
  83558. /**
  83559. * Define the size of the edges with a perspective camera
  83560. */
  83561. edgesWidthScalerForPerspective: number;
  83562. protected _source: AbstractMesh;
  83563. protected _linesPositions: number[];
  83564. protected _linesNormals: number[];
  83565. protected _linesIndices: number[];
  83566. protected _epsilon: number;
  83567. protected _indicesCount: number;
  83568. protected _lineShader: ShaderMaterial;
  83569. protected _ib: DataBuffer;
  83570. protected _buffers: {
  83571. [key: string]: Nullable<VertexBuffer>;
  83572. };
  83573. protected _checkVerticesInsteadOfIndices: boolean;
  83574. private _meshRebuildObserver;
  83575. private _meshDisposeObserver;
  83576. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83577. isEnabled: boolean;
  83578. /**
  83579. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83580. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83581. * @param source Mesh used to create edges
  83582. * @param epsilon sum of angles in adjacency to check for edge
  83583. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83584. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83585. */
  83586. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83587. protected _prepareRessources(): void;
  83588. /** @hidden */
  83589. _rebuild(): void;
  83590. /**
  83591. * Releases the required resources for the edges renderer
  83592. */
  83593. dispose(): void;
  83594. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83595. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83596. /**
  83597. * Checks if the pair of p0 and p1 is en edge
  83598. * @param faceIndex
  83599. * @param edge
  83600. * @param faceNormals
  83601. * @param p0
  83602. * @param p1
  83603. * @private
  83604. */
  83605. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83606. /**
  83607. * push line into the position, normal and index buffer
  83608. * @protected
  83609. */
  83610. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83611. /**
  83612. * Generates lines edges from adjacencjes
  83613. * @private
  83614. */
  83615. _generateEdgesLines(): void;
  83616. /**
  83617. * Checks wether or not the edges renderer is ready to render.
  83618. * @return true if ready, otherwise false.
  83619. */
  83620. isReady(): boolean;
  83621. /**
  83622. * Renders the edges of the attached mesh,
  83623. */
  83624. render(): void;
  83625. }
  83626. /**
  83627. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83628. */
  83629. export class LineEdgesRenderer extends EdgesRenderer {
  83630. /**
  83631. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83632. * @param source LineMesh used to generate edges
  83633. * @param epsilon not important (specified angle for edge detection)
  83634. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83635. */
  83636. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83637. /**
  83638. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83639. */
  83640. _generateEdgesLines(): void;
  83641. }
  83642. }
  83643. declare module BABYLON {
  83644. /**
  83645. * This represents the object necessary to create a rendering group.
  83646. * This is exclusively used and created by the rendering manager.
  83647. * To modify the behavior, you use the available helpers in your scene or meshes.
  83648. * @hidden
  83649. */
  83650. export class RenderingGroup {
  83651. index: number;
  83652. private static _zeroVector;
  83653. private _scene;
  83654. private _opaqueSubMeshes;
  83655. private _transparentSubMeshes;
  83656. private _alphaTestSubMeshes;
  83657. private _depthOnlySubMeshes;
  83658. private _particleSystems;
  83659. private _spriteManagers;
  83660. private _opaqueSortCompareFn;
  83661. private _alphaTestSortCompareFn;
  83662. private _transparentSortCompareFn;
  83663. private _renderOpaque;
  83664. private _renderAlphaTest;
  83665. private _renderTransparent;
  83666. /** @hidden */
  83667. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83668. onBeforeTransparentRendering: () => void;
  83669. /**
  83670. * Set the opaque sort comparison function.
  83671. * If null the sub meshes will be render in the order they were created
  83672. */
  83673. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83674. /**
  83675. * Set the alpha test sort comparison function.
  83676. * If null the sub meshes will be render in the order they were created
  83677. */
  83678. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83679. /**
  83680. * Set the transparent sort comparison function.
  83681. * If null the sub meshes will be render in the order they were created
  83682. */
  83683. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83684. /**
  83685. * Creates a new rendering group.
  83686. * @param index The rendering group index
  83687. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83688. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83689. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83690. */
  83691. 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>);
  83692. /**
  83693. * Render all the sub meshes contained in the group.
  83694. * @param customRenderFunction Used to override the default render behaviour of the group.
  83695. * @returns true if rendered some submeshes.
  83696. */
  83697. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83698. /**
  83699. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83700. * @param subMeshes The submeshes to render
  83701. */
  83702. private renderOpaqueSorted;
  83703. /**
  83704. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  83705. * @param subMeshes The submeshes to render
  83706. */
  83707. private renderAlphaTestSorted;
  83708. /**
  83709. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  83710. * @param subMeshes The submeshes to render
  83711. */
  83712. private renderTransparentSorted;
  83713. /**
  83714. * Renders the submeshes in a specified order.
  83715. * @param subMeshes The submeshes to sort before render
  83716. * @param sortCompareFn The comparison function use to sort
  83717. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  83718. * @param transparent Specifies to activate blending if true
  83719. */
  83720. private static renderSorted;
  83721. /**
  83722. * Renders the submeshes in the order they were dispatched (no sort applied).
  83723. * @param subMeshes The submeshes to render
  83724. */
  83725. private static renderUnsorted;
  83726. /**
  83727. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83728. * are rendered back to front if in the same alpha index.
  83729. *
  83730. * @param a The first submesh
  83731. * @param b The second submesh
  83732. * @returns The result of the comparison
  83733. */
  83734. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  83735. /**
  83736. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83737. * are rendered back to front.
  83738. *
  83739. * @param a The first submesh
  83740. * @param b The second submesh
  83741. * @returns The result of the comparison
  83742. */
  83743. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  83744. /**
  83745. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83746. * are rendered front to back (prevent overdraw).
  83747. *
  83748. * @param a The first submesh
  83749. * @param b The second submesh
  83750. * @returns The result of the comparison
  83751. */
  83752. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83753. /**
  83754. * Resets the different lists of submeshes to prepare a new frame.
  83755. */
  83756. prepare(): void;
  83757. dispose(): void;
  83758. /**
  83759. * Inserts the submesh in its correct queue depending on its material.
  83760. * @param subMesh The submesh to dispatch
  83761. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83762. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83763. */
  83764. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83765. dispatchSprites(spriteManager: ISpriteManager): void;
  83766. dispatchParticles(particleSystem: IParticleSystem): void;
  83767. private _renderParticles;
  83768. private _renderSprites;
  83769. }
  83770. }
  83771. declare module BABYLON {
  83772. /**
  83773. * Interface describing the different options available in the rendering manager
  83774. * regarding Auto Clear between groups.
  83775. */
  83776. export interface IRenderingManagerAutoClearSetup {
  83777. /**
  83778. * Defines whether or not autoclear is enable.
  83779. */
  83780. autoClear: boolean;
  83781. /**
  83782. * Defines whether or not to autoclear the depth buffer.
  83783. */
  83784. depth: boolean;
  83785. /**
  83786. * Defines whether or not to autoclear the stencil buffer.
  83787. */
  83788. stencil: boolean;
  83789. }
  83790. /**
  83791. * This class is used by the onRenderingGroupObservable
  83792. */
  83793. export class RenderingGroupInfo {
  83794. /**
  83795. * The Scene that being rendered
  83796. */
  83797. scene: Scene;
  83798. /**
  83799. * The camera currently used for the rendering pass
  83800. */
  83801. camera: Nullable<Camera>;
  83802. /**
  83803. * The ID of the renderingGroup being processed
  83804. */
  83805. renderingGroupId: number;
  83806. }
  83807. /**
  83808. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83809. * It is enable to manage the different groups as well as the different necessary sort functions.
  83810. * This should not be used directly aside of the few static configurations
  83811. */
  83812. export class RenderingManager {
  83813. /**
  83814. * The max id used for rendering groups (not included)
  83815. */
  83816. static MAX_RENDERINGGROUPS: number;
  83817. /**
  83818. * The min id used for rendering groups (included)
  83819. */
  83820. static MIN_RENDERINGGROUPS: number;
  83821. /**
  83822. * Used to globally prevent autoclearing scenes.
  83823. */
  83824. static AUTOCLEAR: boolean;
  83825. /**
  83826. * @hidden
  83827. */
  83828. _useSceneAutoClearSetup: boolean;
  83829. private _scene;
  83830. private _renderingGroups;
  83831. private _depthStencilBufferAlreadyCleaned;
  83832. private _autoClearDepthStencil;
  83833. private _customOpaqueSortCompareFn;
  83834. private _customAlphaTestSortCompareFn;
  83835. private _customTransparentSortCompareFn;
  83836. private _renderingGroupInfo;
  83837. /**
  83838. * Instantiates a new rendering group for a particular scene
  83839. * @param scene Defines the scene the groups belongs to
  83840. */
  83841. constructor(scene: Scene);
  83842. private _clearDepthStencilBuffer;
  83843. /**
  83844. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  83845. * @hidden
  83846. */
  83847. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  83848. /**
  83849. * Resets the different information of the group to prepare a new frame
  83850. * @hidden
  83851. */
  83852. reset(): void;
  83853. /**
  83854. * Dispose and release the group and its associated resources.
  83855. * @hidden
  83856. */
  83857. dispose(): void;
  83858. /**
  83859. * Clear the info related to rendering groups preventing retention points during dispose.
  83860. */
  83861. freeRenderingGroups(): void;
  83862. private _prepareRenderingGroup;
  83863. /**
  83864. * Add a sprite manager to the rendering manager in order to render it this frame.
  83865. * @param spriteManager Define the sprite manager to render
  83866. */
  83867. dispatchSprites(spriteManager: ISpriteManager): void;
  83868. /**
  83869. * Add a particle system to the rendering manager in order to render it this frame.
  83870. * @param particleSystem Define the particle system to render
  83871. */
  83872. dispatchParticles(particleSystem: IParticleSystem): void;
  83873. /**
  83874. * Add a submesh to the manager in order to render it this frame
  83875. * @param subMesh The submesh to dispatch
  83876. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83877. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83878. */
  83879. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83880. /**
  83881. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83882. * This allowed control for front to back rendering or reversly depending of the special needs.
  83883. *
  83884. * @param renderingGroupId The rendering group id corresponding to its index
  83885. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83886. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83887. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83888. */
  83889. 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;
  83890. /**
  83891. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83892. *
  83893. * @param renderingGroupId The rendering group id corresponding to its index
  83894. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83895. * @param depth Automatically clears depth between groups if true and autoClear is true.
  83896. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  83897. */
  83898. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  83899. /**
  83900. * Gets the current auto clear configuration for one rendering group of the rendering
  83901. * manager.
  83902. * @param index the rendering group index to get the information for
  83903. * @returns The auto clear setup for the requested rendering group
  83904. */
  83905. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  83906. }
  83907. }
  83908. declare module BABYLON {
  83909. /**
  83910. * This Helps creating a texture that will be created from a camera in your scene.
  83911. * It is basically a dynamic texture that could be used to create special effects for instance.
  83912. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  83913. */
  83914. export class RenderTargetTexture extends Texture {
  83915. isCube: boolean;
  83916. /**
  83917. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  83918. */
  83919. static readonly REFRESHRATE_RENDER_ONCE: number;
  83920. /**
  83921. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  83922. */
  83923. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  83924. /**
  83925. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  83926. * the central point of your effect and can save a lot of performances.
  83927. */
  83928. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  83929. /**
  83930. * Use this predicate to dynamically define the list of mesh you want to render.
  83931. * If set, the renderList property will be overwritten.
  83932. */
  83933. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  83934. private _renderList;
  83935. /**
  83936. * Use this list to define the list of mesh you want to render.
  83937. */
  83938. renderList: Nullable<Array<AbstractMesh>>;
  83939. private _hookArray;
  83940. /**
  83941. * Define if particles should be rendered in your texture.
  83942. */
  83943. renderParticles: boolean;
  83944. /**
  83945. * Define if sprites should be rendered in your texture.
  83946. */
  83947. renderSprites: boolean;
  83948. /**
  83949. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  83950. */
  83951. coordinatesMode: number;
  83952. /**
  83953. * Define the camera used to render the texture.
  83954. */
  83955. activeCamera: Nullable<Camera>;
  83956. /**
  83957. * Override the render function of the texture with your own one.
  83958. */
  83959. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  83960. /**
  83961. * Define if camera post processes should be use while rendering the texture.
  83962. */
  83963. useCameraPostProcesses: boolean;
  83964. /**
  83965. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  83966. */
  83967. ignoreCameraViewport: boolean;
  83968. private _postProcessManager;
  83969. private _postProcesses;
  83970. private _resizeObserver;
  83971. /**
  83972. * An event triggered when the texture is unbind.
  83973. */
  83974. onBeforeBindObservable: Observable<RenderTargetTexture>;
  83975. /**
  83976. * An event triggered when the texture is unbind.
  83977. */
  83978. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  83979. private _onAfterUnbindObserver;
  83980. /**
  83981. * Set a after unbind callback in the texture.
  83982. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  83983. */
  83984. onAfterUnbind: () => void;
  83985. /**
  83986. * An event triggered before rendering the texture
  83987. */
  83988. onBeforeRenderObservable: Observable<number>;
  83989. private _onBeforeRenderObserver;
  83990. /**
  83991. * Set a before render callback in the texture.
  83992. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  83993. */
  83994. onBeforeRender: (faceIndex: number) => void;
  83995. /**
  83996. * An event triggered after rendering the texture
  83997. */
  83998. onAfterRenderObservable: Observable<number>;
  83999. private _onAfterRenderObserver;
  84000. /**
  84001. * Set a after render callback in the texture.
  84002. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84003. */
  84004. onAfterRender: (faceIndex: number) => void;
  84005. /**
  84006. * An event triggered after the texture clear
  84007. */
  84008. onClearObservable: Observable<Engine>;
  84009. private _onClearObserver;
  84010. /**
  84011. * Set a clear callback in the texture.
  84012. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84013. */
  84014. onClear: (Engine: Engine) => void;
  84015. /**
  84016. * An event triggered when the texture is resized.
  84017. */
  84018. onResizeObservable: Observable<RenderTargetTexture>;
  84019. /**
  84020. * Define the clear color of the Render Target if it should be different from the scene.
  84021. */
  84022. clearColor: Color4;
  84023. protected _size: number | {
  84024. width: number;
  84025. height: number;
  84026. };
  84027. protected _initialSizeParameter: number | {
  84028. width: number;
  84029. height: number;
  84030. } | {
  84031. ratio: number;
  84032. };
  84033. protected _sizeRatio: Nullable<number>;
  84034. /** @hidden */
  84035. _generateMipMaps: boolean;
  84036. protected _renderingManager: RenderingManager;
  84037. /** @hidden */
  84038. _waitingRenderList: string[];
  84039. protected _doNotChangeAspectRatio: boolean;
  84040. protected _currentRefreshId: number;
  84041. protected _refreshRate: number;
  84042. protected _textureMatrix: Matrix;
  84043. protected _samples: number;
  84044. protected _renderTargetOptions: RenderTargetCreationOptions;
  84045. /**
  84046. * Gets render target creation options that were used.
  84047. */
  84048. readonly renderTargetOptions: RenderTargetCreationOptions;
  84049. protected _engine: Engine;
  84050. protected _onRatioRescale(): void;
  84051. /**
  84052. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84053. * It must define where the camera used to render the texture is set
  84054. */
  84055. boundingBoxPosition: Vector3;
  84056. private _boundingBoxSize;
  84057. /**
  84058. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84059. * When defined, the cubemap will switch to local mode
  84060. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84061. * @example https://www.babylonjs-playground.com/#RNASML
  84062. */
  84063. boundingBoxSize: Vector3;
  84064. /**
  84065. * In case the RTT has been created with a depth texture, get the associated
  84066. * depth texture.
  84067. * Otherwise, return null.
  84068. */
  84069. depthStencilTexture: Nullable<InternalTexture>;
  84070. /**
  84071. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84072. * or used a shadow, depth texture...
  84073. * @param name The friendly name of the texture
  84074. * @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)
  84075. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84076. * @param generateMipMaps True if mip maps need to be generated after render.
  84077. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84078. * @param type The type of the buffer in the RTT (int, half float, float...)
  84079. * @param isCube True if a cube texture needs to be created
  84080. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84081. * @param generateDepthBuffer True to generate a depth buffer
  84082. * @param generateStencilBuffer True to generate a stencil buffer
  84083. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84084. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84085. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84086. */
  84087. constructor(name: string, size: number | {
  84088. width: number;
  84089. height: number;
  84090. } | {
  84091. ratio: number;
  84092. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84093. /**
  84094. * Creates a depth stencil texture.
  84095. * This is only available in WebGL 2 or with the depth texture extension available.
  84096. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84097. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84098. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84099. */
  84100. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84101. private _processSizeParameter;
  84102. /**
  84103. * Define the number of samples to use in case of MSAA.
  84104. * It defaults to one meaning no MSAA has been enabled.
  84105. */
  84106. samples: number;
  84107. /**
  84108. * Resets the refresh counter of the texture and start bak from scratch.
  84109. * Could be useful to regenerate the texture if it is setup to render only once.
  84110. */
  84111. resetRefreshCounter(): void;
  84112. /**
  84113. * Define the refresh rate of the texture or the rendering frequency.
  84114. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84115. */
  84116. refreshRate: number;
  84117. /**
  84118. * Adds a post process to the render target rendering passes.
  84119. * @param postProcess define the post process to add
  84120. */
  84121. addPostProcess(postProcess: PostProcess): void;
  84122. /**
  84123. * Clear all the post processes attached to the render target
  84124. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84125. */
  84126. clearPostProcesses(dispose?: boolean): void;
  84127. /**
  84128. * Remove one of the post process from the list of attached post processes to the texture
  84129. * @param postProcess define the post process to remove from the list
  84130. */
  84131. removePostProcess(postProcess: PostProcess): void;
  84132. /** @hidden */
  84133. _shouldRender(): boolean;
  84134. /**
  84135. * Gets the actual render size of the texture.
  84136. * @returns the width of the render size
  84137. */
  84138. getRenderSize(): number;
  84139. /**
  84140. * Gets the actual render width of the texture.
  84141. * @returns the width of the render size
  84142. */
  84143. getRenderWidth(): number;
  84144. /**
  84145. * Gets the actual render height of the texture.
  84146. * @returns the height of the render size
  84147. */
  84148. getRenderHeight(): number;
  84149. /**
  84150. * Get if the texture can be rescaled or not.
  84151. */
  84152. readonly canRescale: boolean;
  84153. /**
  84154. * Resize the texture using a ratio.
  84155. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84156. */
  84157. scale(ratio: number): void;
  84158. /**
  84159. * Get the texture reflection matrix used to rotate/transform the reflection.
  84160. * @returns the reflection matrix
  84161. */
  84162. getReflectionTextureMatrix(): Matrix;
  84163. /**
  84164. * Resize the texture to a new desired size.
  84165. * Be carrefull as it will recreate all the data in the new texture.
  84166. * @param size Define the new size. It can be:
  84167. * - a number for squared texture,
  84168. * - an object containing { width: number, height: number }
  84169. * - or an object containing a ratio { ratio: number }
  84170. */
  84171. resize(size: number | {
  84172. width: number;
  84173. height: number;
  84174. } | {
  84175. ratio: number;
  84176. }): void;
  84177. /**
  84178. * Renders all the objects from the render list into the texture.
  84179. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84180. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84181. */
  84182. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84183. private _bestReflectionRenderTargetDimension;
  84184. /**
  84185. * @hidden
  84186. * @param faceIndex face index to bind to if this is a cubetexture
  84187. */
  84188. _bindFrameBuffer(faceIndex?: number): void;
  84189. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84190. private renderToTarget;
  84191. /**
  84192. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84193. * This allowed control for front to back rendering or reversly depending of the special needs.
  84194. *
  84195. * @param renderingGroupId The rendering group id corresponding to its index
  84196. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84197. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84198. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84199. */
  84200. 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;
  84201. /**
  84202. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84203. *
  84204. * @param renderingGroupId The rendering group id corresponding to its index
  84205. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84206. */
  84207. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84208. /**
  84209. * Clones the texture.
  84210. * @returns the cloned texture
  84211. */
  84212. clone(): RenderTargetTexture;
  84213. /**
  84214. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84215. * @returns The JSON representation of the texture
  84216. */
  84217. serialize(): any;
  84218. /**
  84219. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84220. */
  84221. disposeFramebufferObjects(): void;
  84222. /**
  84223. * Dispose the texture and release its associated resources.
  84224. */
  84225. dispose(): void;
  84226. /** @hidden */
  84227. _rebuild(): void;
  84228. /**
  84229. * Clear the info related to rendering groups preventing retention point in material dispose.
  84230. */
  84231. freeRenderingGroups(): void;
  84232. /**
  84233. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84234. * @returns the view count
  84235. */
  84236. getViewCount(): number;
  84237. }
  84238. }
  84239. declare module BABYLON {
  84240. /**
  84241. * Base class for the main features of a material in Babylon.js
  84242. */
  84243. export class Material implements IAnimatable {
  84244. /**
  84245. * Returns the triangle fill mode
  84246. */
  84247. static readonly TriangleFillMode: number;
  84248. /**
  84249. * Returns the wireframe mode
  84250. */
  84251. static readonly WireFrameFillMode: number;
  84252. /**
  84253. * Returns the point fill mode
  84254. */
  84255. static readonly PointFillMode: number;
  84256. /**
  84257. * Returns the point list draw mode
  84258. */
  84259. static readonly PointListDrawMode: number;
  84260. /**
  84261. * Returns the line list draw mode
  84262. */
  84263. static readonly LineListDrawMode: number;
  84264. /**
  84265. * Returns the line loop draw mode
  84266. */
  84267. static readonly LineLoopDrawMode: number;
  84268. /**
  84269. * Returns the line strip draw mode
  84270. */
  84271. static readonly LineStripDrawMode: number;
  84272. /**
  84273. * Returns the triangle strip draw mode
  84274. */
  84275. static readonly TriangleStripDrawMode: number;
  84276. /**
  84277. * Returns the triangle fan draw mode
  84278. */
  84279. static readonly TriangleFanDrawMode: number;
  84280. /**
  84281. * Stores the clock-wise side orientation
  84282. */
  84283. static readonly ClockWiseSideOrientation: number;
  84284. /**
  84285. * Stores the counter clock-wise side orientation
  84286. */
  84287. static readonly CounterClockWiseSideOrientation: number;
  84288. /**
  84289. * The dirty texture flag value
  84290. */
  84291. static readonly TextureDirtyFlag: number;
  84292. /**
  84293. * The dirty light flag value
  84294. */
  84295. static readonly LightDirtyFlag: number;
  84296. /**
  84297. * The dirty fresnel flag value
  84298. */
  84299. static readonly FresnelDirtyFlag: number;
  84300. /**
  84301. * The dirty attribute flag value
  84302. */
  84303. static readonly AttributesDirtyFlag: number;
  84304. /**
  84305. * The dirty misc flag value
  84306. */
  84307. static readonly MiscDirtyFlag: number;
  84308. /**
  84309. * The all dirty flag value
  84310. */
  84311. static readonly AllDirtyFlag: number;
  84312. /**
  84313. * The ID of the material
  84314. */
  84315. id: string;
  84316. /**
  84317. * Gets or sets the unique id of the material
  84318. */
  84319. uniqueId: number;
  84320. /**
  84321. * The name of the material
  84322. */
  84323. name: string;
  84324. /**
  84325. * Gets or sets user defined metadata
  84326. */
  84327. metadata: any;
  84328. /**
  84329. * For internal use only. Please do not use.
  84330. */
  84331. reservedDataStore: any;
  84332. /**
  84333. * Specifies if the ready state should be checked on each call
  84334. */
  84335. checkReadyOnEveryCall: boolean;
  84336. /**
  84337. * Specifies if the ready state should be checked once
  84338. */
  84339. checkReadyOnlyOnce: boolean;
  84340. /**
  84341. * The state of the material
  84342. */
  84343. state: string;
  84344. /**
  84345. * The alpha value of the material
  84346. */
  84347. protected _alpha: number;
  84348. /**
  84349. * List of inspectable custom properties (used by the Inspector)
  84350. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84351. */
  84352. inspectableCustomProperties: IInspectable[];
  84353. /**
  84354. * Sets the alpha value of the material
  84355. */
  84356. /**
  84357. * Gets the alpha value of the material
  84358. */
  84359. alpha: number;
  84360. /**
  84361. * Specifies if back face culling is enabled
  84362. */
  84363. protected _backFaceCulling: boolean;
  84364. /**
  84365. * Sets the back-face culling state
  84366. */
  84367. /**
  84368. * Gets the back-face culling state
  84369. */
  84370. backFaceCulling: boolean;
  84371. /**
  84372. * Stores the value for side orientation
  84373. */
  84374. sideOrientation: number;
  84375. /**
  84376. * Callback triggered when the material is compiled
  84377. */
  84378. onCompiled: Nullable<(effect: Effect) => void>;
  84379. /**
  84380. * Callback triggered when an error occurs
  84381. */
  84382. onError: Nullable<(effect: Effect, errors: string) => void>;
  84383. /**
  84384. * Callback triggered to get the render target textures
  84385. */
  84386. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84387. /**
  84388. * Gets a boolean indicating that current material needs to register RTT
  84389. */
  84390. readonly hasRenderTargetTextures: boolean;
  84391. /**
  84392. * Specifies if the material should be serialized
  84393. */
  84394. doNotSerialize: boolean;
  84395. /**
  84396. * @hidden
  84397. */
  84398. _storeEffectOnSubMeshes: boolean;
  84399. /**
  84400. * Stores the animations for the material
  84401. */
  84402. animations: Nullable<Array<Animation>>;
  84403. /**
  84404. * An event triggered when the material is disposed
  84405. */
  84406. onDisposeObservable: Observable<Material>;
  84407. /**
  84408. * An observer which watches for dispose events
  84409. */
  84410. private _onDisposeObserver;
  84411. private _onUnBindObservable;
  84412. /**
  84413. * Called during a dispose event
  84414. */
  84415. onDispose: () => void;
  84416. private _onBindObservable;
  84417. /**
  84418. * An event triggered when the material is bound
  84419. */
  84420. readonly onBindObservable: Observable<AbstractMesh>;
  84421. /**
  84422. * An observer which watches for bind events
  84423. */
  84424. private _onBindObserver;
  84425. /**
  84426. * Called during a bind event
  84427. */
  84428. onBind: (Mesh: AbstractMesh) => void;
  84429. /**
  84430. * An event triggered when the material is unbound
  84431. */
  84432. readonly onUnBindObservable: Observable<Material>;
  84433. /**
  84434. * Stores the value of the alpha mode
  84435. */
  84436. private _alphaMode;
  84437. /**
  84438. * Sets the value of the alpha mode.
  84439. *
  84440. * | Value | Type | Description |
  84441. * | --- | --- | --- |
  84442. * | 0 | ALPHA_DISABLE | |
  84443. * | 1 | ALPHA_ADD | |
  84444. * | 2 | ALPHA_COMBINE | |
  84445. * | 3 | ALPHA_SUBTRACT | |
  84446. * | 4 | ALPHA_MULTIPLY | |
  84447. * | 5 | ALPHA_MAXIMIZED | |
  84448. * | 6 | ALPHA_ONEONE | |
  84449. * | 7 | ALPHA_PREMULTIPLIED | |
  84450. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84451. * | 9 | ALPHA_INTERPOLATE | |
  84452. * | 10 | ALPHA_SCREENMODE | |
  84453. *
  84454. */
  84455. /**
  84456. * Gets the value of the alpha mode
  84457. */
  84458. alphaMode: number;
  84459. /**
  84460. * Stores the state of the need depth pre-pass value
  84461. */
  84462. private _needDepthPrePass;
  84463. /**
  84464. * Sets the need depth pre-pass value
  84465. */
  84466. /**
  84467. * Gets the depth pre-pass value
  84468. */
  84469. needDepthPrePass: boolean;
  84470. /**
  84471. * Specifies if depth writing should be disabled
  84472. */
  84473. disableDepthWrite: boolean;
  84474. /**
  84475. * Specifies if depth writing should be forced
  84476. */
  84477. forceDepthWrite: boolean;
  84478. /**
  84479. * Specifies if there should be a separate pass for culling
  84480. */
  84481. separateCullingPass: boolean;
  84482. /**
  84483. * Stores the state specifing if fog should be enabled
  84484. */
  84485. private _fogEnabled;
  84486. /**
  84487. * Sets the state for enabling fog
  84488. */
  84489. /**
  84490. * Gets the value of the fog enabled state
  84491. */
  84492. fogEnabled: boolean;
  84493. /**
  84494. * Stores the size of points
  84495. */
  84496. pointSize: number;
  84497. /**
  84498. * Stores the z offset value
  84499. */
  84500. zOffset: number;
  84501. /**
  84502. * Gets a value specifying if wireframe mode is enabled
  84503. */
  84504. /**
  84505. * Sets the state of wireframe mode
  84506. */
  84507. wireframe: boolean;
  84508. /**
  84509. * Gets the value specifying if point clouds are enabled
  84510. */
  84511. /**
  84512. * Sets the state of point cloud mode
  84513. */
  84514. pointsCloud: boolean;
  84515. /**
  84516. * Gets the material fill mode
  84517. */
  84518. /**
  84519. * Sets the material fill mode
  84520. */
  84521. fillMode: number;
  84522. /**
  84523. * @hidden
  84524. * Stores the effects for the material
  84525. */
  84526. _effect: Nullable<Effect>;
  84527. /**
  84528. * @hidden
  84529. * Specifies if the material was previously ready
  84530. */
  84531. _wasPreviouslyReady: boolean;
  84532. /**
  84533. * Specifies if uniform buffers should be used
  84534. */
  84535. private _useUBO;
  84536. /**
  84537. * Stores a reference to the scene
  84538. */
  84539. private _scene;
  84540. /**
  84541. * Stores the fill mode state
  84542. */
  84543. private _fillMode;
  84544. /**
  84545. * Specifies if the depth write state should be cached
  84546. */
  84547. private _cachedDepthWriteState;
  84548. /**
  84549. * Stores the uniform buffer
  84550. */
  84551. protected _uniformBuffer: UniformBuffer;
  84552. /** @hidden */
  84553. _indexInSceneMaterialArray: number;
  84554. /** @hidden */
  84555. meshMap: Nullable<{
  84556. [id: string]: AbstractMesh | undefined;
  84557. }>;
  84558. /**
  84559. * Creates a material instance
  84560. * @param name defines the name of the material
  84561. * @param scene defines the scene to reference
  84562. * @param doNotAdd specifies if the material should be added to the scene
  84563. */
  84564. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84565. /**
  84566. * Returns a string representation of the current material
  84567. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84568. * @returns a string with material information
  84569. */
  84570. toString(fullDetails?: boolean): string;
  84571. /**
  84572. * Gets the class name of the material
  84573. * @returns a string with the class name of the material
  84574. */
  84575. getClassName(): string;
  84576. /**
  84577. * Specifies if updates for the material been locked
  84578. */
  84579. readonly isFrozen: boolean;
  84580. /**
  84581. * Locks updates for the material
  84582. */
  84583. freeze(): void;
  84584. /**
  84585. * Unlocks updates for the material
  84586. */
  84587. unfreeze(): void;
  84588. /**
  84589. * Specifies if the material is ready to be used
  84590. * @param mesh defines the mesh to check
  84591. * @param useInstances specifies if instances should be used
  84592. * @returns a boolean indicating if the material is ready to be used
  84593. */
  84594. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84595. /**
  84596. * Specifies that the submesh is ready to be used
  84597. * @param mesh defines the mesh to check
  84598. * @param subMesh defines which submesh to check
  84599. * @param useInstances specifies that instances should be used
  84600. * @returns a boolean indicating that the submesh is ready or not
  84601. */
  84602. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84603. /**
  84604. * Returns the material effect
  84605. * @returns the effect associated with the material
  84606. */
  84607. getEffect(): Nullable<Effect>;
  84608. /**
  84609. * Returns the current scene
  84610. * @returns a Scene
  84611. */
  84612. getScene(): Scene;
  84613. /**
  84614. * Specifies if the material will require alpha blending
  84615. * @returns a boolean specifying if alpha blending is needed
  84616. */
  84617. needAlphaBlending(): boolean;
  84618. /**
  84619. * Specifies if the mesh will require alpha blending
  84620. * @param mesh defines the mesh to check
  84621. * @returns a boolean specifying if alpha blending is needed for the mesh
  84622. */
  84623. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84624. /**
  84625. * Specifies if this material should be rendered in alpha test mode
  84626. * @returns a boolean specifying if an alpha test is needed.
  84627. */
  84628. needAlphaTesting(): boolean;
  84629. /**
  84630. * Gets the texture used for the alpha test
  84631. * @returns the texture to use for alpha testing
  84632. */
  84633. getAlphaTestTexture(): Nullable<BaseTexture>;
  84634. /**
  84635. * Marks the material to indicate that it needs to be re-calculated
  84636. */
  84637. markDirty(): void;
  84638. /** @hidden */
  84639. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84640. /**
  84641. * Binds the material to the mesh
  84642. * @param world defines the world transformation matrix
  84643. * @param mesh defines the mesh to bind the material to
  84644. */
  84645. bind(world: Matrix, mesh?: Mesh): void;
  84646. /**
  84647. * Binds the submesh to the material
  84648. * @param world defines the world transformation matrix
  84649. * @param mesh defines the mesh containing the submesh
  84650. * @param subMesh defines the submesh to bind the material to
  84651. */
  84652. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84653. /**
  84654. * Binds the world matrix to the material
  84655. * @param world defines the world transformation matrix
  84656. */
  84657. bindOnlyWorldMatrix(world: Matrix): void;
  84658. /**
  84659. * Binds the scene's uniform buffer to the effect.
  84660. * @param effect defines the effect to bind to the scene uniform buffer
  84661. * @param sceneUbo defines the uniform buffer storing scene data
  84662. */
  84663. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84664. /**
  84665. * Binds the view matrix to the effect
  84666. * @param effect defines the effect to bind the view matrix to
  84667. */
  84668. bindView(effect: Effect): void;
  84669. /**
  84670. * Binds the view projection matrix to the effect
  84671. * @param effect defines the effect to bind the view projection matrix to
  84672. */
  84673. bindViewProjection(effect: Effect): void;
  84674. /**
  84675. * Specifies if material alpha testing should be turned on for the mesh
  84676. * @param mesh defines the mesh to check
  84677. */
  84678. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84679. /**
  84680. * Processes to execute after binding the material to a mesh
  84681. * @param mesh defines the rendered mesh
  84682. */
  84683. protected _afterBind(mesh?: Mesh): void;
  84684. /**
  84685. * Unbinds the material from the mesh
  84686. */
  84687. unbind(): void;
  84688. /**
  84689. * Gets the active textures from the material
  84690. * @returns an array of textures
  84691. */
  84692. getActiveTextures(): BaseTexture[];
  84693. /**
  84694. * Specifies if the material uses a texture
  84695. * @param texture defines the texture to check against the material
  84696. * @returns a boolean specifying if the material uses the texture
  84697. */
  84698. hasTexture(texture: BaseTexture): boolean;
  84699. /**
  84700. * Makes a duplicate of the material, and gives it a new name
  84701. * @param name defines the new name for the duplicated material
  84702. * @returns the cloned material
  84703. */
  84704. clone(name: string): Nullable<Material>;
  84705. /**
  84706. * Gets the meshes bound to the material
  84707. * @returns an array of meshes bound to the material
  84708. */
  84709. getBindedMeshes(): AbstractMesh[];
  84710. /**
  84711. * Force shader compilation
  84712. * @param mesh defines the mesh associated with this material
  84713. * @param onCompiled defines a function to execute once the material is compiled
  84714. * @param options defines the options to configure the compilation
  84715. */
  84716. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84717. clipPlane: boolean;
  84718. }>): void;
  84719. /**
  84720. * Force shader compilation
  84721. * @param mesh defines the mesh that will use this material
  84722. * @param options defines additional options for compiling the shaders
  84723. * @returns a promise that resolves when the compilation completes
  84724. */
  84725. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84726. clipPlane: boolean;
  84727. }>): Promise<void>;
  84728. private static readonly _AllDirtyCallBack;
  84729. private static readonly _ImageProcessingDirtyCallBack;
  84730. private static readonly _TextureDirtyCallBack;
  84731. private static readonly _FresnelDirtyCallBack;
  84732. private static readonly _MiscDirtyCallBack;
  84733. private static readonly _LightsDirtyCallBack;
  84734. private static readonly _AttributeDirtyCallBack;
  84735. private static _FresnelAndMiscDirtyCallBack;
  84736. private static _TextureAndMiscDirtyCallBack;
  84737. private static readonly _DirtyCallbackArray;
  84738. private static readonly _RunDirtyCallBacks;
  84739. /**
  84740. * Marks a define in the material to indicate that it needs to be re-computed
  84741. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84742. */
  84743. markAsDirty(flag: number): void;
  84744. /**
  84745. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84746. * @param func defines a function which checks material defines against the submeshes
  84747. */
  84748. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84749. /**
  84750. * Indicates that we need to re-calculated for all submeshes
  84751. */
  84752. protected _markAllSubMeshesAsAllDirty(): void;
  84753. /**
  84754. * Indicates that image processing needs to be re-calculated for all submeshes
  84755. */
  84756. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84757. /**
  84758. * Indicates that textures need to be re-calculated for all submeshes
  84759. */
  84760. protected _markAllSubMeshesAsTexturesDirty(): void;
  84761. /**
  84762. * Indicates that fresnel needs to be re-calculated for all submeshes
  84763. */
  84764. protected _markAllSubMeshesAsFresnelDirty(): void;
  84765. /**
  84766. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84767. */
  84768. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84769. /**
  84770. * Indicates that lights need to be re-calculated for all submeshes
  84771. */
  84772. protected _markAllSubMeshesAsLightsDirty(): void;
  84773. /**
  84774. * Indicates that attributes need to be re-calculated for all submeshes
  84775. */
  84776. protected _markAllSubMeshesAsAttributesDirty(): void;
  84777. /**
  84778. * Indicates that misc needs to be re-calculated for all submeshes
  84779. */
  84780. protected _markAllSubMeshesAsMiscDirty(): void;
  84781. /**
  84782. * Indicates that textures and misc need to be re-calculated for all submeshes
  84783. */
  84784. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84785. /**
  84786. * Disposes the material
  84787. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84788. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84789. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84790. */
  84791. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84792. /** @hidden */
  84793. private releaseVertexArrayObject;
  84794. /**
  84795. * Serializes this material
  84796. * @returns the serialized material object
  84797. */
  84798. serialize(): any;
  84799. /**
  84800. * Creates a material from parsed material data
  84801. * @param parsedMaterial defines parsed material data
  84802. * @param scene defines the hosting scene
  84803. * @param rootUrl defines the root URL to use to load textures
  84804. * @returns a new material
  84805. */
  84806. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84807. }
  84808. }
  84809. declare module BABYLON {
  84810. /**
  84811. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84812. * separate meshes. This can be use to improve performances.
  84813. * @see http://doc.babylonjs.com/how_to/multi_materials
  84814. */
  84815. export class MultiMaterial extends Material {
  84816. private _subMaterials;
  84817. /**
  84818. * Gets or Sets the list of Materials used within the multi material.
  84819. * They need to be ordered according to the submeshes order in the associated mesh
  84820. */
  84821. subMaterials: Nullable<Material>[];
  84822. /**
  84823. * Function used to align with Node.getChildren()
  84824. * @returns the list of Materials used within the multi material
  84825. */
  84826. getChildren(): Nullable<Material>[];
  84827. /**
  84828. * Instantiates a new Multi Material
  84829. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84830. * separate meshes. This can be use to improve performances.
  84831. * @see http://doc.babylonjs.com/how_to/multi_materials
  84832. * @param name Define the name in the scene
  84833. * @param scene Define the scene the material belongs to
  84834. */
  84835. constructor(name: string, scene: Scene);
  84836. private _hookArray;
  84837. /**
  84838. * Get one of the submaterial by its index in the submaterials array
  84839. * @param index The index to look the sub material at
  84840. * @returns The Material if the index has been defined
  84841. */
  84842. getSubMaterial(index: number): Nullable<Material>;
  84843. /**
  84844. * Get the list of active textures for the whole sub materials list.
  84845. * @returns All the textures that will be used during the rendering
  84846. */
  84847. getActiveTextures(): BaseTexture[];
  84848. /**
  84849. * Gets the current class name of the material e.g. "MultiMaterial"
  84850. * Mainly use in serialization.
  84851. * @returns the class name
  84852. */
  84853. getClassName(): string;
  84854. /**
  84855. * Checks if the material is ready to render the requested sub mesh
  84856. * @param mesh Define the mesh the submesh belongs to
  84857. * @param subMesh Define the sub mesh to look readyness for
  84858. * @param useInstances Define whether or not the material is used with instances
  84859. * @returns true if ready, otherwise false
  84860. */
  84861. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84862. /**
  84863. * Clones the current material and its related sub materials
  84864. * @param name Define the name of the newly cloned material
  84865. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  84866. * @returns the cloned material
  84867. */
  84868. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  84869. /**
  84870. * Serializes the materials into a JSON representation.
  84871. * @returns the JSON representation
  84872. */
  84873. serialize(): any;
  84874. /**
  84875. * Dispose the material and release its associated resources
  84876. * @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)
  84877. * @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)
  84878. * @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)
  84879. */
  84880. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  84881. /**
  84882. * Creates a MultiMaterial from parsed MultiMaterial data.
  84883. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  84884. * @param scene defines the hosting scene
  84885. * @returns a new MultiMaterial
  84886. */
  84887. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  84888. }
  84889. }
  84890. declare module BABYLON {
  84891. /**
  84892. * Base class for submeshes
  84893. */
  84894. export class BaseSubMesh {
  84895. /** @hidden */
  84896. _materialDefines: Nullable<MaterialDefines>;
  84897. /** @hidden */
  84898. _materialEffect: Nullable<Effect>;
  84899. /**
  84900. * Gets associated effect
  84901. */
  84902. readonly effect: Nullable<Effect>;
  84903. /**
  84904. * Sets associated effect (effect used to render this submesh)
  84905. * @param effect defines the effect to associate with
  84906. * @param defines defines the set of defines used to compile this effect
  84907. */
  84908. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84909. }
  84910. /**
  84911. * Defines a subdivision inside a mesh
  84912. */
  84913. export class SubMesh extends BaseSubMesh implements ICullable {
  84914. /** the material index to use */
  84915. materialIndex: number;
  84916. /** vertex index start */
  84917. verticesStart: number;
  84918. /** vertices count */
  84919. verticesCount: number;
  84920. /** index start */
  84921. indexStart: number;
  84922. /** indices count */
  84923. indexCount: number;
  84924. /** @hidden */
  84925. _linesIndexCount: number;
  84926. private _mesh;
  84927. private _renderingMesh;
  84928. private _boundingInfo;
  84929. private _linesIndexBuffer;
  84930. /** @hidden */
  84931. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84932. /** @hidden */
  84933. _trianglePlanes: Plane[];
  84934. /** @hidden */
  84935. _lastColliderTransformMatrix: Nullable<Matrix>;
  84936. /** @hidden */
  84937. _renderId: number;
  84938. /** @hidden */
  84939. _alphaIndex: number;
  84940. /** @hidden */
  84941. _distanceToCamera: number;
  84942. /** @hidden */
  84943. _id: number;
  84944. private _currentMaterial;
  84945. /**
  84946. * Add a new submesh to a mesh
  84947. * @param materialIndex defines the material index to use
  84948. * @param verticesStart defines vertex index start
  84949. * @param verticesCount defines vertices count
  84950. * @param indexStart defines index start
  84951. * @param indexCount defines indices count
  84952. * @param mesh defines the parent mesh
  84953. * @param renderingMesh defines an optional rendering mesh
  84954. * @param createBoundingBox defines if bounding box should be created for this submesh
  84955. * @returns the new submesh
  84956. */
  84957. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84958. /**
  84959. * Creates a new submesh
  84960. * @param materialIndex defines the material index to use
  84961. * @param verticesStart defines vertex index start
  84962. * @param verticesCount defines vertices count
  84963. * @param indexStart defines index start
  84964. * @param indexCount defines indices count
  84965. * @param mesh defines the parent mesh
  84966. * @param renderingMesh defines an optional rendering mesh
  84967. * @param createBoundingBox defines if bounding box should be created for this submesh
  84968. */
  84969. constructor(
  84970. /** the material index to use */
  84971. materialIndex: number,
  84972. /** vertex index start */
  84973. verticesStart: number,
  84974. /** vertices count */
  84975. verticesCount: number,
  84976. /** index start */
  84977. indexStart: number,
  84978. /** indices count */
  84979. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84980. /**
  84981. * Returns true if this submesh covers the entire parent mesh
  84982. * @ignorenaming
  84983. */
  84984. readonly IsGlobal: boolean;
  84985. /**
  84986. * Returns the submesh BoudingInfo object
  84987. * @returns current bounding info (or mesh's one if the submesh is global)
  84988. */
  84989. getBoundingInfo(): BoundingInfo;
  84990. /**
  84991. * Sets the submesh BoundingInfo
  84992. * @param boundingInfo defines the new bounding info to use
  84993. * @returns the SubMesh
  84994. */
  84995. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84996. /**
  84997. * Returns the mesh of the current submesh
  84998. * @return the parent mesh
  84999. */
  85000. getMesh(): AbstractMesh;
  85001. /**
  85002. * Returns the rendering mesh of the submesh
  85003. * @returns the rendering mesh (could be different from parent mesh)
  85004. */
  85005. getRenderingMesh(): Mesh;
  85006. /**
  85007. * Returns the submesh material
  85008. * @returns null or the current material
  85009. */
  85010. getMaterial(): Nullable<Material>;
  85011. /**
  85012. * Sets a new updated BoundingInfo object to the submesh
  85013. * @param data defines an optional position array to use to determine the bounding info
  85014. * @returns the SubMesh
  85015. */
  85016. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85017. /** @hidden */
  85018. _checkCollision(collider: Collider): boolean;
  85019. /**
  85020. * Updates the submesh BoundingInfo
  85021. * @param world defines the world matrix to use to update the bounding info
  85022. * @returns the submesh
  85023. */
  85024. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85025. /**
  85026. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85027. * @param frustumPlanes defines the frustum planes
  85028. * @returns true if the submesh is intersecting with the frustum
  85029. */
  85030. isInFrustum(frustumPlanes: Plane[]): boolean;
  85031. /**
  85032. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85033. * @param frustumPlanes defines the frustum planes
  85034. * @returns true if the submesh is inside the frustum
  85035. */
  85036. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85037. /**
  85038. * Renders the submesh
  85039. * @param enableAlphaMode defines if alpha needs to be used
  85040. * @returns the submesh
  85041. */
  85042. render(enableAlphaMode: boolean): SubMesh;
  85043. /**
  85044. * @hidden
  85045. */
  85046. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85047. /**
  85048. * Checks if the submesh intersects with a ray
  85049. * @param ray defines the ray to test
  85050. * @returns true is the passed ray intersects the submesh bounding box
  85051. */
  85052. canIntersects(ray: Ray): boolean;
  85053. /**
  85054. * Intersects current submesh with a ray
  85055. * @param ray defines the ray to test
  85056. * @param positions defines mesh's positions array
  85057. * @param indices defines mesh's indices array
  85058. * @param fastCheck defines if only bounding info should be used
  85059. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85060. * @returns intersection info or null if no intersection
  85061. */
  85062. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85063. /** @hidden */
  85064. private _intersectLines;
  85065. /** @hidden */
  85066. private _intersectUnIndexedLines;
  85067. /** @hidden */
  85068. private _intersectTriangles;
  85069. /** @hidden */
  85070. private _intersectUnIndexedTriangles;
  85071. /** @hidden */
  85072. _rebuild(): void;
  85073. /**
  85074. * Creates a new submesh from the passed mesh
  85075. * @param newMesh defines the new hosting mesh
  85076. * @param newRenderingMesh defines an optional rendering mesh
  85077. * @returns the new submesh
  85078. */
  85079. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85080. /**
  85081. * Release associated resources
  85082. */
  85083. dispose(): void;
  85084. /**
  85085. * Gets the class name
  85086. * @returns the string "SubMesh".
  85087. */
  85088. getClassName(): string;
  85089. /**
  85090. * Creates a new submesh from indices data
  85091. * @param materialIndex the index of the main mesh material
  85092. * @param startIndex the index where to start the copy in the mesh indices array
  85093. * @param indexCount the number of indices to copy then from the startIndex
  85094. * @param mesh the main mesh to create the submesh from
  85095. * @param renderingMesh the optional rendering mesh
  85096. * @returns a new submesh
  85097. */
  85098. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85099. }
  85100. }
  85101. declare module BABYLON {
  85102. /**
  85103. * Class used to represent data loading progression
  85104. */
  85105. export class SceneLoaderFlags {
  85106. private static _ForceFullSceneLoadingForIncremental;
  85107. private static _ShowLoadingScreen;
  85108. private static _CleanBoneMatrixWeights;
  85109. private static _loggingLevel;
  85110. /**
  85111. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  85112. */
  85113. static ForceFullSceneLoadingForIncremental: boolean;
  85114. /**
  85115. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  85116. */
  85117. static ShowLoadingScreen: boolean;
  85118. /**
  85119. * Defines the current logging level (while loading the scene)
  85120. * @ignorenaming
  85121. */
  85122. static loggingLevel: number;
  85123. /**
  85124. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  85125. */
  85126. static CleanBoneMatrixWeights: boolean;
  85127. }
  85128. }
  85129. declare module BABYLON {
  85130. /**
  85131. * Class used to store geometry data (vertex buffers + index buffer)
  85132. */
  85133. export class Geometry implements IGetSetVerticesData {
  85134. /**
  85135. * Gets or sets the ID of the geometry
  85136. */
  85137. id: string;
  85138. /**
  85139. * Gets or sets the unique ID of the geometry
  85140. */
  85141. uniqueId: number;
  85142. /**
  85143. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85144. */
  85145. delayLoadState: number;
  85146. /**
  85147. * Gets the file containing the data to load when running in delay load state
  85148. */
  85149. delayLoadingFile: Nullable<string>;
  85150. /**
  85151. * Callback called when the geometry is updated
  85152. */
  85153. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85154. private _scene;
  85155. private _engine;
  85156. private _meshes;
  85157. private _totalVertices;
  85158. /** @hidden */
  85159. _indices: IndicesArray;
  85160. /** @hidden */
  85161. _vertexBuffers: {
  85162. [key: string]: VertexBuffer;
  85163. };
  85164. private _isDisposed;
  85165. private _extend;
  85166. private _boundingBias;
  85167. /** @hidden */
  85168. _delayInfo: Array<string>;
  85169. private _indexBuffer;
  85170. private _indexBufferIsUpdatable;
  85171. /** @hidden */
  85172. _boundingInfo: Nullable<BoundingInfo>;
  85173. /** @hidden */
  85174. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85175. /** @hidden */
  85176. _softwareSkinningFrameId: number;
  85177. private _vertexArrayObjects;
  85178. private _updatable;
  85179. /** @hidden */
  85180. _positions: Nullable<Vector3[]>;
  85181. /**
  85182. * 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
  85183. */
  85184. /**
  85185. * 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
  85186. */
  85187. boundingBias: Vector2;
  85188. /**
  85189. * Static function used to attach a new empty geometry to a mesh
  85190. * @param mesh defines the mesh to attach the geometry to
  85191. * @returns the new Geometry
  85192. */
  85193. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85194. /**
  85195. * Creates a new geometry
  85196. * @param id defines the unique ID
  85197. * @param scene defines the hosting scene
  85198. * @param vertexData defines the VertexData used to get geometry data
  85199. * @param updatable defines if geometry must be updatable (false by default)
  85200. * @param mesh defines the mesh that will be associated with the geometry
  85201. */
  85202. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85203. /**
  85204. * Gets the current extend of the geometry
  85205. */
  85206. readonly extend: {
  85207. minimum: Vector3;
  85208. maximum: Vector3;
  85209. };
  85210. /**
  85211. * Gets the hosting scene
  85212. * @returns the hosting Scene
  85213. */
  85214. getScene(): Scene;
  85215. /**
  85216. * Gets the hosting engine
  85217. * @returns the hosting Engine
  85218. */
  85219. getEngine(): Engine;
  85220. /**
  85221. * Defines if the geometry is ready to use
  85222. * @returns true if the geometry is ready to be used
  85223. */
  85224. isReady(): boolean;
  85225. /**
  85226. * Gets a value indicating that the geometry should not be serialized
  85227. */
  85228. readonly doNotSerialize: boolean;
  85229. /** @hidden */
  85230. _rebuild(): void;
  85231. /**
  85232. * Affects all geometry data in one call
  85233. * @param vertexData defines the geometry data
  85234. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85235. */
  85236. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85237. /**
  85238. * Set specific vertex data
  85239. * @param kind defines the data kind (Position, normal, etc...)
  85240. * @param data defines the vertex data to use
  85241. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85242. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85243. */
  85244. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85245. /**
  85246. * Removes a specific vertex data
  85247. * @param kind defines the data kind (Position, normal, etc...)
  85248. */
  85249. removeVerticesData(kind: string): void;
  85250. /**
  85251. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85252. * @param buffer defines the vertex buffer to use
  85253. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85254. */
  85255. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85256. /**
  85257. * Update a specific vertex buffer
  85258. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85259. * It will do nothing if the buffer is not updatable
  85260. * @param kind defines the data kind (Position, normal, etc...)
  85261. * @param data defines the data to use
  85262. * @param offset defines the offset in the target buffer where to store the data
  85263. * @param useBytes set to true if the offset is in bytes
  85264. */
  85265. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85266. /**
  85267. * Update a specific vertex buffer
  85268. * This function will create a new buffer if the current one is not updatable
  85269. * @param kind defines the data kind (Position, normal, etc...)
  85270. * @param data defines the data to use
  85271. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85272. */
  85273. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85274. private _updateBoundingInfo;
  85275. /** @hidden */
  85276. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85277. /**
  85278. * Gets total number of vertices
  85279. * @returns the total number of vertices
  85280. */
  85281. getTotalVertices(): number;
  85282. /**
  85283. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85284. * @param kind defines the data kind (Position, normal, etc...)
  85285. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85286. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85287. * @returns a float array containing vertex data
  85288. */
  85289. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85290. /**
  85291. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85292. * @param kind defines the data kind (Position, normal, etc...)
  85293. * @returns true if the vertex buffer with the specified kind is updatable
  85294. */
  85295. isVertexBufferUpdatable(kind: string): boolean;
  85296. /**
  85297. * Gets a specific vertex buffer
  85298. * @param kind defines the data kind (Position, normal, etc...)
  85299. * @returns a VertexBuffer
  85300. */
  85301. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85302. /**
  85303. * Returns all vertex buffers
  85304. * @return an object holding all vertex buffers indexed by kind
  85305. */
  85306. getVertexBuffers(): Nullable<{
  85307. [key: string]: VertexBuffer;
  85308. }>;
  85309. /**
  85310. * Gets a boolean indicating if specific vertex buffer is present
  85311. * @param kind defines the data kind (Position, normal, etc...)
  85312. * @returns true if data is present
  85313. */
  85314. isVerticesDataPresent(kind: string): boolean;
  85315. /**
  85316. * Gets a list of all attached data kinds (Position, normal, etc...)
  85317. * @returns a list of string containing all kinds
  85318. */
  85319. getVerticesDataKinds(): string[];
  85320. /**
  85321. * Update index buffer
  85322. * @param indices defines the indices to store in the index buffer
  85323. * @param offset defines the offset in the target buffer where to store the data
  85324. * @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)
  85325. */
  85326. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85327. /**
  85328. * Creates a new index buffer
  85329. * @param indices defines the indices to store in the index buffer
  85330. * @param totalVertices defines the total number of vertices (could be null)
  85331. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85332. */
  85333. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85334. /**
  85335. * Return the total number of indices
  85336. * @returns the total number of indices
  85337. */
  85338. getTotalIndices(): number;
  85339. /**
  85340. * Gets the index buffer array
  85341. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85342. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85343. * @returns the index buffer array
  85344. */
  85345. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85346. /**
  85347. * Gets the index buffer
  85348. * @return the index buffer
  85349. */
  85350. getIndexBuffer(): Nullable<DataBuffer>;
  85351. /** @hidden */
  85352. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85353. /**
  85354. * Release the associated resources for a specific mesh
  85355. * @param mesh defines the source mesh
  85356. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85357. */
  85358. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85359. /**
  85360. * Apply current geometry to a given mesh
  85361. * @param mesh defines the mesh to apply geometry to
  85362. */
  85363. applyToMesh(mesh: Mesh): void;
  85364. private _updateExtend;
  85365. private _applyToMesh;
  85366. private notifyUpdate;
  85367. /**
  85368. * Load the geometry if it was flagged as delay loaded
  85369. * @param scene defines the hosting scene
  85370. * @param onLoaded defines a callback called when the geometry is loaded
  85371. */
  85372. load(scene: Scene, onLoaded?: () => void): void;
  85373. private _queueLoad;
  85374. /**
  85375. * Invert the geometry to move from a right handed system to a left handed one.
  85376. */
  85377. toLeftHanded(): void;
  85378. /** @hidden */
  85379. _resetPointsArrayCache(): void;
  85380. /** @hidden */
  85381. _generatePointsArray(): boolean;
  85382. /**
  85383. * Gets a value indicating if the geometry is disposed
  85384. * @returns true if the geometry was disposed
  85385. */
  85386. isDisposed(): boolean;
  85387. private _disposeVertexArrayObjects;
  85388. /**
  85389. * Free all associated resources
  85390. */
  85391. dispose(): void;
  85392. /**
  85393. * Clone the current geometry into a new geometry
  85394. * @param id defines the unique ID of the new geometry
  85395. * @returns a new geometry object
  85396. */
  85397. copy(id: string): Geometry;
  85398. /**
  85399. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85400. * @return a JSON representation of the current geometry data (without the vertices data)
  85401. */
  85402. serialize(): any;
  85403. private toNumberArray;
  85404. /**
  85405. * Serialize all vertices data into a JSON oject
  85406. * @returns a JSON representation of the current geometry data
  85407. */
  85408. serializeVerticeData(): any;
  85409. /**
  85410. * Extracts a clone of a mesh geometry
  85411. * @param mesh defines the source mesh
  85412. * @param id defines the unique ID of the new geometry object
  85413. * @returns the new geometry object
  85414. */
  85415. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85416. /**
  85417. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85418. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85419. * Be aware Math.random() could cause collisions, but:
  85420. * "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"
  85421. * @returns a string containing a new GUID
  85422. */
  85423. static RandomId(): string;
  85424. /** @hidden */
  85425. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85426. private static _CleanMatricesWeights;
  85427. /**
  85428. * Create a new geometry from persisted data (Using .babylon file format)
  85429. * @param parsedVertexData defines the persisted data
  85430. * @param scene defines the hosting scene
  85431. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85432. * @returns the new geometry object
  85433. */
  85434. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85435. }
  85436. }
  85437. declare module BABYLON {
  85438. /**
  85439. * Define an interface for all classes that will get and set the data on vertices
  85440. */
  85441. export interface IGetSetVerticesData {
  85442. /**
  85443. * Gets a boolean indicating if specific vertex data is present
  85444. * @param kind defines the vertex data kind to use
  85445. * @returns true is data kind is present
  85446. */
  85447. isVerticesDataPresent(kind: string): boolean;
  85448. /**
  85449. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85450. * @param kind defines the data kind (Position, normal, etc...)
  85451. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85452. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85453. * @returns a float array containing vertex data
  85454. */
  85455. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85456. /**
  85457. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85458. * @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.
  85459. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85460. * @returns the indices array or an empty array if the mesh has no geometry
  85461. */
  85462. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85463. /**
  85464. * Set specific vertex data
  85465. * @param kind defines the data kind (Position, normal, etc...)
  85466. * @param data defines the vertex data to use
  85467. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85468. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85469. */
  85470. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85471. /**
  85472. * Update a specific associated vertex buffer
  85473. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85474. * - VertexBuffer.PositionKind
  85475. * - VertexBuffer.UVKind
  85476. * - VertexBuffer.UV2Kind
  85477. * - VertexBuffer.UV3Kind
  85478. * - VertexBuffer.UV4Kind
  85479. * - VertexBuffer.UV5Kind
  85480. * - VertexBuffer.UV6Kind
  85481. * - VertexBuffer.ColorKind
  85482. * - VertexBuffer.MatricesIndicesKind
  85483. * - VertexBuffer.MatricesIndicesExtraKind
  85484. * - VertexBuffer.MatricesWeightsKind
  85485. * - VertexBuffer.MatricesWeightsExtraKind
  85486. * @param data defines the data source
  85487. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85488. * @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)
  85489. */
  85490. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85491. /**
  85492. * Creates a new index buffer
  85493. * @param indices defines the indices to store in the index buffer
  85494. * @param totalVertices defines the total number of vertices (could be null)
  85495. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85496. */
  85497. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85498. }
  85499. /**
  85500. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85501. */
  85502. export class VertexData {
  85503. /**
  85504. * Mesh side orientation : usually the external or front surface
  85505. */
  85506. static readonly FRONTSIDE: number;
  85507. /**
  85508. * Mesh side orientation : usually the internal or back surface
  85509. */
  85510. static readonly BACKSIDE: number;
  85511. /**
  85512. * Mesh side orientation : both internal and external or front and back surfaces
  85513. */
  85514. static readonly DOUBLESIDE: number;
  85515. /**
  85516. * Mesh side orientation : by default, `FRONTSIDE`
  85517. */
  85518. static readonly DEFAULTSIDE: number;
  85519. /**
  85520. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85521. */
  85522. positions: Nullable<FloatArray>;
  85523. /**
  85524. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85525. */
  85526. normals: Nullable<FloatArray>;
  85527. /**
  85528. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85529. */
  85530. tangents: Nullable<FloatArray>;
  85531. /**
  85532. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85533. */
  85534. uvs: Nullable<FloatArray>;
  85535. /**
  85536. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85537. */
  85538. uvs2: Nullable<FloatArray>;
  85539. /**
  85540. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85541. */
  85542. uvs3: Nullable<FloatArray>;
  85543. /**
  85544. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85545. */
  85546. uvs4: Nullable<FloatArray>;
  85547. /**
  85548. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85549. */
  85550. uvs5: Nullable<FloatArray>;
  85551. /**
  85552. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85553. */
  85554. uvs6: Nullable<FloatArray>;
  85555. /**
  85556. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85557. */
  85558. colors: Nullable<FloatArray>;
  85559. /**
  85560. * 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).
  85561. */
  85562. matricesIndices: Nullable<FloatArray>;
  85563. /**
  85564. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85565. */
  85566. matricesWeights: Nullable<FloatArray>;
  85567. /**
  85568. * An array extending the number of possible indices
  85569. */
  85570. matricesIndicesExtra: Nullable<FloatArray>;
  85571. /**
  85572. * An array extending the number of possible weights when the number of indices is extended
  85573. */
  85574. matricesWeightsExtra: Nullable<FloatArray>;
  85575. /**
  85576. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85577. */
  85578. indices: Nullable<IndicesArray>;
  85579. /**
  85580. * Uses the passed data array to set the set the values for the specified kind of data
  85581. * @param data a linear array of floating numbers
  85582. * @param kind the type of data that is being set, eg positions, colors etc
  85583. */
  85584. set(data: FloatArray, kind: string): void;
  85585. /**
  85586. * Associates the vertexData to the passed Mesh.
  85587. * Sets it as updatable or not (default `false`)
  85588. * @param mesh the mesh the vertexData is applied to
  85589. * @param updatable when used and having the value true allows new data to update the vertexData
  85590. * @returns the VertexData
  85591. */
  85592. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85593. /**
  85594. * Associates the vertexData to the passed Geometry.
  85595. * Sets it as updatable or not (default `false`)
  85596. * @param geometry the geometry the vertexData is applied to
  85597. * @param updatable when used and having the value true allows new data to update the vertexData
  85598. * @returns VertexData
  85599. */
  85600. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85601. /**
  85602. * Updates the associated mesh
  85603. * @param mesh the mesh to be updated
  85604. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85605. * @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
  85606. * @returns VertexData
  85607. */
  85608. updateMesh(mesh: Mesh): VertexData;
  85609. /**
  85610. * Updates the associated geometry
  85611. * @param geometry the geometry to be updated
  85612. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85613. * @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
  85614. * @returns VertexData.
  85615. */
  85616. updateGeometry(geometry: Geometry): VertexData;
  85617. private _applyTo;
  85618. private _update;
  85619. /**
  85620. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85621. * @param matrix the transforming matrix
  85622. * @returns the VertexData
  85623. */
  85624. transform(matrix: Matrix): VertexData;
  85625. /**
  85626. * Merges the passed VertexData into the current one
  85627. * @param other the VertexData to be merged into the current one
  85628. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85629. * @returns the modified VertexData
  85630. */
  85631. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85632. private _mergeElement;
  85633. private _validate;
  85634. /**
  85635. * Serializes the VertexData
  85636. * @returns a serialized object
  85637. */
  85638. serialize(): any;
  85639. /**
  85640. * Extracts the vertexData from a mesh
  85641. * @param mesh the mesh from which to extract the VertexData
  85642. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85643. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85644. * @returns the object VertexData associated to the passed mesh
  85645. */
  85646. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85647. /**
  85648. * Extracts the vertexData from the geometry
  85649. * @param geometry the geometry from which to extract the VertexData
  85650. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85651. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85652. * @returns the object VertexData associated to the passed mesh
  85653. */
  85654. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85655. private static _ExtractFrom;
  85656. /**
  85657. * Creates the VertexData for a Ribbon
  85658. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85659. * * pathArray array of paths, each of which an array of successive Vector3
  85660. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85661. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85662. * * 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
  85663. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85664. * * 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)
  85665. * * 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)
  85666. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85667. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85668. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85669. * @returns the VertexData of the ribbon
  85670. */
  85671. static CreateRibbon(options: {
  85672. pathArray: Vector3[][];
  85673. closeArray?: boolean;
  85674. closePath?: boolean;
  85675. offset?: number;
  85676. sideOrientation?: number;
  85677. frontUVs?: Vector4;
  85678. backUVs?: Vector4;
  85679. invertUV?: boolean;
  85680. uvs?: Vector2[];
  85681. colors?: Color4[];
  85682. }): VertexData;
  85683. /**
  85684. * Creates the VertexData for a box
  85685. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85686. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85687. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85688. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85689. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85690. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85691. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85692. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85693. * * 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)
  85694. * * 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)
  85695. * @returns the VertexData of the box
  85696. */
  85697. static CreateBox(options: {
  85698. size?: number;
  85699. width?: number;
  85700. height?: number;
  85701. depth?: number;
  85702. faceUV?: Vector4[];
  85703. faceColors?: Color4[];
  85704. sideOrientation?: number;
  85705. frontUVs?: Vector4;
  85706. backUVs?: Vector4;
  85707. }): VertexData;
  85708. /**
  85709. * Creates the VertexData for a tiled box
  85710. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85711. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85712. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85713. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85715. * @returns the VertexData of the box
  85716. */
  85717. static CreateTiledBox(options: {
  85718. pattern?: number;
  85719. width?: number;
  85720. height?: number;
  85721. depth?: number;
  85722. tileSize?: number;
  85723. tileWidth?: number;
  85724. tileHeight?: number;
  85725. alignHorizontal?: number;
  85726. alignVertical?: number;
  85727. faceUV?: Vector4[];
  85728. faceColors?: Color4[];
  85729. sideOrientation?: number;
  85730. }): VertexData;
  85731. /**
  85732. * Creates the VertexData for a tiled plane
  85733. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85734. * * pattern a limited pattern arrangement depending on the number
  85735. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85736. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85737. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85739. * * 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)
  85740. * * 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)
  85741. * @returns the VertexData of the tiled plane
  85742. */
  85743. static CreateTiledPlane(options: {
  85744. pattern?: number;
  85745. tileSize?: number;
  85746. tileWidth?: number;
  85747. tileHeight?: number;
  85748. size?: number;
  85749. width?: number;
  85750. height?: number;
  85751. alignHorizontal?: number;
  85752. alignVertical?: number;
  85753. sideOrientation?: number;
  85754. frontUVs?: Vector4;
  85755. backUVs?: Vector4;
  85756. }): VertexData;
  85757. /**
  85758. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85759. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85760. * * segments sets the number of horizontal strips optional, default 32
  85761. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85762. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85763. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85764. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85765. * * 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
  85766. * * 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
  85767. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85768. * * 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)
  85769. * * 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)
  85770. * @returns the VertexData of the ellipsoid
  85771. */
  85772. static CreateSphere(options: {
  85773. segments?: number;
  85774. diameter?: number;
  85775. diameterX?: number;
  85776. diameterY?: number;
  85777. diameterZ?: number;
  85778. arc?: number;
  85779. slice?: number;
  85780. sideOrientation?: number;
  85781. frontUVs?: Vector4;
  85782. backUVs?: Vector4;
  85783. }): VertexData;
  85784. /**
  85785. * Creates the VertexData for a cylinder, cone or prism
  85786. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85787. * * height sets the height (y direction) of the cylinder, optional, default 2
  85788. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85789. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85790. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85791. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85792. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85793. * * 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
  85794. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85795. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85796. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85797. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85799. * * 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)
  85800. * * 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)
  85801. * @returns the VertexData of the cylinder, cone or prism
  85802. */
  85803. static CreateCylinder(options: {
  85804. height?: number;
  85805. diameterTop?: number;
  85806. diameterBottom?: number;
  85807. diameter?: number;
  85808. tessellation?: number;
  85809. subdivisions?: number;
  85810. arc?: number;
  85811. faceColors?: Color4[];
  85812. faceUV?: Vector4[];
  85813. hasRings?: boolean;
  85814. enclose?: boolean;
  85815. sideOrientation?: number;
  85816. frontUVs?: Vector4;
  85817. backUVs?: Vector4;
  85818. }): VertexData;
  85819. /**
  85820. * Creates the VertexData for a torus
  85821. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85822. * * diameter the diameter of the torus, optional default 1
  85823. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85824. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85826. * * 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)
  85827. * * 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)
  85828. * @returns the VertexData of the torus
  85829. */
  85830. static CreateTorus(options: {
  85831. diameter?: number;
  85832. thickness?: number;
  85833. tessellation?: number;
  85834. sideOrientation?: number;
  85835. frontUVs?: Vector4;
  85836. backUVs?: Vector4;
  85837. }): VertexData;
  85838. /**
  85839. * Creates the VertexData of the LineSystem
  85840. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85841. * - lines an array of lines, each line being an array of successive Vector3
  85842. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85843. * @returns the VertexData of the LineSystem
  85844. */
  85845. static CreateLineSystem(options: {
  85846. lines: Vector3[][];
  85847. colors?: Nullable<Color4[][]>;
  85848. }): VertexData;
  85849. /**
  85850. * Create the VertexData for a DashedLines
  85851. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85852. * - points an array successive Vector3
  85853. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85854. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85855. * - dashNb the intended total number of dashes, optional, default 200
  85856. * @returns the VertexData for the DashedLines
  85857. */
  85858. static CreateDashedLines(options: {
  85859. points: Vector3[];
  85860. dashSize?: number;
  85861. gapSize?: number;
  85862. dashNb?: number;
  85863. }): VertexData;
  85864. /**
  85865. * Creates the VertexData for a Ground
  85866. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85867. * - width the width (x direction) of the ground, optional, default 1
  85868. * - height the height (z direction) of the ground, optional, default 1
  85869. * - subdivisions the number of subdivisions per side, optional, default 1
  85870. * @returns the VertexData of the Ground
  85871. */
  85872. static CreateGround(options: {
  85873. width?: number;
  85874. height?: number;
  85875. subdivisions?: number;
  85876. subdivisionsX?: number;
  85877. subdivisionsY?: number;
  85878. }): VertexData;
  85879. /**
  85880. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85881. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85882. * * xmin the ground minimum X coordinate, optional, default -1
  85883. * * zmin the ground minimum Z coordinate, optional, default -1
  85884. * * xmax the ground maximum X coordinate, optional, default 1
  85885. * * zmax the ground maximum Z coordinate, optional, default 1
  85886. * * 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}
  85887. * * 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}
  85888. * @returns the VertexData of the TiledGround
  85889. */
  85890. static CreateTiledGround(options: {
  85891. xmin: number;
  85892. zmin: number;
  85893. xmax: number;
  85894. zmax: number;
  85895. subdivisions?: {
  85896. w: number;
  85897. h: number;
  85898. };
  85899. precision?: {
  85900. w: number;
  85901. h: number;
  85902. };
  85903. }): VertexData;
  85904. /**
  85905. * Creates the VertexData of the Ground designed from a heightmap
  85906. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85907. * * width the width (x direction) of the ground
  85908. * * height the height (z direction) of the ground
  85909. * * subdivisions the number of subdivisions per side
  85910. * * minHeight the minimum altitude on the ground, optional, default 0
  85911. * * maxHeight the maximum altitude on the ground, optional default 1
  85912. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85913. * * buffer the array holding the image color data
  85914. * * bufferWidth the width of image
  85915. * * bufferHeight the height of image
  85916. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85917. * @returns the VertexData of the Ground designed from a heightmap
  85918. */
  85919. static CreateGroundFromHeightMap(options: {
  85920. width: number;
  85921. height: number;
  85922. subdivisions: number;
  85923. minHeight: number;
  85924. maxHeight: number;
  85925. colorFilter: Color3;
  85926. buffer: Uint8Array;
  85927. bufferWidth: number;
  85928. bufferHeight: number;
  85929. alphaFilter: number;
  85930. }): VertexData;
  85931. /**
  85932. * Creates the VertexData for a Plane
  85933. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85934. * * size sets the width and height of the plane to the value of size, optional default 1
  85935. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85936. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85937. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85938. * * 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)
  85939. * * 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)
  85940. * @returns the VertexData of the box
  85941. */
  85942. static CreatePlane(options: {
  85943. size?: number;
  85944. width?: number;
  85945. height?: number;
  85946. sideOrientation?: number;
  85947. frontUVs?: Vector4;
  85948. backUVs?: Vector4;
  85949. }): VertexData;
  85950. /**
  85951. * Creates the VertexData of the Disc or regular Polygon
  85952. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85953. * * radius the radius of the disc, optional default 0.5
  85954. * * tessellation the number of polygon sides, optional, default 64
  85955. * * 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
  85956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85957. * * 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)
  85958. * * 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)
  85959. * @returns the VertexData of the box
  85960. */
  85961. static CreateDisc(options: {
  85962. radius?: number;
  85963. tessellation?: number;
  85964. arc?: number;
  85965. sideOrientation?: number;
  85966. frontUVs?: Vector4;
  85967. backUVs?: Vector4;
  85968. }): VertexData;
  85969. /**
  85970. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85971. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85972. * @param polygon a mesh built from polygonTriangulation.build()
  85973. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85974. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85975. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85976. * @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)
  85977. * @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)
  85978. * @returns the VertexData of the Polygon
  85979. */
  85980. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85981. /**
  85982. * Creates the VertexData of the IcoSphere
  85983. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85984. * * radius the radius of the IcoSphere, optional default 1
  85985. * * radiusX allows stretching in the x direction, optional, default radius
  85986. * * radiusY allows stretching in the y direction, optional, default radius
  85987. * * radiusZ allows stretching in the z direction, optional, default radius
  85988. * * flat when true creates a flat shaded mesh, optional, default true
  85989. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85991. * * 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)
  85992. * * 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)
  85993. * @returns the VertexData of the IcoSphere
  85994. */
  85995. static CreateIcoSphere(options: {
  85996. radius?: number;
  85997. radiusX?: number;
  85998. radiusY?: number;
  85999. radiusZ?: number;
  86000. flat?: boolean;
  86001. subdivisions?: number;
  86002. sideOrientation?: number;
  86003. frontUVs?: Vector4;
  86004. backUVs?: Vector4;
  86005. }): VertexData;
  86006. /**
  86007. * Creates the VertexData for a Polyhedron
  86008. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86009. * * type provided types are:
  86010. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86011. * * 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)
  86012. * * size the size of the IcoSphere, optional default 1
  86013. * * sizeX allows stretching in the x direction, optional, default size
  86014. * * sizeY allows stretching in the y direction, optional, default size
  86015. * * sizeZ allows stretching in the z direction, optional, default size
  86016. * * 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
  86017. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86018. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86019. * * flat when true creates a flat shaded mesh, optional, default true
  86020. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86022. * * 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)
  86023. * * 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)
  86024. * @returns the VertexData of the Polyhedron
  86025. */
  86026. static CreatePolyhedron(options: {
  86027. type?: number;
  86028. size?: number;
  86029. sizeX?: number;
  86030. sizeY?: number;
  86031. sizeZ?: number;
  86032. custom?: any;
  86033. faceUV?: Vector4[];
  86034. faceColors?: Color4[];
  86035. flat?: boolean;
  86036. sideOrientation?: number;
  86037. frontUVs?: Vector4;
  86038. backUVs?: Vector4;
  86039. }): VertexData;
  86040. /**
  86041. * Creates the VertexData for a TorusKnot
  86042. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86043. * * radius the radius of the torus knot, optional, default 2
  86044. * * tube the thickness of the tube, optional, default 0.5
  86045. * * radialSegments the number of sides on each tube segments, optional, default 32
  86046. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86047. * * p the number of windings around the z axis, optional, default 2
  86048. * * q the number of windings around the x axis, optional, default 3
  86049. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86050. * * 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)
  86051. * * 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)
  86052. * @returns the VertexData of the Torus Knot
  86053. */
  86054. static CreateTorusKnot(options: {
  86055. radius?: number;
  86056. tube?: number;
  86057. radialSegments?: number;
  86058. tubularSegments?: number;
  86059. p?: number;
  86060. q?: number;
  86061. sideOrientation?: number;
  86062. frontUVs?: Vector4;
  86063. backUVs?: Vector4;
  86064. }): VertexData;
  86065. /**
  86066. * Compute normals for given positions and indices
  86067. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86068. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86069. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86070. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86071. * * facetNormals : optional array of facet normals (vector3)
  86072. * * facetPositions : optional array of facet positions (vector3)
  86073. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86074. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86075. * * bInfo : optional bounding info, required for facetPartitioning computation
  86076. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86077. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86078. * * useRightHandedSystem: optional boolean to for right handed system computation
  86079. * * depthSort : optional boolean to enable the facet depth sort computation
  86080. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86081. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86082. */
  86083. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86084. facetNormals?: any;
  86085. facetPositions?: any;
  86086. facetPartitioning?: any;
  86087. ratio?: number;
  86088. bInfo?: any;
  86089. bbSize?: Vector3;
  86090. subDiv?: any;
  86091. useRightHandedSystem?: boolean;
  86092. depthSort?: boolean;
  86093. distanceTo?: Vector3;
  86094. depthSortedFacets?: any;
  86095. }): void;
  86096. /** @hidden */
  86097. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86098. /**
  86099. * Applies VertexData created from the imported parameters to the geometry
  86100. * @param parsedVertexData the parsed data from an imported file
  86101. * @param geometry the geometry to apply the VertexData to
  86102. */
  86103. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86104. }
  86105. }
  86106. declare module BABYLON {
  86107. /**
  86108. * Defines a target to use with MorphTargetManager
  86109. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86110. */
  86111. export class MorphTarget implements IAnimatable {
  86112. /** defines the name of the target */
  86113. name: string;
  86114. /**
  86115. * Gets or sets the list of animations
  86116. */
  86117. animations: Animation[];
  86118. private _scene;
  86119. private _positions;
  86120. private _normals;
  86121. private _tangents;
  86122. private _uvs;
  86123. private _influence;
  86124. /**
  86125. * Observable raised when the influence changes
  86126. */
  86127. onInfluenceChanged: Observable<boolean>;
  86128. /** @hidden */
  86129. _onDataLayoutChanged: Observable<void>;
  86130. /**
  86131. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  86132. */
  86133. influence: number;
  86134. /**
  86135. * Gets or sets the id of the morph Target
  86136. */
  86137. id: string;
  86138. private _animationPropertiesOverride;
  86139. /**
  86140. * Gets or sets the animation properties override
  86141. */
  86142. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  86143. /**
  86144. * Creates a new MorphTarget
  86145. * @param name defines the name of the target
  86146. * @param influence defines the influence to use
  86147. * @param scene defines the scene the morphtarget belongs to
  86148. */
  86149. constructor(
  86150. /** defines the name of the target */
  86151. name: string, influence?: number, scene?: Nullable<Scene>);
  86152. /**
  86153. * Gets a boolean defining if the target contains position data
  86154. */
  86155. readonly hasPositions: boolean;
  86156. /**
  86157. * Gets a boolean defining if the target contains normal data
  86158. */
  86159. readonly hasNormals: boolean;
  86160. /**
  86161. * Gets a boolean defining if the target contains tangent data
  86162. */
  86163. readonly hasTangents: boolean;
  86164. /**
  86165. * Gets a boolean defining if the target contains texture coordinates data
  86166. */
  86167. readonly hasUVs: boolean;
  86168. /**
  86169. * Affects position data to this target
  86170. * @param data defines the position data to use
  86171. */
  86172. setPositions(data: Nullable<FloatArray>): void;
  86173. /**
  86174. * Gets the position data stored in this target
  86175. * @returns a FloatArray containing the position data (or null if not present)
  86176. */
  86177. getPositions(): Nullable<FloatArray>;
  86178. /**
  86179. * Affects normal data to this target
  86180. * @param data defines the normal data to use
  86181. */
  86182. setNormals(data: Nullable<FloatArray>): void;
  86183. /**
  86184. * Gets the normal data stored in this target
  86185. * @returns a FloatArray containing the normal data (or null if not present)
  86186. */
  86187. getNormals(): Nullable<FloatArray>;
  86188. /**
  86189. * Affects tangent data to this target
  86190. * @param data defines the tangent data to use
  86191. */
  86192. setTangents(data: Nullable<FloatArray>): void;
  86193. /**
  86194. * Gets the tangent data stored in this target
  86195. * @returns a FloatArray containing the tangent data (or null if not present)
  86196. */
  86197. getTangents(): Nullable<FloatArray>;
  86198. /**
  86199. * Affects texture coordinates data to this target
  86200. * @param data defines the texture coordinates data to use
  86201. */
  86202. setUVs(data: Nullable<FloatArray>): void;
  86203. /**
  86204. * Gets the texture coordinates data stored in this target
  86205. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  86206. */
  86207. getUVs(): Nullable<FloatArray>;
  86208. /**
  86209. * Serializes the current target into a Serialization object
  86210. * @returns the serialized object
  86211. */
  86212. serialize(): any;
  86213. /**
  86214. * Returns the string "MorphTarget"
  86215. * @returns "MorphTarget"
  86216. */
  86217. getClassName(): string;
  86218. /**
  86219. * Creates a new target from serialized data
  86220. * @param serializationObject defines the serialized data to use
  86221. * @returns a new MorphTarget
  86222. */
  86223. static Parse(serializationObject: any): MorphTarget;
  86224. /**
  86225. * Creates a MorphTarget from mesh data
  86226. * @param mesh defines the source mesh
  86227. * @param name defines the name to use for the new target
  86228. * @param influence defines the influence to attach to the target
  86229. * @returns a new MorphTarget
  86230. */
  86231. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  86232. }
  86233. }
  86234. declare module BABYLON {
  86235. /**
  86236. * This class is used to deform meshes using morphing between different targets
  86237. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86238. */
  86239. export class MorphTargetManager {
  86240. private _targets;
  86241. private _targetInfluenceChangedObservers;
  86242. private _targetDataLayoutChangedObservers;
  86243. private _activeTargets;
  86244. private _scene;
  86245. private _influences;
  86246. private _supportsNormals;
  86247. private _supportsTangents;
  86248. private _supportsUVs;
  86249. private _vertexCount;
  86250. private _uniqueId;
  86251. private _tempInfluences;
  86252. /**
  86253. * Gets or sets a boolean indicating if normals must be morphed
  86254. */
  86255. enableNormalMorphing: boolean;
  86256. /**
  86257. * Gets or sets a boolean indicating if tangents must be morphed
  86258. */
  86259. enableTangentMorphing: boolean;
  86260. /**
  86261. * Gets or sets a boolean indicating if UV must be morphed
  86262. */
  86263. enableUVMorphing: boolean;
  86264. /**
  86265. * Creates a new MorphTargetManager
  86266. * @param scene defines the current scene
  86267. */
  86268. constructor(scene?: Nullable<Scene>);
  86269. /**
  86270. * Gets the unique ID of this manager
  86271. */
  86272. readonly uniqueId: number;
  86273. /**
  86274. * Gets the number of vertices handled by this manager
  86275. */
  86276. readonly vertexCount: number;
  86277. /**
  86278. * Gets a boolean indicating if this manager supports morphing of normals
  86279. */
  86280. readonly supportsNormals: boolean;
  86281. /**
  86282. * Gets a boolean indicating if this manager supports morphing of tangents
  86283. */
  86284. readonly supportsTangents: boolean;
  86285. /**
  86286. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  86287. */
  86288. readonly supportsUVs: boolean;
  86289. /**
  86290. * Gets the number of targets stored in this manager
  86291. */
  86292. readonly numTargets: number;
  86293. /**
  86294. * Gets the number of influencers (ie. the number of targets with influences > 0)
  86295. */
  86296. readonly numInfluencers: number;
  86297. /**
  86298. * Gets the list of influences (one per target)
  86299. */
  86300. readonly influences: Float32Array;
  86301. /**
  86302. * Gets the active target at specified index. An active target is a target with an influence > 0
  86303. * @param index defines the index to check
  86304. * @returns the requested target
  86305. */
  86306. getActiveTarget(index: number): MorphTarget;
  86307. /**
  86308. * Gets the target at specified index
  86309. * @param index defines the index to check
  86310. * @returns the requested target
  86311. */
  86312. getTarget(index: number): MorphTarget;
  86313. /**
  86314. * Add a new target to this manager
  86315. * @param target defines the target to add
  86316. */
  86317. addTarget(target: MorphTarget): void;
  86318. /**
  86319. * Removes a target from the manager
  86320. * @param target defines the target to remove
  86321. */
  86322. removeTarget(target: MorphTarget): void;
  86323. /**
  86324. * Serializes the current manager into a Serialization object
  86325. * @returns the serialized object
  86326. */
  86327. serialize(): any;
  86328. private _syncActiveTargets;
  86329. /**
  86330. * Syncrhonize the targets with all the meshes using this morph target manager
  86331. */
  86332. synchronize(): void;
  86333. /**
  86334. * Creates a new MorphTargetManager from serialized data
  86335. * @param serializationObject defines the serialized data
  86336. * @param scene defines the hosting scene
  86337. * @returns the new MorphTargetManager
  86338. */
  86339. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  86340. }
  86341. }
  86342. declare module BABYLON {
  86343. /**
  86344. * Class used to represent a specific level of detail of a mesh
  86345. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86346. */
  86347. export class MeshLODLevel {
  86348. /** Defines the distance where this level should star being displayed */
  86349. distance: number;
  86350. /** Defines the mesh to use to render this level */
  86351. mesh: Nullable<Mesh>;
  86352. /**
  86353. * Creates a new LOD level
  86354. * @param distance defines the distance where this level should star being displayed
  86355. * @param mesh defines the mesh to use to render this level
  86356. */
  86357. constructor(
  86358. /** Defines the distance where this level should star being displayed */
  86359. distance: number,
  86360. /** Defines the mesh to use to render this level */
  86361. mesh: Nullable<Mesh>);
  86362. }
  86363. }
  86364. declare module BABYLON {
  86365. /**
  86366. * Mesh representing the gorund
  86367. */
  86368. export class GroundMesh extends Mesh {
  86369. /** If octree should be generated */
  86370. generateOctree: boolean;
  86371. private _heightQuads;
  86372. /** @hidden */
  86373. _subdivisionsX: number;
  86374. /** @hidden */
  86375. _subdivisionsY: number;
  86376. /** @hidden */
  86377. _width: number;
  86378. /** @hidden */
  86379. _height: number;
  86380. /** @hidden */
  86381. _minX: number;
  86382. /** @hidden */
  86383. _maxX: number;
  86384. /** @hidden */
  86385. _minZ: number;
  86386. /** @hidden */
  86387. _maxZ: number;
  86388. constructor(name: string, scene: Scene);
  86389. /**
  86390. * "GroundMesh"
  86391. * @returns "GroundMesh"
  86392. */
  86393. getClassName(): string;
  86394. /**
  86395. * The minimum of x and y subdivisions
  86396. */
  86397. readonly subdivisions: number;
  86398. /**
  86399. * X subdivisions
  86400. */
  86401. readonly subdivisionsX: number;
  86402. /**
  86403. * Y subdivisions
  86404. */
  86405. readonly subdivisionsY: number;
  86406. /**
  86407. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  86408. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  86409. * @param chunksCount the number of subdivisions for x and y
  86410. * @param octreeBlocksSize (Default: 32)
  86411. */
  86412. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  86413. /**
  86414. * Returns a height (y) value in the Worl system :
  86415. * the ground altitude at the coordinates (x, z) expressed in the World system.
  86416. * @param x x coordinate
  86417. * @param z z coordinate
  86418. * @returns the ground y position if (x, z) are outside the ground surface.
  86419. */
  86420. getHeightAtCoordinates(x: number, z: number): number;
  86421. /**
  86422. * Returns a normalized vector (Vector3) orthogonal to the ground
  86423. * at the ground coordinates (x, z) expressed in the World system.
  86424. * @param x x coordinate
  86425. * @param z z coordinate
  86426. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  86427. */
  86428. getNormalAtCoordinates(x: number, z: number): Vector3;
  86429. /**
  86430. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  86431. * at the ground coordinates (x, z) expressed in the World system.
  86432. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  86433. * @param x x coordinate
  86434. * @param z z coordinate
  86435. * @param ref vector to store the result
  86436. * @returns the GroundMesh.
  86437. */
  86438. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  86439. /**
  86440. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  86441. * if the ground has been updated.
  86442. * This can be used in the render loop.
  86443. * @returns the GroundMesh.
  86444. */
  86445. updateCoordinateHeights(): GroundMesh;
  86446. private _getFacetAt;
  86447. private _initHeightQuads;
  86448. private _computeHeightQuads;
  86449. /**
  86450. * Serializes this ground mesh
  86451. * @param serializationObject object to write serialization to
  86452. */
  86453. serialize(serializationObject: any): void;
  86454. /**
  86455. * Parses a serialized ground mesh
  86456. * @param parsedMesh the serialized mesh
  86457. * @param scene the scene to create the ground mesh in
  86458. * @returns the created ground mesh
  86459. */
  86460. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  86461. }
  86462. }
  86463. declare module BABYLON {
  86464. /**
  86465. * Interface for Physics-Joint data
  86466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86467. */
  86468. export interface PhysicsJointData {
  86469. /**
  86470. * The main pivot of the joint
  86471. */
  86472. mainPivot?: Vector3;
  86473. /**
  86474. * The connected pivot of the joint
  86475. */
  86476. connectedPivot?: Vector3;
  86477. /**
  86478. * The main axis of the joint
  86479. */
  86480. mainAxis?: Vector3;
  86481. /**
  86482. * The connected axis of the joint
  86483. */
  86484. connectedAxis?: Vector3;
  86485. /**
  86486. * The collision of the joint
  86487. */
  86488. collision?: boolean;
  86489. /**
  86490. * Native Oimo/Cannon/Energy data
  86491. */
  86492. nativeParams?: any;
  86493. }
  86494. /**
  86495. * This is a holder class for the physics joint created by the physics plugin
  86496. * It holds a set of functions to control the underlying joint
  86497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86498. */
  86499. export class PhysicsJoint {
  86500. /**
  86501. * The type of the physics joint
  86502. */
  86503. type: number;
  86504. /**
  86505. * The data for the physics joint
  86506. */
  86507. jointData: PhysicsJointData;
  86508. private _physicsJoint;
  86509. protected _physicsPlugin: IPhysicsEnginePlugin;
  86510. /**
  86511. * Initializes the physics joint
  86512. * @param type The type of the physics joint
  86513. * @param jointData The data for the physics joint
  86514. */
  86515. constructor(
  86516. /**
  86517. * The type of the physics joint
  86518. */
  86519. type: number,
  86520. /**
  86521. * The data for the physics joint
  86522. */
  86523. jointData: PhysicsJointData);
  86524. /**
  86525. * Gets the physics joint
  86526. */
  86527. /**
  86528. * Sets the physics joint
  86529. */
  86530. physicsJoint: any;
  86531. /**
  86532. * Sets the physics plugin
  86533. */
  86534. physicsPlugin: IPhysicsEnginePlugin;
  86535. /**
  86536. * Execute a function that is physics-plugin specific.
  86537. * @param {Function} func the function that will be executed.
  86538. * It accepts two parameters: the physics world and the physics joint
  86539. */
  86540. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  86541. /**
  86542. * Distance-Joint type
  86543. */
  86544. static DistanceJoint: number;
  86545. /**
  86546. * Hinge-Joint type
  86547. */
  86548. static HingeJoint: number;
  86549. /**
  86550. * Ball-and-Socket joint type
  86551. */
  86552. static BallAndSocketJoint: number;
  86553. /**
  86554. * Wheel-Joint type
  86555. */
  86556. static WheelJoint: number;
  86557. /**
  86558. * Slider-Joint type
  86559. */
  86560. static SliderJoint: number;
  86561. /**
  86562. * Prismatic-Joint type
  86563. */
  86564. static PrismaticJoint: number;
  86565. /**
  86566. * Universal-Joint type
  86567. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  86568. */
  86569. static UniversalJoint: number;
  86570. /**
  86571. * Hinge-Joint 2 type
  86572. */
  86573. static Hinge2Joint: number;
  86574. /**
  86575. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  86576. */
  86577. static PointToPointJoint: number;
  86578. /**
  86579. * Spring-Joint type
  86580. */
  86581. static SpringJoint: number;
  86582. /**
  86583. * Lock-Joint type
  86584. */
  86585. static LockJoint: number;
  86586. }
  86587. /**
  86588. * A class representing a physics distance joint
  86589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86590. */
  86591. export class DistanceJoint extends PhysicsJoint {
  86592. /**
  86593. *
  86594. * @param jointData The data for the Distance-Joint
  86595. */
  86596. constructor(jointData: DistanceJointData);
  86597. /**
  86598. * Update the predefined distance.
  86599. * @param maxDistance The maximum preferred distance
  86600. * @param minDistance The minimum preferred distance
  86601. */
  86602. updateDistance(maxDistance: number, minDistance?: number): void;
  86603. }
  86604. /**
  86605. * Represents a Motor-Enabled Joint
  86606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86607. */
  86608. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  86609. /**
  86610. * Initializes the Motor-Enabled Joint
  86611. * @param type The type of the joint
  86612. * @param jointData The physica joint data for the joint
  86613. */
  86614. constructor(type: number, jointData: PhysicsJointData);
  86615. /**
  86616. * Set the motor values.
  86617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86618. * @param force the force to apply
  86619. * @param maxForce max force for this motor.
  86620. */
  86621. setMotor(force?: number, maxForce?: number): void;
  86622. /**
  86623. * Set the motor's limits.
  86624. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86625. * @param upperLimit The upper limit of the motor
  86626. * @param lowerLimit The lower limit of the motor
  86627. */
  86628. setLimit(upperLimit: number, lowerLimit?: number): void;
  86629. }
  86630. /**
  86631. * This class represents a single physics Hinge-Joint
  86632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86633. */
  86634. export class HingeJoint extends MotorEnabledJoint {
  86635. /**
  86636. * Initializes the Hinge-Joint
  86637. * @param jointData The joint data for the Hinge-Joint
  86638. */
  86639. constructor(jointData: PhysicsJointData);
  86640. /**
  86641. * Set the motor values.
  86642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86643. * @param {number} force the force to apply
  86644. * @param {number} maxForce max force for this motor.
  86645. */
  86646. setMotor(force?: number, maxForce?: number): void;
  86647. /**
  86648. * Set the motor's limits.
  86649. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86650. * @param upperLimit The upper limit of the motor
  86651. * @param lowerLimit The lower limit of the motor
  86652. */
  86653. setLimit(upperLimit: number, lowerLimit?: number): void;
  86654. }
  86655. /**
  86656. * This class represents a dual hinge physics joint (same as wheel joint)
  86657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86658. */
  86659. export class Hinge2Joint extends MotorEnabledJoint {
  86660. /**
  86661. * Initializes the Hinge2-Joint
  86662. * @param jointData The joint data for the Hinge2-Joint
  86663. */
  86664. constructor(jointData: PhysicsJointData);
  86665. /**
  86666. * Set the motor values.
  86667. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86668. * @param {number} targetSpeed the speed the motor is to reach
  86669. * @param {number} maxForce max force for this motor.
  86670. * @param {motorIndex} the motor's index, 0 or 1.
  86671. */
  86672. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86673. /**
  86674. * Set the motor limits.
  86675. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86676. * @param {number} upperLimit the upper limit
  86677. * @param {number} lowerLimit lower limit
  86678. * @param {motorIndex} the motor's index, 0 or 1.
  86679. */
  86680. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86681. }
  86682. /**
  86683. * Interface for a motor enabled joint
  86684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86685. */
  86686. export interface IMotorEnabledJoint {
  86687. /**
  86688. * Physics joint
  86689. */
  86690. physicsJoint: any;
  86691. /**
  86692. * Sets the motor of the motor-enabled joint
  86693. * @param force The force of the motor
  86694. * @param maxForce The maximum force of the motor
  86695. * @param motorIndex The index of the motor
  86696. */
  86697. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86698. /**
  86699. * Sets the limit of the motor
  86700. * @param upperLimit The upper limit of the motor
  86701. * @param lowerLimit The lower limit of the motor
  86702. * @param motorIndex The index of the motor
  86703. */
  86704. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86705. }
  86706. /**
  86707. * Joint data for a Distance-Joint
  86708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86709. */
  86710. export interface DistanceJointData extends PhysicsJointData {
  86711. /**
  86712. * Max distance the 2 joint objects can be apart
  86713. */
  86714. maxDistance: number;
  86715. }
  86716. /**
  86717. * Joint data from a spring joint
  86718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86719. */
  86720. export interface SpringJointData extends PhysicsJointData {
  86721. /**
  86722. * Length of the spring
  86723. */
  86724. length: number;
  86725. /**
  86726. * Stiffness of the spring
  86727. */
  86728. stiffness: number;
  86729. /**
  86730. * Damping of the spring
  86731. */
  86732. damping: number;
  86733. /** this callback will be called when applying the force to the impostors. */
  86734. forceApplicationCallback: () => void;
  86735. }
  86736. }
  86737. declare module BABYLON {
  86738. /**
  86739. * Holds the data for the raycast result
  86740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86741. */
  86742. export class PhysicsRaycastResult {
  86743. private _hasHit;
  86744. private _hitDistance;
  86745. private _hitNormalWorld;
  86746. private _hitPointWorld;
  86747. private _rayFromWorld;
  86748. private _rayToWorld;
  86749. /**
  86750. * Gets if there was a hit
  86751. */
  86752. readonly hasHit: boolean;
  86753. /**
  86754. * Gets the distance from the hit
  86755. */
  86756. readonly hitDistance: number;
  86757. /**
  86758. * Gets the hit normal/direction in the world
  86759. */
  86760. readonly hitNormalWorld: Vector3;
  86761. /**
  86762. * Gets the hit point in the world
  86763. */
  86764. readonly hitPointWorld: Vector3;
  86765. /**
  86766. * Gets the ray "start point" of the ray in the world
  86767. */
  86768. readonly rayFromWorld: Vector3;
  86769. /**
  86770. * Gets the ray "end point" of the ray in the world
  86771. */
  86772. readonly rayToWorld: Vector3;
  86773. /**
  86774. * Sets the hit data (normal & point in world space)
  86775. * @param hitNormalWorld defines the normal in world space
  86776. * @param hitPointWorld defines the point in world space
  86777. */
  86778. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86779. /**
  86780. * Sets the distance from the start point to the hit point
  86781. * @param distance
  86782. */
  86783. setHitDistance(distance: number): void;
  86784. /**
  86785. * Calculates the distance manually
  86786. */
  86787. calculateHitDistance(): void;
  86788. /**
  86789. * Resets all the values to default
  86790. * @param from The from point on world space
  86791. * @param to The to point on world space
  86792. */
  86793. reset(from?: Vector3, to?: Vector3): void;
  86794. }
  86795. /**
  86796. * Interface for the size containing width and height
  86797. */
  86798. interface IXYZ {
  86799. /**
  86800. * X
  86801. */
  86802. x: number;
  86803. /**
  86804. * Y
  86805. */
  86806. y: number;
  86807. /**
  86808. * Z
  86809. */
  86810. z: number;
  86811. }
  86812. }
  86813. declare module BABYLON {
  86814. /**
  86815. * Interface used to describe a physics joint
  86816. */
  86817. export interface PhysicsImpostorJoint {
  86818. /** Defines the main impostor to which the joint is linked */
  86819. mainImpostor: PhysicsImpostor;
  86820. /** Defines the impostor that is connected to the main impostor using this joint */
  86821. connectedImpostor: PhysicsImpostor;
  86822. /** Defines the joint itself */
  86823. joint: PhysicsJoint;
  86824. }
  86825. /** @hidden */
  86826. export interface IPhysicsEnginePlugin {
  86827. world: any;
  86828. name: string;
  86829. setGravity(gravity: Vector3): void;
  86830. setTimeStep(timeStep: number): void;
  86831. getTimeStep(): number;
  86832. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86833. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86834. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86835. generatePhysicsBody(impostor: PhysicsImpostor): void;
  86836. removePhysicsBody(impostor: PhysicsImpostor): void;
  86837. generateJoint(joint: PhysicsImpostorJoint): void;
  86838. removeJoint(joint: PhysicsImpostorJoint): void;
  86839. isSupported(): boolean;
  86840. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  86841. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  86842. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86843. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86844. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86845. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86846. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  86847. getBodyMass(impostor: PhysicsImpostor): number;
  86848. getBodyFriction(impostor: PhysicsImpostor): number;
  86849. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  86850. getBodyRestitution(impostor: PhysicsImpostor): number;
  86851. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  86852. getBodyPressure?(impostor: PhysicsImpostor): number;
  86853. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  86854. getBodyStiffness?(impostor: PhysicsImpostor): number;
  86855. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  86856. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  86857. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  86858. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  86859. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  86860. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86861. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86862. sleepBody(impostor: PhysicsImpostor): void;
  86863. wakeUpBody(impostor: PhysicsImpostor): void;
  86864. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86865. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  86866. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  86867. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86868. getRadius(impostor: PhysicsImpostor): number;
  86869. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  86870. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  86871. dispose(): void;
  86872. }
  86873. /**
  86874. * Interface used to define a physics engine
  86875. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  86876. */
  86877. export interface IPhysicsEngine {
  86878. /**
  86879. * Gets the gravity vector used by the simulation
  86880. */
  86881. gravity: Vector3;
  86882. /**
  86883. * Sets the gravity vector used by the simulation
  86884. * @param gravity defines the gravity vector to use
  86885. */
  86886. setGravity(gravity: Vector3): void;
  86887. /**
  86888. * Set the time step of the physics engine.
  86889. * Default is 1/60.
  86890. * To slow it down, enter 1/600 for example.
  86891. * To speed it up, 1/30
  86892. * @param newTimeStep the new timestep to apply to this world.
  86893. */
  86894. setTimeStep(newTimeStep: number): void;
  86895. /**
  86896. * Get the time step of the physics engine.
  86897. * @returns the current time step
  86898. */
  86899. getTimeStep(): number;
  86900. /**
  86901. * Release all resources
  86902. */
  86903. dispose(): void;
  86904. /**
  86905. * Gets the name of the current physics plugin
  86906. * @returns the name of the plugin
  86907. */
  86908. getPhysicsPluginName(): string;
  86909. /**
  86910. * Adding a new impostor for the impostor tracking.
  86911. * This will be done by the impostor itself.
  86912. * @param impostor the impostor to add
  86913. */
  86914. addImpostor(impostor: PhysicsImpostor): void;
  86915. /**
  86916. * Remove an impostor from the engine.
  86917. * This impostor and its mesh will not longer be updated by the physics engine.
  86918. * @param impostor the impostor to remove
  86919. */
  86920. removeImpostor(impostor: PhysicsImpostor): void;
  86921. /**
  86922. * Add a joint to the physics engine
  86923. * @param mainImpostor defines the main impostor to which the joint is added.
  86924. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  86925. * @param joint defines the joint that will connect both impostors.
  86926. */
  86927. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86928. /**
  86929. * Removes a joint from the simulation
  86930. * @param mainImpostor defines the impostor used with the joint
  86931. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  86932. * @param joint defines the joint to remove
  86933. */
  86934. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86935. /**
  86936. * Gets the current plugin used to run the simulation
  86937. * @returns current plugin
  86938. */
  86939. getPhysicsPlugin(): IPhysicsEnginePlugin;
  86940. /**
  86941. * Gets the list of physic impostors
  86942. * @returns an array of PhysicsImpostor
  86943. */
  86944. getImpostors(): Array<PhysicsImpostor>;
  86945. /**
  86946. * Gets the impostor for a physics enabled object
  86947. * @param object defines the object impersonated by the impostor
  86948. * @returns the PhysicsImpostor or null if not found
  86949. */
  86950. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86951. /**
  86952. * Gets the impostor for a physics body object
  86953. * @param body defines physics body used by the impostor
  86954. * @returns the PhysicsImpostor or null if not found
  86955. */
  86956. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  86957. /**
  86958. * Does a raycast in the physics world
  86959. * @param from when should the ray start?
  86960. * @param to when should the ray end?
  86961. * @returns PhysicsRaycastResult
  86962. */
  86963. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86964. /**
  86965. * Called by the scene. No need to call it.
  86966. * @param delta defines the timespam between frames
  86967. */
  86968. _step(delta: number): void;
  86969. }
  86970. }
  86971. declare module BABYLON {
  86972. /**
  86973. * The interface for the physics imposter parameters
  86974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86975. */
  86976. export interface PhysicsImpostorParameters {
  86977. /**
  86978. * The mass of the physics imposter
  86979. */
  86980. mass: number;
  86981. /**
  86982. * The friction of the physics imposter
  86983. */
  86984. friction?: number;
  86985. /**
  86986. * The coefficient of restitution of the physics imposter
  86987. */
  86988. restitution?: number;
  86989. /**
  86990. * The native options of the physics imposter
  86991. */
  86992. nativeOptions?: any;
  86993. /**
  86994. * Specifies if the parent should be ignored
  86995. */
  86996. ignoreParent?: boolean;
  86997. /**
  86998. * Specifies if bi-directional transformations should be disabled
  86999. */
  87000. disableBidirectionalTransformation?: boolean;
  87001. /**
  87002. * The pressure inside the physics imposter, soft object only
  87003. */
  87004. pressure?: number;
  87005. /**
  87006. * The stiffness the physics imposter, soft object only
  87007. */
  87008. stiffness?: number;
  87009. /**
  87010. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  87011. */
  87012. velocityIterations?: number;
  87013. /**
  87014. * The number of iterations used in maintaining consistent vertex positions, soft object only
  87015. */
  87016. positionIterations?: number;
  87017. /**
  87018. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  87019. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  87020. * Add to fix multiple points
  87021. */
  87022. fixedPoints?: number;
  87023. /**
  87024. * The collision margin around a soft object
  87025. */
  87026. margin?: number;
  87027. /**
  87028. * The collision margin around a soft object
  87029. */
  87030. damping?: number;
  87031. /**
  87032. * The path for a rope based on an extrusion
  87033. */
  87034. path?: any;
  87035. /**
  87036. * The shape of an extrusion used for a rope based on an extrusion
  87037. */
  87038. shape?: any;
  87039. }
  87040. /**
  87041. * Interface for a physics-enabled object
  87042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87043. */
  87044. export interface IPhysicsEnabledObject {
  87045. /**
  87046. * The position of the physics-enabled object
  87047. */
  87048. position: Vector3;
  87049. /**
  87050. * The rotation of the physics-enabled object
  87051. */
  87052. rotationQuaternion: Nullable<Quaternion>;
  87053. /**
  87054. * The scale of the physics-enabled object
  87055. */
  87056. scaling: Vector3;
  87057. /**
  87058. * The rotation of the physics-enabled object
  87059. */
  87060. rotation?: Vector3;
  87061. /**
  87062. * The parent of the physics-enabled object
  87063. */
  87064. parent?: any;
  87065. /**
  87066. * The bounding info of the physics-enabled object
  87067. * @returns The bounding info of the physics-enabled object
  87068. */
  87069. getBoundingInfo(): BoundingInfo;
  87070. /**
  87071. * Computes the world matrix
  87072. * @param force Specifies if the world matrix should be computed by force
  87073. * @returns A world matrix
  87074. */
  87075. computeWorldMatrix(force: boolean): Matrix;
  87076. /**
  87077. * Gets the world matrix
  87078. * @returns A world matrix
  87079. */
  87080. getWorldMatrix?(): Matrix;
  87081. /**
  87082. * Gets the child meshes
  87083. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  87084. * @returns An array of abstract meshes
  87085. */
  87086. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  87087. /**
  87088. * Gets the vertex data
  87089. * @param kind The type of vertex data
  87090. * @returns A nullable array of numbers, or a float32 array
  87091. */
  87092. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  87093. /**
  87094. * Gets the indices from the mesh
  87095. * @returns A nullable array of index arrays
  87096. */
  87097. getIndices?(): Nullable<IndicesArray>;
  87098. /**
  87099. * Gets the scene from the mesh
  87100. * @returns the indices array or null
  87101. */
  87102. getScene?(): Scene;
  87103. /**
  87104. * Gets the absolute position from the mesh
  87105. * @returns the absolute position
  87106. */
  87107. getAbsolutePosition(): Vector3;
  87108. /**
  87109. * Gets the absolute pivot point from the mesh
  87110. * @returns the absolute pivot point
  87111. */
  87112. getAbsolutePivotPoint(): Vector3;
  87113. /**
  87114. * Rotates the mesh
  87115. * @param axis The axis of rotation
  87116. * @param amount The amount of rotation
  87117. * @param space The space of the rotation
  87118. * @returns The rotation transform node
  87119. */
  87120. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87121. /**
  87122. * Translates the mesh
  87123. * @param axis The axis of translation
  87124. * @param distance The distance of translation
  87125. * @param space The space of the translation
  87126. * @returns The transform node
  87127. */
  87128. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87129. /**
  87130. * Sets the absolute position of the mesh
  87131. * @param absolutePosition The absolute position of the mesh
  87132. * @returns The transform node
  87133. */
  87134. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87135. /**
  87136. * Gets the class name of the mesh
  87137. * @returns The class name
  87138. */
  87139. getClassName(): string;
  87140. }
  87141. /**
  87142. * Represents a physics imposter
  87143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87144. */
  87145. export class PhysicsImpostor {
  87146. /**
  87147. * The physics-enabled object used as the physics imposter
  87148. */
  87149. object: IPhysicsEnabledObject;
  87150. /**
  87151. * The type of the physics imposter
  87152. */
  87153. type: number;
  87154. private _options;
  87155. private _scene?;
  87156. /**
  87157. * The default object size of the imposter
  87158. */
  87159. static DEFAULT_OBJECT_SIZE: Vector3;
  87160. /**
  87161. * The identity quaternion of the imposter
  87162. */
  87163. static IDENTITY_QUATERNION: Quaternion;
  87164. /** @hidden */
  87165. _pluginData: any;
  87166. private _physicsEngine;
  87167. private _physicsBody;
  87168. private _bodyUpdateRequired;
  87169. private _onBeforePhysicsStepCallbacks;
  87170. private _onAfterPhysicsStepCallbacks;
  87171. /** @hidden */
  87172. _onPhysicsCollideCallbacks: Array<{
  87173. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  87174. otherImpostors: Array<PhysicsImpostor>;
  87175. }>;
  87176. private _deltaPosition;
  87177. private _deltaRotation;
  87178. private _deltaRotationConjugated;
  87179. /** @hidden */
  87180. _isFromLine: boolean;
  87181. private _parent;
  87182. private _isDisposed;
  87183. private static _tmpVecs;
  87184. private static _tmpQuat;
  87185. /**
  87186. * Specifies if the physics imposter is disposed
  87187. */
  87188. readonly isDisposed: boolean;
  87189. /**
  87190. * Gets the mass of the physics imposter
  87191. */
  87192. mass: number;
  87193. /**
  87194. * Gets the coefficient of friction
  87195. */
  87196. /**
  87197. * Sets the coefficient of friction
  87198. */
  87199. friction: number;
  87200. /**
  87201. * Gets the coefficient of restitution
  87202. */
  87203. /**
  87204. * Sets the coefficient of restitution
  87205. */
  87206. restitution: number;
  87207. /**
  87208. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  87209. */
  87210. /**
  87211. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  87212. */
  87213. pressure: number;
  87214. /**
  87215. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87216. */
  87217. /**
  87218. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87219. */
  87220. stiffness: number;
  87221. /**
  87222. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87223. */
  87224. /**
  87225. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87226. */
  87227. velocityIterations: number;
  87228. /**
  87229. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87230. */
  87231. /**
  87232. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87233. */
  87234. positionIterations: number;
  87235. /**
  87236. * The unique id of the physics imposter
  87237. * set by the physics engine when adding this impostor to the array
  87238. */
  87239. uniqueId: number;
  87240. /**
  87241. * @hidden
  87242. */
  87243. soft: boolean;
  87244. /**
  87245. * @hidden
  87246. */
  87247. segments: number;
  87248. private _joints;
  87249. /**
  87250. * Initializes the physics imposter
  87251. * @param object The physics-enabled object used as the physics imposter
  87252. * @param type The type of the physics imposter
  87253. * @param _options The options for the physics imposter
  87254. * @param _scene The Babylon scene
  87255. */
  87256. constructor(
  87257. /**
  87258. * The physics-enabled object used as the physics imposter
  87259. */
  87260. object: IPhysicsEnabledObject,
  87261. /**
  87262. * The type of the physics imposter
  87263. */
  87264. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  87265. /**
  87266. * This function will completly initialize this impostor.
  87267. * It will create a new body - but only if this mesh has no parent.
  87268. * If it has, this impostor will not be used other than to define the impostor
  87269. * of the child mesh.
  87270. * @hidden
  87271. */
  87272. _init(): void;
  87273. private _getPhysicsParent;
  87274. /**
  87275. * Should a new body be generated.
  87276. * @returns boolean specifying if body initialization is required
  87277. */
  87278. isBodyInitRequired(): boolean;
  87279. /**
  87280. * Sets the updated scaling
  87281. * @param updated Specifies if the scaling is updated
  87282. */
  87283. setScalingUpdated(): void;
  87284. /**
  87285. * Force a regeneration of this or the parent's impostor's body.
  87286. * Use under cautious - This will remove all joints already implemented.
  87287. */
  87288. forceUpdate(): void;
  87289. /**
  87290. * Gets the body that holds this impostor. Either its own, or its parent.
  87291. */
  87292. /**
  87293. * Set the physics body. Used mainly by the physics engine/plugin
  87294. */
  87295. physicsBody: any;
  87296. /**
  87297. * Get the parent of the physics imposter
  87298. * @returns Physics imposter or null
  87299. */
  87300. /**
  87301. * Sets the parent of the physics imposter
  87302. */
  87303. parent: Nullable<PhysicsImpostor>;
  87304. /**
  87305. * Resets the update flags
  87306. */
  87307. resetUpdateFlags(): void;
  87308. /**
  87309. * Gets the object extend size
  87310. * @returns the object extend size
  87311. */
  87312. getObjectExtendSize(): Vector3;
  87313. /**
  87314. * Gets the object center
  87315. * @returns The object center
  87316. */
  87317. getObjectCenter(): Vector3;
  87318. /**
  87319. * Get a specific parametes from the options parameter
  87320. * @param paramName The object parameter name
  87321. * @returns The object parameter
  87322. */
  87323. getParam(paramName: string): any;
  87324. /**
  87325. * Sets a specific parameter in the options given to the physics plugin
  87326. * @param paramName The parameter name
  87327. * @param value The value of the parameter
  87328. */
  87329. setParam(paramName: string, value: number): void;
  87330. /**
  87331. * Specifically change the body's mass option. Won't recreate the physics body object
  87332. * @param mass The mass of the physics imposter
  87333. */
  87334. setMass(mass: number): void;
  87335. /**
  87336. * Gets the linear velocity
  87337. * @returns linear velocity or null
  87338. */
  87339. getLinearVelocity(): Nullable<Vector3>;
  87340. /**
  87341. * Sets the linear velocity
  87342. * @param velocity linear velocity or null
  87343. */
  87344. setLinearVelocity(velocity: Nullable<Vector3>): void;
  87345. /**
  87346. * Gets the angular velocity
  87347. * @returns angular velocity or null
  87348. */
  87349. getAngularVelocity(): Nullable<Vector3>;
  87350. /**
  87351. * Sets the angular velocity
  87352. * @param velocity The velocity or null
  87353. */
  87354. setAngularVelocity(velocity: Nullable<Vector3>): void;
  87355. /**
  87356. * Execute a function with the physics plugin native code
  87357. * Provide a function the will have two variables - the world object and the physics body object
  87358. * @param func The function to execute with the physics plugin native code
  87359. */
  87360. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  87361. /**
  87362. * Register a function that will be executed before the physics world is stepping forward
  87363. * @param func The function to execute before the physics world is stepped forward
  87364. */
  87365. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87366. /**
  87367. * Unregister a function that will be executed before the physics world is stepping forward
  87368. * @param func The function to execute before the physics world is stepped forward
  87369. */
  87370. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87371. /**
  87372. * Register a function that will be executed after the physics step
  87373. * @param func The function to execute after physics step
  87374. */
  87375. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87376. /**
  87377. * Unregisters a function that will be executed after the physics step
  87378. * @param func The function to execute after physics step
  87379. */
  87380. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87381. /**
  87382. * register a function that will be executed when this impostor collides against a different body
  87383. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  87384. * @param func Callback that is executed on collision
  87385. */
  87386. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  87387. /**
  87388. * Unregisters the physics imposter on contact
  87389. * @param collideAgainst The physics object to collide against
  87390. * @param func Callback to execute on collision
  87391. */
  87392. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  87393. private _tmpQuat;
  87394. private _tmpQuat2;
  87395. /**
  87396. * Get the parent rotation
  87397. * @returns The parent rotation
  87398. */
  87399. getParentsRotation(): Quaternion;
  87400. /**
  87401. * this function is executed by the physics engine.
  87402. */
  87403. beforeStep: () => void;
  87404. /**
  87405. * this function is executed by the physics engine
  87406. */
  87407. afterStep: () => void;
  87408. /**
  87409. * Legacy collision detection event support
  87410. */
  87411. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  87412. /**
  87413. * event and body object due to cannon's event-based architecture.
  87414. */
  87415. onCollide: (e: {
  87416. body: any;
  87417. }) => void;
  87418. /**
  87419. * Apply a force
  87420. * @param force The force to apply
  87421. * @param contactPoint The contact point for the force
  87422. * @returns The physics imposter
  87423. */
  87424. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87425. /**
  87426. * Apply an impulse
  87427. * @param force The impulse force
  87428. * @param contactPoint The contact point for the impulse force
  87429. * @returns The physics imposter
  87430. */
  87431. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87432. /**
  87433. * A help function to create a joint
  87434. * @param otherImpostor A physics imposter used to create a joint
  87435. * @param jointType The type of joint
  87436. * @param jointData The data for the joint
  87437. * @returns The physics imposter
  87438. */
  87439. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  87440. /**
  87441. * Add a joint to this impostor with a different impostor
  87442. * @param otherImpostor A physics imposter used to add a joint
  87443. * @param joint The joint to add
  87444. * @returns The physics imposter
  87445. */
  87446. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  87447. /**
  87448. * Add an anchor to a cloth impostor
  87449. * @param otherImpostor rigid impostor to anchor to
  87450. * @param width ratio across width from 0 to 1
  87451. * @param height ratio up height from 0 to 1
  87452. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  87453. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  87454. * @returns impostor the soft imposter
  87455. */
  87456. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87457. /**
  87458. * Add a hook to a rope impostor
  87459. * @param otherImpostor rigid impostor to anchor to
  87460. * @param length ratio across rope from 0 to 1
  87461. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  87462. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  87463. * @returns impostor the rope imposter
  87464. */
  87465. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87466. /**
  87467. * Will keep this body still, in a sleep mode.
  87468. * @returns the physics imposter
  87469. */
  87470. sleep(): PhysicsImpostor;
  87471. /**
  87472. * Wake the body up.
  87473. * @returns The physics imposter
  87474. */
  87475. wakeUp(): PhysicsImpostor;
  87476. /**
  87477. * Clones the physics imposter
  87478. * @param newObject The physics imposter clones to this physics-enabled object
  87479. * @returns A nullable physics imposter
  87480. */
  87481. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87482. /**
  87483. * Disposes the physics imposter
  87484. */
  87485. dispose(): void;
  87486. /**
  87487. * Sets the delta position
  87488. * @param position The delta position amount
  87489. */
  87490. setDeltaPosition(position: Vector3): void;
  87491. /**
  87492. * Sets the delta rotation
  87493. * @param rotation The delta rotation amount
  87494. */
  87495. setDeltaRotation(rotation: Quaternion): void;
  87496. /**
  87497. * Gets the box size of the physics imposter and stores the result in the input parameter
  87498. * @param result Stores the box size
  87499. * @returns The physics imposter
  87500. */
  87501. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  87502. /**
  87503. * Gets the radius of the physics imposter
  87504. * @returns Radius of the physics imposter
  87505. */
  87506. getRadius(): number;
  87507. /**
  87508. * Sync a bone with this impostor
  87509. * @param bone The bone to sync to the impostor.
  87510. * @param boneMesh The mesh that the bone is influencing.
  87511. * @param jointPivot The pivot of the joint / bone in local space.
  87512. * @param distToJoint Optional distance from the impostor to the joint.
  87513. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87514. */
  87515. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  87516. /**
  87517. * Sync impostor to a bone
  87518. * @param bone The bone that the impostor will be synced to.
  87519. * @param boneMesh The mesh that the bone is influencing.
  87520. * @param jointPivot The pivot of the joint / bone in local space.
  87521. * @param distToJoint Optional distance from the impostor to the joint.
  87522. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87523. * @param boneAxis Optional vector3 axis the bone is aligned with
  87524. */
  87525. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  87526. /**
  87527. * No-Imposter type
  87528. */
  87529. static NoImpostor: number;
  87530. /**
  87531. * Sphere-Imposter type
  87532. */
  87533. static SphereImpostor: number;
  87534. /**
  87535. * Box-Imposter type
  87536. */
  87537. static BoxImpostor: number;
  87538. /**
  87539. * Plane-Imposter type
  87540. */
  87541. static PlaneImpostor: number;
  87542. /**
  87543. * Mesh-imposter type
  87544. */
  87545. static MeshImpostor: number;
  87546. /**
  87547. * Capsule-Impostor type (Ammo.js plugin only)
  87548. */
  87549. static CapsuleImpostor: number;
  87550. /**
  87551. * Cylinder-Imposter type
  87552. */
  87553. static CylinderImpostor: number;
  87554. /**
  87555. * Particle-Imposter type
  87556. */
  87557. static ParticleImpostor: number;
  87558. /**
  87559. * Heightmap-Imposter type
  87560. */
  87561. static HeightmapImpostor: number;
  87562. /**
  87563. * ConvexHull-Impostor type (Ammo.js plugin only)
  87564. */
  87565. static ConvexHullImpostor: number;
  87566. /**
  87567. * Rope-Imposter type
  87568. */
  87569. static RopeImpostor: number;
  87570. /**
  87571. * Cloth-Imposter type
  87572. */
  87573. static ClothImpostor: number;
  87574. /**
  87575. * Softbody-Imposter type
  87576. */
  87577. static SoftbodyImpostor: number;
  87578. }
  87579. }
  87580. declare module BABYLON {
  87581. /**
  87582. * @hidden
  87583. **/
  87584. export class _CreationDataStorage {
  87585. closePath?: boolean;
  87586. closeArray?: boolean;
  87587. idx: number[];
  87588. dashSize: number;
  87589. gapSize: number;
  87590. path3D: Path3D;
  87591. pathArray: Vector3[][];
  87592. arc: number;
  87593. radius: number;
  87594. cap: number;
  87595. tessellation: number;
  87596. }
  87597. /**
  87598. * @hidden
  87599. **/
  87600. class _InstanceDataStorage {
  87601. visibleInstances: any;
  87602. batchCache: _InstancesBatch;
  87603. instancesBufferSize: number;
  87604. instancesBuffer: Nullable<Buffer>;
  87605. instancesData: Float32Array;
  87606. overridenInstanceCount: number;
  87607. isFrozen: boolean;
  87608. previousBatch: Nullable<_InstancesBatch>;
  87609. hardwareInstancedRendering: boolean;
  87610. sideOrientation: number;
  87611. }
  87612. /**
  87613. * @hidden
  87614. **/
  87615. export class _InstancesBatch {
  87616. mustReturn: boolean;
  87617. visibleInstances: Nullable<InstancedMesh[]>[];
  87618. renderSelf: boolean[];
  87619. hardwareInstancedRendering: boolean[];
  87620. }
  87621. /**
  87622. * Class used to represent renderable models
  87623. */
  87624. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  87625. /**
  87626. * Mesh side orientation : usually the external or front surface
  87627. */
  87628. static readonly FRONTSIDE: number;
  87629. /**
  87630. * Mesh side orientation : usually the internal or back surface
  87631. */
  87632. static readonly BACKSIDE: number;
  87633. /**
  87634. * Mesh side orientation : both internal and external or front and back surfaces
  87635. */
  87636. static readonly DOUBLESIDE: number;
  87637. /**
  87638. * Mesh side orientation : by default, `FRONTSIDE`
  87639. */
  87640. static readonly DEFAULTSIDE: number;
  87641. /**
  87642. * Mesh cap setting : no cap
  87643. */
  87644. static readonly NO_CAP: number;
  87645. /**
  87646. * Mesh cap setting : one cap at the beginning of the mesh
  87647. */
  87648. static readonly CAP_START: number;
  87649. /**
  87650. * Mesh cap setting : one cap at the end of the mesh
  87651. */
  87652. static readonly CAP_END: number;
  87653. /**
  87654. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87655. */
  87656. static readonly CAP_ALL: number;
  87657. /**
  87658. * Mesh pattern setting : no flip or rotate
  87659. */
  87660. static readonly NO_FLIP: number;
  87661. /**
  87662. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87663. */
  87664. static readonly FLIP_TILE: number;
  87665. /**
  87666. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87667. */
  87668. static readonly ROTATE_TILE: number;
  87669. /**
  87670. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87671. */
  87672. static readonly FLIP_ROW: number;
  87673. /**
  87674. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87675. */
  87676. static readonly ROTATE_ROW: number;
  87677. /**
  87678. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87679. */
  87680. static readonly FLIP_N_ROTATE_TILE: number;
  87681. /**
  87682. * Mesh pattern setting : rotate pattern and rotate
  87683. */
  87684. static readonly FLIP_N_ROTATE_ROW: number;
  87685. /**
  87686. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87687. */
  87688. static readonly CENTER: number;
  87689. /**
  87690. * Mesh tile positioning : part tiles on left
  87691. */
  87692. static readonly LEFT: number;
  87693. /**
  87694. * Mesh tile positioning : part tiles on right
  87695. */
  87696. static readonly RIGHT: number;
  87697. /**
  87698. * Mesh tile positioning : part tiles on top
  87699. */
  87700. static readonly TOP: number;
  87701. /**
  87702. * Mesh tile positioning : part tiles on bottom
  87703. */
  87704. static readonly BOTTOM: number;
  87705. /**
  87706. * Gets the default side orientation.
  87707. * @param orientation the orientation to value to attempt to get
  87708. * @returns the default orientation
  87709. * @hidden
  87710. */
  87711. static _GetDefaultSideOrientation(orientation?: number): number;
  87712. private _internalMeshDataInfo;
  87713. /**
  87714. * An event triggered before rendering the mesh
  87715. */
  87716. readonly onBeforeRenderObservable: Observable<Mesh>;
  87717. /**
  87718. * An event triggered before binding the mesh
  87719. */
  87720. readonly onBeforeBindObservable: Observable<Mesh>;
  87721. /**
  87722. * An event triggered after rendering the mesh
  87723. */
  87724. readonly onAfterRenderObservable: Observable<Mesh>;
  87725. /**
  87726. * An event triggered before drawing the mesh
  87727. */
  87728. readonly onBeforeDrawObservable: Observable<Mesh>;
  87729. private _onBeforeDrawObserver;
  87730. /**
  87731. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87732. */
  87733. onBeforeDraw: () => void;
  87734. /**
  87735. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87736. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87737. */
  87738. delayLoadState: number;
  87739. /**
  87740. * Gets the list of instances created from this mesh
  87741. * it is not supposed to be modified manually.
  87742. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87743. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87744. */
  87745. instances: InstancedMesh[];
  87746. /**
  87747. * Gets the file containing delay loading data for this mesh
  87748. */
  87749. delayLoadingFile: string;
  87750. /** @hidden */
  87751. _binaryInfo: any;
  87752. /**
  87753. * User defined function used to change how LOD level selection is done
  87754. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87755. */
  87756. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87757. /**
  87758. * Gets or sets the morph target manager
  87759. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87760. */
  87761. morphTargetManager: Nullable<MorphTargetManager>;
  87762. /** @hidden */
  87763. _creationDataStorage: Nullable<_CreationDataStorage>;
  87764. /** @hidden */
  87765. _geometry: Nullable<Geometry>;
  87766. /** @hidden */
  87767. _delayInfo: Array<string>;
  87768. /** @hidden */
  87769. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87770. /** @hidden */
  87771. _instanceDataStorage: _InstanceDataStorage;
  87772. private _effectiveMaterial;
  87773. /** @hidden */
  87774. _shouldGenerateFlatShading: boolean;
  87775. /** @hidden */
  87776. _originalBuilderSideOrientation: number;
  87777. /**
  87778. * Use this property to change the original side orientation defined at construction time
  87779. */
  87780. overrideMaterialSideOrientation: Nullable<number>;
  87781. /**
  87782. * Gets the source mesh (the one used to clone this one from)
  87783. */
  87784. readonly source: Nullable<Mesh>;
  87785. /**
  87786. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87787. */
  87788. isUnIndexed: boolean;
  87789. /**
  87790. * @constructor
  87791. * @param name The value used by scene.getMeshByName() to do a lookup.
  87792. * @param scene The scene to add this mesh to.
  87793. * @param parent The parent of this mesh, if it has one
  87794. * @param source An optional Mesh from which geometry is shared, cloned.
  87795. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87796. * When false, achieved by calling a clone(), also passing False.
  87797. * This will make creation of children, recursive.
  87798. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87799. */
  87800. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87801. /**
  87802. * Gets the class name
  87803. * @returns the string "Mesh".
  87804. */
  87805. getClassName(): string;
  87806. /** @hidden */
  87807. readonly _isMesh: boolean;
  87808. /**
  87809. * Returns a description of this mesh
  87810. * @param fullDetails define if full details about this mesh must be used
  87811. * @returns a descriptive string representing this mesh
  87812. */
  87813. toString(fullDetails?: boolean): string;
  87814. /** @hidden */
  87815. _unBindEffect(): void;
  87816. /**
  87817. * Gets a boolean indicating if this mesh has LOD
  87818. */
  87819. readonly hasLODLevels: boolean;
  87820. /**
  87821. * Gets the list of MeshLODLevel associated with the current mesh
  87822. * @returns an array of MeshLODLevel
  87823. */
  87824. getLODLevels(): MeshLODLevel[];
  87825. private _sortLODLevels;
  87826. /**
  87827. * Add a mesh as LOD level triggered at the given distance.
  87828. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87829. * @param distance The distance from the center of the object to show this level
  87830. * @param mesh The mesh to be added as LOD level (can be null)
  87831. * @return This mesh (for chaining)
  87832. */
  87833. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  87834. /**
  87835. * Returns the LOD level mesh at the passed distance or null if not found.
  87836. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87837. * @param distance The distance from the center of the object to show this level
  87838. * @returns a Mesh or `null`
  87839. */
  87840. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  87841. /**
  87842. * Remove a mesh from the LOD array
  87843. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87844. * @param mesh defines the mesh to be removed
  87845. * @return This mesh (for chaining)
  87846. */
  87847. removeLODLevel(mesh: Mesh): Mesh;
  87848. /**
  87849. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87850. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87851. * @param camera defines the camera to use to compute distance
  87852. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87853. * @return This mesh (for chaining)
  87854. */
  87855. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  87856. /**
  87857. * Gets the mesh internal Geometry object
  87858. */
  87859. readonly geometry: Nullable<Geometry>;
  87860. /**
  87861. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87862. * @returns the total number of vertices
  87863. */
  87864. getTotalVertices(): number;
  87865. /**
  87866. * Returns the content of an associated vertex buffer
  87867. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87868. * - VertexBuffer.PositionKind
  87869. * - VertexBuffer.UVKind
  87870. * - VertexBuffer.UV2Kind
  87871. * - VertexBuffer.UV3Kind
  87872. * - VertexBuffer.UV4Kind
  87873. * - VertexBuffer.UV5Kind
  87874. * - VertexBuffer.UV6Kind
  87875. * - VertexBuffer.ColorKind
  87876. * - VertexBuffer.MatricesIndicesKind
  87877. * - VertexBuffer.MatricesIndicesExtraKind
  87878. * - VertexBuffer.MatricesWeightsKind
  87879. * - VertexBuffer.MatricesWeightsExtraKind
  87880. * @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
  87881. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87882. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87883. */
  87884. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87885. /**
  87886. * Returns the mesh VertexBuffer object from the requested `kind`
  87887. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87888. * - VertexBuffer.PositionKind
  87889. * - VertexBuffer.NormalKind
  87890. * - VertexBuffer.UVKind
  87891. * - VertexBuffer.UV2Kind
  87892. * - VertexBuffer.UV3Kind
  87893. * - VertexBuffer.UV4Kind
  87894. * - VertexBuffer.UV5Kind
  87895. * - VertexBuffer.UV6Kind
  87896. * - VertexBuffer.ColorKind
  87897. * - VertexBuffer.MatricesIndicesKind
  87898. * - VertexBuffer.MatricesIndicesExtraKind
  87899. * - VertexBuffer.MatricesWeightsKind
  87900. * - VertexBuffer.MatricesWeightsExtraKind
  87901. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87902. */
  87903. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87904. /**
  87905. * Tests if a specific vertex buffer is associated with this mesh
  87906. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87907. * - VertexBuffer.PositionKind
  87908. * - VertexBuffer.NormalKind
  87909. * - VertexBuffer.UVKind
  87910. * - VertexBuffer.UV2Kind
  87911. * - VertexBuffer.UV3Kind
  87912. * - VertexBuffer.UV4Kind
  87913. * - VertexBuffer.UV5Kind
  87914. * - VertexBuffer.UV6Kind
  87915. * - VertexBuffer.ColorKind
  87916. * - VertexBuffer.MatricesIndicesKind
  87917. * - VertexBuffer.MatricesIndicesExtraKind
  87918. * - VertexBuffer.MatricesWeightsKind
  87919. * - VertexBuffer.MatricesWeightsExtraKind
  87920. * @returns a boolean
  87921. */
  87922. isVerticesDataPresent(kind: string): boolean;
  87923. /**
  87924. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87925. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87926. * - VertexBuffer.PositionKind
  87927. * - VertexBuffer.UVKind
  87928. * - VertexBuffer.UV2Kind
  87929. * - VertexBuffer.UV3Kind
  87930. * - VertexBuffer.UV4Kind
  87931. * - VertexBuffer.UV5Kind
  87932. * - VertexBuffer.UV6Kind
  87933. * - VertexBuffer.ColorKind
  87934. * - VertexBuffer.MatricesIndicesKind
  87935. * - VertexBuffer.MatricesIndicesExtraKind
  87936. * - VertexBuffer.MatricesWeightsKind
  87937. * - VertexBuffer.MatricesWeightsExtraKind
  87938. * @returns a boolean
  87939. */
  87940. isVertexBufferUpdatable(kind: string): boolean;
  87941. /**
  87942. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87943. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87944. * - VertexBuffer.PositionKind
  87945. * - VertexBuffer.NormalKind
  87946. * - VertexBuffer.UVKind
  87947. * - VertexBuffer.UV2Kind
  87948. * - VertexBuffer.UV3Kind
  87949. * - VertexBuffer.UV4Kind
  87950. * - VertexBuffer.UV5Kind
  87951. * - VertexBuffer.UV6Kind
  87952. * - VertexBuffer.ColorKind
  87953. * - VertexBuffer.MatricesIndicesKind
  87954. * - VertexBuffer.MatricesIndicesExtraKind
  87955. * - VertexBuffer.MatricesWeightsKind
  87956. * - VertexBuffer.MatricesWeightsExtraKind
  87957. * @returns an array of strings
  87958. */
  87959. getVerticesDataKinds(): string[];
  87960. /**
  87961. * Returns a positive integer : the total number of indices in this mesh geometry.
  87962. * @returns the numner of indices or zero if the mesh has no geometry.
  87963. */
  87964. getTotalIndices(): number;
  87965. /**
  87966. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87967. * @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.
  87968. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87969. * @returns the indices array or an empty array if the mesh has no geometry
  87970. */
  87971. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87972. readonly isBlocked: boolean;
  87973. /**
  87974. * Determine if the current mesh is ready to be rendered
  87975. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87976. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87977. * @returns true if all associated assets are ready (material, textures, shaders)
  87978. */
  87979. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  87980. /**
  87981. * 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.
  87982. */
  87983. readonly areNormalsFrozen: boolean;
  87984. /**
  87985. * 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.
  87986. * @returns the current mesh
  87987. */
  87988. freezeNormals(): Mesh;
  87989. /**
  87990. * 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
  87991. * @returns the current mesh
  87992. */
  87993. unfreezeNormals(): Mesh;
  87994. /**
  87995. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  87996. */
  87997. overridenInstanceCount: number;
  87998. /** @hidden */
  87999. _preActivate(): Mesh;
  88000. /** @hidden */
  88001. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88002. /** @hidden */
  88003. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  88004. /**
  88005. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88006. * This means the mesh underlying bounding box and sphere are recomputed.
  88007. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88008. * @returns the current mesh
  88009. */
  88010. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  88011. /** @hidden */
  88012. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  88013. /**
  88014. * This function will subdivide the mesh into multiple submeshes
  88015. * @param count defines the expected number of submeshes
  88016. */
  88017. subdivide(count: number): void;
  88018. /**
  88019. * Copy a FloatArray into a specific associated vertex buffer
  88020. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88021. * - VertexBuffer.PositionKind
  88022. * - VertexBuffer.UVKind
  88023. * - VertexBuffer.UV2Kind
  88024. * - VertexBuffer.UV3Kind
  88025. * - VertexBuffer.UV4Kind
  88026. * - VertexBuffer.UV5Kind
  88027. * - VertexBuffer.UV6Kind
  88028. * - VertexBuffer.ColorKind
  88029. * - VertexBuffer.MatricesIndicesKind
  88030. * - VertexBuffer.MatricesIndicesExtraKind
  88031. * - VertexBuffer.MatricesWeightsKind
  88032. * - VertexBuffer.MatricesWeightsExtraKind
  88033. * @param data defines the data source
  88034. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88035. * @param stride defines the data stride size (can be null)
  88036. * @returns the current mesh
  88037. */
  88038. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  88039. /**
  88040. * Flags an associated vertex buffer as updatable
  88041. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88042. * - VertexBuffer.PositionKind
  88043. * - VertexBuffer.UVKind
  88044. * - VertexBuffer.UV2Kind
  88045. * - VertexBuffer.UV3Kind
  88046. * - VertexBuffer.UV4Kind
  88047. * - VertexBuffer.UV5Kind
  88048. * - VertexBuffer.UV6Kind
  88049. * - VertexBuffer.ColorKind
  88050. * - VertexBuffer.MatricesIndicesKind
  88051. * - VertexBuffer.MatricesIndicesExtraKind
  88052. * - VertexBuffer.MatricesWeightsKind
  88053. * - VertexBuffer.MatricesWeightsExtraKind
  88054. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88055. */
  88056. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  88057. /**
  88058. * Sets the mesh global Vertex Buffer
  88059. * @param buffer defines the buffer to use
  88060. * @returns the current mesh
  88061. */
  88062. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  88063. /**
  88064. * Update a specific associated vertex buffer
  88065. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88066. * - VertexBuffer.PositionKind
  88067. * - VertexBuffer.UVKind
  88068. * - VertexBuffer.UV2Kind
  88069. * - VertexBuffer.UV3Kind
  88070. * - VertexBuffer.UV4Kind
  88071. * - VertexBuffer.UV5Kind
  88072. * - VertexBuffer.UV6Kind
  88073. * - VertexBuffer.ColorKind
  88074. * - VertexBuffer.MatricesIndicesKind
  88075. * - VertexBuffer.MatricesIndicesExtraKind
  88076. * - VertexBuffer.MatricesWeightsKind
  88077. * - VertexBuffer.MatricesWeightsExtraKind
  88078. * @param data defines the data source
  88079. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88080. * @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)
  88081. * @returns the current mesh
  88082. */
  88083. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88084. /**
  88085. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88086. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88087. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88088. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88089. * @returns the current mesh
  88090. */
  88091. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  88092. /**
  88093. * Creates a un-shared specific occurence of the geometry for the mesh.
  88094. * @returns the current mesh
  88095. */
  88096. makeGeometryUnique(): Mesh;
  88097. /**
  88098. * Set the index buffer of this mesh
  88099. * @param indices defines the source data
  88100. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88101. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88102. * @returns the current mesh
  88103. */
  88104. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  88105. /**
  88106. * Update the current index buffer
  88107. * @param indices defines the source data
  88108. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88109. * @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)
  88110. * @returns the current mesh
  88111. */
  88112. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  88113. /**
  88114. * Invert the geometry to move from a right handed system to a left handed one.
  88115. * @returns the current mesh
  88116. */
  88117. toLeftHanded(): Mesh;
  88118. /** @hidden */
  88119. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88120. /** @hidden */
  88121. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88122. /**
  88123. * Registers for this mesh a javascript function called just before the rendering process
  88124. * @param func defines the function to call before rendering this mesh
  88125. * @returns the current mesh
  88126. */
  88127. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88128. /**
  88129. * Disposes a previously registered javascript function called before the rendering
  88130. * @param func defines the function to remove
  88131. * @returns the current mesh
  88132. */
  88133. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88134. /**
  88135. * Registers for this mesh a javascript function called just after the rendering is complete
  88136. * @param func defines the function to call after rendering this mesh
  88137. * @returns the current mesh
  88138. */
  88139. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88140. /**
  88141. * Disposes a previously registered javascript function called after the rendering.
  88142. * @param func defines the function to remove
  88143. * @returns the current mesh
  88144. */
  88145. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88146. /** @hidden */
  88147. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  88148. /** @hidden */
  88149. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  88150. /** @hidden */
  88151. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  88152. /** @hidden */
  88153. _rebuild(): void;
  88154. /** @hidden */
  88155. _freeze(): void;
  88156. /** @hidden */
  88157. _unFreeze(): void;
  88158. /**
  88159. * 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
  88160. * @param subMesh defines the subMesh to render
  88161. * @param enableAlphaMode defines if alpha mode can be changed
  88162. * @returns the current mesh
  88163. */
  88164. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  88165. private _onBeforeDraw;
  88166. /**
  88167. * Renormalize the mesh and patch it up if there are no weights
  88168. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88169. * However in the case of zero weights then we set just a single influence to 1.
  88170. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88171. */
  88172. cleanMatrixWeights(): void;
  88173. private normalizeSkinFourWeights;
  88174. private normalizeSkinWeightsAndExtra;
  88175. /**
  88176. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88177. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88178. * the user know there was an issue with importing the mesh
  88179. * @returns a validation object with skinned, valid and report string
  88180. */
  88181. validateSkinning(): {
  88182. skinned: boolean;
  88183. valid: boolean;
  88184. report: string;
  88185. };
  88186. /** @hidden */
  88187. _checkDelayState(): Mesh;
  88188. private _queueLoad;
  88189. /**
  88190. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88191. * A mesh is in the frustum if its bounding box intersects the frustum
  88192. * @param frustumPlanes defines the frustum to test
  88193. * @returns true if the mesh is in the frustum planes
  88194. */
  88195. isInFrustum(frustumPlanes: Plane[]): boolean;
  88196. /**
  88197. * Sets the mesh material by the material or multiMaterial `id` property
  88198. * @param id is a string identifying the material or the multiMaterial
  88199. * @returns the current mesh
  88200. */
  88201. setMaterialByID(id: string): Mesh;
  88202. /**
  88203. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88204. * @returns an array of IAnimatable
  88205. */
  88206. getAnimatables(): IAnimatable[];
  88207. /**
  88208. * Modifies the mesh geometry according to the passed transformation matrix.
  88209. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88210. * The mesh normals are modified using the same transformation.
  88211. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88212. * @param transform defines the transform matrix to use
  88213. * @see http://doc.babylonjs.com/resources/baking_transformations
  88214. * @returns the current mesh
  88215. */
  88216. bakeTransformIntoVertices(transform: Matrix): Mesh;
  88217. /**
  88218. * Modifies the mesh geometry according to its own current World Matrix.
  88219. * The mesh World Matrix is then reset.
  88220. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88221. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88222. * @see http://doc.babylonjs.com/resources/baking_transformations
  88223. * @returns the current mesh
  88224. */
  88225. bakeCurrentTransformIntoVertices(): Mesh;
  88226. /** @hidden */
  88227. readonly _positions: Nullable<Vector3[]>;
  88228. /** @hidden */
  88229. _resetPointsArrayCache(): Mesh;
  88230. /** @hidden */
  88231. _generatePointsArray(): boolean;
  88232. /**
  88233. * Returns a new Mesh object generated from the current mesh properties.
  88234. * This method must not get confused with createInstance()
  88235. * @param name is a string, the name given to the new mesh
  88236. * @param newParent can be any Node object (default `null`)
  88237. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88238. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88239. * @returns a new mesh
  88240. */
  88241. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  88242. /**
  88243. * Releases resources associated with this mesh.
  88244. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88245. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88246. */
  88247. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88248. /**
  88249. * Modifies the mesh geometry according to a displacement map.
  88250. * 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.
  88251. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88252. * @param url is a string, the URL from the image file is to be downloaded.
  88253. * @param minHeight is the lower limit of the displacement.
  88254. * @param maxHeight is the upper limit of the displacement.
  88255. * @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.
  88256. * @param uvOffset is an optional vector2 used to offset UV.
  88257. * @param uvScale is an optional vector2 used to scale UV.
  88258. * @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.
  88259. * @returns the Mesh.
  88260. */
  88261. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88262. /**
  88263. * Modifies the mesh geometry according to a displacementMap buffer.
  88264. * 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.
  88265. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88266. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88267. * @param heightMapWidth is the width of the buffer image.
  88268. * @param heightMapHeight is the height of the buffer image.
  88269. * @param minHeight is the lower limit of the displacement.
  88270. * @param maxHeight is the upper limit of the displacement.
  88271. * @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.
  88272. * @param uvOffset is an optional vector2 used to offset UV.
  88273. * @param uvScale is an optional vector2 used to scale UV.
  88274. * @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.
  88275. * @returns the Mesh.
  88276. */
  88277. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88278. /**
  88279. * Modify the mesh to get a flat shading rendering.
  88280. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88281. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88282. * @returns current mesh
  88283. */
  88284. convertToFlatShadedMesh(): Mesh;
  88285. /**
  88286. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88287. * In other words, more vertices, no more indices and a single bigger VBO.
  88288. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88289. * @returns current mesh
  88290. */
  88291. convertToUnIndexedMesh(): Mesh;
  88292. /**
  88293. * Inverses facet orientations.
  88294. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88295. * @param flipNormals will also inverts the normals
  88296. * @returns current mesh
  88297. */
  88298. flipFaces(flipNormals?: boolean): Mesh;
  88299. /**
  88300. * Increase the number of facets and hence vertices in a mesh
  88301. * Vertex normals are interpolated from existing vertex normals
  88302. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88303. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88304. */
  88305. increaseVertices(numberPerEdge: number): void;
  88306. /**
  88307. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88308. * This will undo any application of covertToFlatShadedMesh
  88309. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88310. */
  88311. forceSharedVertices(): void;
  88312. /** @hidden */
  88313. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  88314. /** @hidden */
  88315. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  88316. /**
  88317. * Creates a new InstancedMesh object from the mesh model.
  88318. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88319. * @param name defines the name of the new instance
  88320. * @returns a new InstancedMesh
  88321. */
  88322. createInstance(name: string): InstancedMesh;
  88323. /**
  88324. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88325. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88326. * @returns the current mesh
  88327. */
  88328. synchronizeInstances(): Mesh;
  88329. /**
  88330. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88331. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88332. * This should be used together with the simplification to avoid disappearing triangles.
  88333. * @param successCallback an optional success callback to be called after the optimization finished.
  88334. * @returns the current mesh
  88335. */
  88336. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  88337. /**
  88338. * Serialize current mesh
  88339. * @param serializationObject defines the object which will receive the serialization data
  88340. */
  88341. serialize(serializationObject: any): void;
  88342. /** @hidden */
  88343. _syncGeometryWithMorphTargetManager(): void;
  88344. /** @hidden */
  88345. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  88346. /**
  88347. * Returns a new Mesh object parsed from the source provided.
  88348. * @param parsedMesh is the source
  88349. * @param scene defines the hosting scene
  88350. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  88351. * @returns a new Mesh
  88352. */
  88353. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  88354. /**
  88355. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88356. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88357. * @param name defines the name of the mesh to create
  88358. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88359. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88360. * @param closePath creates a seam between the first and the last points of each path of the path array
  88361. * @param offset is taken in account only if the `pathArray` is containing a single path
  88362. * @param scene defines the hosting scene
  88363. * @param updatable defines if the mesh must be flagged as updatable
  88364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88365. * @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)
  88366. * @returns a new Mesh
  88367. */
  88368. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88369. /**
  88370. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88371. * @param name defines the name of the mesh to create
  88372. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88373. * @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
  88374. * @param scene defines the hosting scene
  88375. * @param updatable defines if the mesh must be flagged as updatable
  88376. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88377. * @returns a new Mesh
  88378. */
  88379. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88380. /**
  88381. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88382. * @param name defines the name of the mesh to create
  88383. * @param size sets the size (float) of each box side (default 1)
  88384. * @param scene defines the hosting scene
  88385. * @param updatable defines if the mesh must be flagged as updatable
  88386. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88387. * @returns a new Mesh
  88388. */
  88389. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88390. /**
  88391. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88392. * @param name defines the name of the mesh to create
  88393. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88394. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88395. * @param scene defines the hosting scene
  88396. * @param updatable defines if the mesh must be flagged as updatable
  88397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88398. * @returns a new Mesh
  88399. */
  88400. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88401. /**
  88402. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  88403. * @param name defines the name of the mesh to create
  88404. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88405. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88406. * @param scene defines the hosting scene
  88407. * @returns a new Mesh
  88408. */
  88409. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  88410. /**
  88411. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  88412. * @param name defines the name of the mesh to create
  88413. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  88414. * @param diameterTop set the top cap diameter (floats, default 1)
  88415. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  88416. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  88417. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  88418. * @param scene defines the hosting scene
  88419. * @param updatable defines if the mesh must be flagged as updatable
  88420. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88421. * @returns a new Mesh
  88422. */
  88423. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  88424. /**
  88425. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  88426. * @param name defines the name of the mesh to create
  88427. * @param diameter sets the diameter size (float) of the torus (default 1)
  88428. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  88429. * @param tessellation sets the number of torus sides (postive integer, default 16)
  88430. * @param scene defines the hosting scene
  88431. * @param updatable defines if the mesh must be flagged as updatable
  88432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88433. * @returns a new Mesh
  88434. */
  88435. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88436. /**
  88437. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  88438. * @param name defines the name of the mesh to create
  88439. * @param radius sets the global radius size (float) of the torus knot (default 2)
  88440. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  88441. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  88442. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  88443. * @param p the number of windings on X axis (positive integers, default 2)
  88444. * @param q the number of windings on Y axis (positive integers, default 3)
  88445. * @param scene defines the hosting scene
  88446. * @param updatable defines if the mesh must be flagged as updatable
  88447. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88448. * @returns a new Mesh
  88449. */
  88450. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88451. /**
  88452. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  88453. * @param name defines the name of the mesh to create
  88454. * @param points is an array successive Vector3
  88455. * @param scene defines the hosting scene
  88456. * @param updatable defines if the mesh must be flagged as updatable
  88457. * @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).
  88458. * @returns a new Mesh
  88459. */
  88460. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  88461. /**
  88462. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  88463. * @param name defines the name of the mesh to create
  88464. * @param points is an array successive Vector3
  88465. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  88466. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88467. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  88468. * @param scene defines the hosting scene
  88469. * @param updatable defines if the mesh must be flagged as updatable
  88470. * @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)
  88471. * @returns a new Mesh
  88472. */
  88473. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  88474. /**
  88475. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  88476. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  88477. * 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.
  88478. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88479. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88480. * Remember you can only change the shape positions, not their number when updating a polygon.
  88481. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88482. * @param name defines the name of the mesh to create
  88483. * @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
  88484. * @param scene defines the hosting scene
  88485. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88486. * @param updatable defines if the mesh must be flagged as updatable
  88487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88488. * @param earcutInjection can be used to inject your own earcut reference
  88489. * @returns a new Mesh
  88490. */
  88491. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88492. /**
  88493. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88494. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88495. * @param name defines the name of the mesh to create
  88496. * @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
  88497. * @param depth defines the height of extrusion
  88498. * @param scene defines the hosting scene
  88499. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88500. * @param updatable defines if the mesh must be flagged as updatable
  88501. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88502. * @param earcutInjection can be used to inject your own earcut reference
  88503. * @returns a new Mesh
  88504. */
  88505. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88506. /**
  88507. * Creates an extruded shape mesh.
  88508. * 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
  88509. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88510. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88511. * @param name defines the name of the mesh to create
  88512. * @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
  88513. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88514. * @param scale is the value to scale the shape
  88515. * @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
  88516. * @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
  88517. * @param scene defines the hosting scene
  88518. * @param updatable defines if the mesh must be flagged as updatable
  88519. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88520. * @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)
  88521. * @returns a new Mesh
  88522. */
  88523. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88524. /**
  88525. * Creates an custom extruded shape mesh.
  88526. * The custom extrusion is a parametric shape.
  88527. * It has no predefined shape. Its final shape will depend on the input parameters.
  88528. * Please consider using the same method from the MeshBuilder class instead
  88529. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88530. * @param name defines the name of the mesh to create
  88531. * @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
  88532. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88533. * @param scaleFunction is a custom Javascript function called on each path point
  88534. * @param rotationFunction is a custom Javascript function called on each path point
  88535. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88536. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88537. * @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
  88538. * @param scene defines the hosting scene
  88539. * @param updatable defines if the mesh must be flagged as updatable
  88540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88541. * @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)
  88542. * @returns a new Mesh
  88543. */
  88544. 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;
  88545. /**
  88546. * Creates lathe mesh.
  88547. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88548. * Please consider using the same method from the MeshBuilder class instead
  88549. * @param name defines the name of the mesh to create
  88550. * @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
  88551. * @param radius is the radius value of the lathe
  88552. * @param tessellation is the side number of the lathe.
  88553. * @param scene defines the hosting scene
  88554. * @param updatable defines if the mesh must be flagged as updatable
  88555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88556. * @returns a new Mesh
  88557. */
  88558. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88559. /**
  88560. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88561. * @param name defines the name of the mesh to create
  88562. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88563. * @param scene defines the hosting scene
  88564. * @param updatable defines if the mesh must be flagged as updatable
  88565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88566. * @returns a new Mesh
  88567. */
  88568. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88569. /**
  88570. * Creates a ground mesh.
  88571. * Please consider using the same method from the MeshBuilder class instead
  88572. * @param name defines the name of the mesh to create
  88573. * @param width set the width of the ground
  88574. * @param height set the height of the ground
  88575. * @param subdivisions sets the number of subdivisions per side
  88576. * @param scene defines the hosting scene
  88577. * @param updatable defines if the mesh must be flagged as updatable
  88578. * @returns a new Mesh
  88579. */
  88580. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  88581. /**
  88582. * Creates a tiled ground mesh.
  88583. * Please consider using the same method from the MeshBuilder class instead
  88584. * @param name defines the name of the mesh to create
  88585. * @param xmin set the ground minimum X coordinate
  88586. * @param zmin set the ground minimum Y coordinate
  88587. * @param xmax set the ground maximum X coordinate
  88588. * @param zmax set the ground maximum Z coordinate
  88589. * @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
  88590. * @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
  88591. * @param scene defines the hosting scene
  88592. * @param updatable defines if the mesh must be flagged as updatable
  88593. * @returns a new Mesh
  88594. */
  88595. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  88596. w: number;
  88597. h: number;
  88598. }, precision: {
  88599. w: number;
  88600. h: number;
  88601. }, scene: Scene, updatable?: boolean): Mesh;
  88602. /**
  88603. * Creates a ground mesh from a height map.
  88604. * Please consider using the same method from the MeshBuilder class instead
  88605. * @see http://doc.babylonjs.com/babylon101/height_map
  88606. * @param name defines the name of the mesh to create
  88607. * @param url sets the URL of the height map image resource
  88608. * @param width set the ground width size
  88609. * @param height set the ground height size
  88610. * @param subdivisions sets the number of subdivision per side
  88611. * @param minHeight is the minimum altitude on the ground
  88612. * @param maxHeight is the maximum altitude on the ground
  88613. * @param scene defines the hosting scene
  88614. * @param updatable defines if the mesh must be flagged as updatable
  88615. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88616. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88617. * @returns a new Mesh
  88618. */
  88619. 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;
  88620. /**
  88621. * Creates a tube mesh.
  88622. * The tube is a parametric shape.
  88623. * It has no predefined shape. Its final shape will depend on the input parameters.
  88624. * Please consider using the same method from the MeshBuilder class instead
  88625. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88626. * @param name defines the name of the mesh to create
  88627. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88628. * @param radius sets the tube radius size
  88629. * @param tessellation is the number of sides on the tubular surface
  88630. * @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
  88631. * @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
  88632. * @param scene defines the hosting scene
  88633. * @param updatable defines if the mesh must be flagged as updatable
  88634. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88635. * @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)
  88636. * @returns a new Mesh
  88637. */
  88638. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  88639. (i: number, distance: number): number;
  88640. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88641. /**
  88642. * Creates a polyhedron mesh.
  88643. * Please consider using the same method from the MeshBuilder class instead.
  88644. * * 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
  88645. * * The parameter `size` (positive float, default 1) sets the polygon size
  88646. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88647. * * 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`
  88648. * * 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
  88649. * * 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)`)
  88650. * * 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
  88651. * * 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
  88652. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88653. * * If you create a double-sided mesh, you can choose what parts of 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
  88654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88655. * @param name defines the name of the mesh to create
  88656. * @param options defines the options used to create the mesh
  88657. * @param scene defines the hosting scene
  88658. * @returns a new Mesh
  88659. */
  88660. static CreatePolyhedron(name: string, options: {
  88661. type?: number;
  88662. size?: number;
  88663. sizeX?: number;
  88664. sizeY?: number;
  88665. sizeZ?: number;
  88666. custom?: any;
  88667. faceUV?: Vector4[];
  88668. faceColors?: Color4[];
  88669. updatable?: boolean;
  88670. sideOrientation?: number;
  88671. }, scene: Scene): Mesh;
  88672. /**
  88673. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88674. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88675. * * 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`)
  88676. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88677. * * 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
  88678. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88679. * * If you create a double-sided mesh, you can choose what parts of 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
  88680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88681. * @param name defines the name of the mesh
  88682. * @param options defines the options used to create the mesh
  88683. * @param scene defines the hosting scene
  88684. * @returns a new Mesh
  88685. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88686. */
  88687. static CreateIcoSphere(name: string, options: {
  88688. radius?: number;
  88689. flat?: boolean;
  88690. subdivisions?: number;
  88691. sideOrientation?: number;
  88692. updatable?: boolean;
  88693. }, scene: Scene): Mesh;
  88694. /**
  88695. * Creates a decal mesh.
  88696. * Please consider using the same method from the MeshBuilder class instead.
  88697. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88698. * @param name defines the name of the mesh
  88699. * @param sourceMesh defines the mesh receiving the decal
  88700. * @param position sets the position of the decal in world coordinates
  88701. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88702. * @param size sets the decal scaling
  88703. * @param angle sets the angle to rotate the decal
  88704. * @returns a new Mesh
  88705. */
  88706. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  88707. /**
  88708. * Prepare internal position array for software CPU skinning
  88709. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88710. */
  88711. setPositionsForCPUSkinning(): Float32Array;
  88712. /**
  88713. * Prepare internal normal array for software CPU skinning
  88714. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88715. */
  88716. setNormalsForCPUSkinning(): Float32Array;
  88717. /**
  88718. * Updates the vertex buffer by applying transformation from the bones
  88719. * @param skeleton defines the skeleton to apply to current mesh
  88720. * @returns the current mesh
  88721. */
  88722. applySkeleton(skeleton: Skeleton): Mesh;
  88723. /**
  88724. * 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
  88725. * @param meshes defines the list of meshes to scan
  88726. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88727. */
  88728. static MinMax(meshes: AbstractMesh[]): {
  88729. min: Vector3;
  88730. max: Vector3;
  88731. };
  88732. /**
  88733. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88734. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88735. * @returns a vector3
  88736. */
  88737. static Center(meshesOrMinMaxVector: {
  88738. min: Vector3;
  88739. max: Vector3;
  88740. } | AbstractMesh[]): Vector3;
  88741. /**
  88742. * Merge the array of meshes into a single mesh for performance reasons.
  88743. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88744. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88745. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88746. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88747. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88748. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88749. * @returns a new mesh
  88750. */
  88751. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  88752. /** @hidden */
  88753. addInstance(instance: InstancedMesh): void;
  88754. /** @hidden */
  88755. removeInstance(instance: InstancedMesh): void;
  88756. }
  88757. }
  88758. declare module BABYLON {
  88759. /**
  88760. * This is the base class of all the camera used in the application.
  88761. * @see http://doc.babylonjs.com/features/cameras
  88762. */
  88763. export class Camera extends Node {
  88764. /** @hidden */
  88765. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88766. /**
  88767. * This is the default projection mode used by the cameras.
  88768. * It helps recreating a feeling of perspective and better appreciate depth.
  88769. * This is the best way to simulate real life cameras.
  88770. */
  88771. static readonly PERSPECTIVE_CAMERA: number;
  88772. /**
  88773. * This helps creating camera with an orthographic mode.
  88774. * 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.
  88775. */
  88776. static readonly ORTHOGRAPHIC_CAMERA: number;
  88777. /**
  88778. * This is the default FOV mode for perspective cameras.
  88779. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88780. */
  88781. static readonly FOVMODE_VERTICAL_FIXED: number;
  88782. /**
  88783. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88784. */
  88785. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88786. /**
  88787. * This specifies ther is no need for a camera rig.
  88788. * Basically only one eye is rendered corresponding to the camera.
  88789. */
  88790. static readonly RIG_MODE_NONE: number;
  88791. /**
  88792. * Simulates a camera Rig with one blue eye and one red eye.
  88793. * This can be use with 3d blue and red glasses.
  88794. */
  88795. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88796. /**
  88797. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88798. */
  88799. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88800. /**
  88801. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88802. */
  88803. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88804. /**
  88805. * Defines that both eyes of the camera will be rendered over under each other.
  88806. */
  88807. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88808. /**
  88809. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88810. */
  88811. static readonly RIG_MODE_VR: number;
  88812. /**
  88813. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88814. */
  88815. static readonly RIG_MODE_WEBVR: number;
  88816. /**
  88817. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88818. */
  88819. static readonly RIG_MODE_CUSTOM: number;
  88820. /**
  88821. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88822. */
  88823. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88824. /**
  88825. * Define the input manager associated with the camera.
  88826. */
  88827. inputs: CameraInputsManager<Camera>;
  88828. /** @hidden */
  88829. _position: Vector3;
  88830. /**
  88831. * Define the current local position of the camera in the scene
  88832. */
  88833. position: Vector3;
  88834. /**
  88835. * The vector the camera should consider as up.
  88836. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88837. */
  88838. upVector: Vector3;
  88839. /**
  88840. * Define the current limit on the left side for an orthographic camera
  88841. * In scene unit
  88842. */
  88843. orthoLeft: Nullable<number>;
  88844. /**
  88845. * Define the current limit on the right side for an orthographic camera
  88846. * In scene unit
  88847. */
  88848. orthoRight: Nullable<number>;
  88849. /**
  88850. * Define the current limit on the bottom side for an orthographic camera
  88851. * In scene unit
  88852. */
  88853. orthoBottom: Nullable<number>;
  88854. /**
  88855. * Define the current limit on the top side for an orthographic camera
  88856. * In scene unit
  88857. */
  88858. orthoTop: Nullable<number>;
  88859. /**
  88860. * Field Of View is set in Radians. (default is 0.8)
  88861. */
  88862. fov: number;
  88863. /**
  88864. * Define the minimum distance the camera can see from.
  88865. * This is important to note that the depth buffer are not infinite and the closer it starts
  88866. * the more your scene might encounter depth fighting issue.
  88867. */
  88868. minZ: number;
  88869. /**
  88870. * Define the maximum distance the camera can see to.
  88871. * This is important to note that the depth buffer are not infinite and the further it end
  88872. * the more your scene might encounter depth fighting issue.
  88873. */
  88874. maxZ: number;
  88875. /**
  88876. * Define the default inertia of the camera.
  88877. * This helps giving a smooth feeling to the camera movement.
  88878. */
  88879. inertia: number;
  88880. /**
  88881. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  88882. */
  88883. mode: number;
  88884. /**
  88885. * Define wether the camera is intermediate.
  88886. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88887. */
  88888. isIntermediate: boolean;
  88889. /**
  88890. * Define the viewport of the camera.
  88891. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88892. */
  88893. viewport: Viewport;
  88894. /**
  88895. * Restricts the camera to viewing objects with the same layerMask.
  88896. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88897. */
  88898. layerMask: number;
  88899. /**
  88900. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88901. */
  88902. fovMode: number;
  88903. /**
  88904. * Rig mode of the camera.
  88905. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88906. * This is normally controlled byt the camera themselves as internal use.
  88907. */
  88908. cameraRigMode: number;
  88909. /**
  88910. * Defines the distance between both "eyes" in case of a RIG
  88911. */
  88912. interaxialDistance: number;
  88913. /**
  88914. * Defines if stereoscopic rendering is done side by side or over under.
  88915. */
  88916. isStereoscopicSideBySide: boolean;
  88917. /**
  88918. * 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
  88919. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88920. * else in the scene. (Eg. security camera)
  88921. *
  88922. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  88923. */
  88924. customRenderTargets: RenderTargetTexture[];
  88925. /**
  88926. * When set, the camera will render to this render target instead of the default canvas
  88927. *
  88928. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  88929. */
  88930. outputRenderTarget: Nullable<RenderTargetTexture>;
  88931. /**
  88932. * Observable triggered when the camera view matrix has changed.
  88933. */
  88934. onViewMatrixChangedObservable: Observable<Camera>;
  88935. /**
  88936. * Observable triggered when the camera Projection matrix has changed.
  88937. */
  88938. onProjectionMatrixChangedObservable: Observable<Camera>;
  88939. /**
  88940. * Observable triggered when the inputs have been processed.
  88941. */
  88942. onAfterCheckInputsObservable: Observable<Camera>;
  88943. /**
  88944. * Observable triggered when reset has been called and applied to the camera.
  88945. */
  88946. onRestoreStateObservable: Observable<Camera>;
  88947. /** @hidden */
  88948. _cameraRigParams: any;
  88949. /** @hidden */
  88950. _rigCameras: Camera[];
  88951. /** @hidden */
  88952. _rigPostProcess: Nullable<PostProcess>;
  88953. protected _webvrViewMatrix: Matrix;
  88954. /** @hidden */
  88955. _skipRendering: boolean;
  88956. /** @hidden */
  88957. _projectionMatrix: Matrix;
  88958. /** @hidden */
  88959. _postProcesses: Nullable<PostProcess>[];
  88960. /** @hidden */
  88961. _activeMeshes: SmartArray<AbstractMesh>;
  88962. protected _globalPosition: Vector3;
  88963. /** @hidden */
  88964. _computedViewMatrix: Matrix;
  88965. private _doNotComputeProjectionMatrix;
  88966. private _transformMatrix;
  88967. private _frustumPlanes;
  88968. private _refreshFrustumPlanes;
  88969. private _storedFov;
  88970. private _stateStored;
  88971. /**
  88972. * Instantiates a new camera object.
  88973. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88974. * @see http://doc.babylonjs.com/features/cameras
  88975. * @param name Defines the name of the camera in the scene
  88976. * @param position Defines the position of the camera
  88977. * @param scene Defines the scene the camera belongs too
  88978. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88979. */
  88980. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88981. /**
  88982. * Store current camera state (fov, position, etc..)
  88983. * @returns the camera
  88984. */
  88985. storeState(): Camera;
  88986. /**
  88987. * Restores the camera state values if it has been stored. You must call storeState() first
  88988. */
  88989. protected _restoreStateValues(): boolean;
  88990. /**
  88991. * Restored camera state. You must call storeState() first.
  88992. * @returns true if restored and false otherwise
  88993. */
  88994. restoreState(): boolean;
  88995. /**
  88996. * Gets the class name of the camera.
  88997. * @returns the class name
  88998. */
  88999. getClassName(): string;
  89000. /** @hidden */
  89001. readonly _isCamera: boolean;
  89002. /**
  89003. * Gets a string representation of the camera useful for debug purpose.
  89004. * @param fullDetails Defines that a more verboe level of logging is required
  89005. * @returns the string representation
  89006. */
  89007. toString(fullDetails?: boolean): string;
  89008. /**
  89009. * Gets the current world space position of the camera.
  89010. */
  89011. readonly globalPosition: Vector3;
  89012. /**
  89013. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89014. * @returns the active meshe list
  89015. */
  89016. getActiveMeshes(): SmartArray<AbstractMesh>;
  89017. /**
  89018. * Check wether a mesh is part of the current active mesh list of the camera
  89019. * @param mesh Defines the mesh to check
  89020. * @returns true if active, false otherwise
  89021. */
  89022. isActiveMesh(mesh: Mesh): boolean;
  89023. /**
  89024. * Is this camera ready to be used/rendered
  89025. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89026. * @return true if the camera is ready
  89027. */
  89028. isReady(completeCheck?: boolean): boolean;
  89029. /** @hidden */
  89030. _initCache(): void;
  89031. /** @hidden */
  89032. _updateCache(ignoreParentClass?: boolean): void;
  89033. /** @hidden */
  89034. _isSynchronized(): boolean;
  89035. /** @hidden */
  89036. _isSynchronizedViewMatrix(): boolean;
  89037. /** @hidden */
  89038. _isSynchronizedProjectionMatrix(): boolean;
  89039. /**
  89040. * Attach the input controls to a specific dom element to get the input from.
  89041. * @param element Defines the element the controls should be listened from
  89042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89043. */
  89044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89045. /**
  89046. * Detach the current controls from the specified dom element.
  89047. * @param element Defines the element to stop listening the inputs from
  89048. */
  89049. detachControl(element: HTMLElement): void;
  89050. /**
  89051. * Update the camera state according to the different inputs gathered during the frame.
  89052. */
  89053. update(): void;
  89054. /** @hidden */
  89055. _checkInputs(): void;
  89056. /** @hidden */
  89057. readonly rigCameras: Camera[];
  89058. /**
  89059. * Gets the post process used by the rig cameras
  89060. */
  89061. readonly rigPostProcess: Nullable<PostProcess>;
  89062. /**
  89063. * Internal, gets the first post proces.
  89064. * @returns the first post process to be run on this camera.
  89065. */
  89066. _getFirstPostProcess(): Nullable<PostProcess>;
  89067. private _cascadePostProcessesToRigCams;
  89068. /**
  89069. * Attach a post process to the camera.
  89070. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89071. * @param postProcess The post process to attach to the camera
  89072. * @param insertAt The position of the post process in case several of them are in use in the scene
  89073. * @returns the position the post process has been inserted at
  89074. */
  89075. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89076. /**
  89077. * Detach a post process to the camera.
  89078. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89079. * @param postProcess The post process to detach from the camera
  89080. */
  89081. detachPostProcess(postProcess: PostProcess): void;
  89082. /**
  89083. * Gets the current world matrix of the camera
  89084. */
  89085. getWorldMatrix(): Matrix;
  89086. /** @hidden */
  89087. _getViewMatrix(): Matrix;
  89088. /**
  89089. * Gets the current view matrix of the camera.
  89090. * @param force forces the camera to recompute the matrix without looking at the cached state
  89091. * @returns the view matrix
  89092. */
  89093. getViewMatrix(force?: boolean): Matrix;
  89094. /**
  89095. * Freeze the projection matrix.
  89096. * It will prevent the cache check of the camera projection compute and can speed up perf
  89097. * if no parameter of the camera are meant to change
  89098. * @param projection Defines manually a projection if necessary
  89099. */
  89100. freezeProjectionMatrix(projection?: Matrix): void;
  89101. /**
  89102. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89103. */
  89104. unfreezeProjectionMatrix(): void;
  89105. /**
  89106. * Gets the current projection matrix of the camera.
  89107. * @param force forces the camera to recompute the matrix without looking at the cached state
  89108. * @returns the projection matrix
  89109. */
  89110. getProjectionMatrix(force?: boolean): Matrix;
  89111. /**
  89112. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89113. * @returns a Matrix
  89114. */
  89115. getTransformationMatrix(): Matrix;
  89116. private _updateFrustumPlanes;
  89117. /**
  89118. * Checks if a cullable object (mesh...) is in the camera frustum
  89119. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89120. * @param target The object to check
  89121. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  89122. * @returns true if the object is in frustum otherwise false
  89123. */
  89124. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  89125. /**
  89126. * Checks if a cullable object (mesh...) is in the camera frustum
  89127. * Unlike isInFrustum this cheks the full bounding box
  89128. * @param target The object to check
  89129. * @returns true if the object is in frustum otherwise false
  89130. */
  89131. isCompletelyInFrustum(target: ICullable): boolean;
  89132. /**
  89133. * Gets a ray in the forward direction from the camera.
  89134. * @param length Defines the length of the ray to create
  89135. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89136. * @param origin Defines the start point of the ray which defaults to the camera position
  89137. * @returns the forward ray
  89138. */
  89139. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89140. /**
  89141. * Releases resources associated with this node.
  89142. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89143. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89144. */
  89145. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89146. /** @hidden */
  89147. _isLeftCamera: boolean;
  89148. /**
  89149. * Gets the left camera of a rig setup in case of Rigged Camera
  89150. */
  89151. readonly isLeftCamera: boolean;
  89152. /** @hidden */
  89153. _isRightCamera: boolean;
  89154. /**
  89155. * Gets the right camera of a rig setup in case of Rigged Camera
  89156. */
  89157. readonly isRightCamera: boolean;
  89158. /**
  89159. * Gets the left camera of a rig setup in case of Rigged Camera
  89160. */
  89161. readonly leftCamera: Nullable<FreeCamera>;
  89162. /**
  89163. * Gets the right camera of a rig setup in case of Rigged Camera
  89164. */
  89165. readonly rightCamera: Nullable<FreeCamera>;
  89166. /**
  89167. * Gets the left camera target of a rig setup in case of Rigged Camera
  89168. * @returns the target position
  89169. */
  89170. getLeftTarget(): Nullable<Vector3>;
  89171. /**
  89172. * Gets the right camera target of a rig setup in case of Rigged Camera
  89173. * @returns the target position
  89174. */
  89175. getRightTarget(): Nullable<Vector3>;
  89176. /**
  89177. * @hidden
  89178. */
  89179. setCameraRigMode(mode: number, rigParams: any): void;
  89180. /** @hidden */
  89181. static _setStereoscopicRigMode(camera: Camera): void;
  89182. /** @hidden */
  89183. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89184. /** @hidden */
  89185. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89186. /** @hidden */
  89187. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89188. /** @hidden */
  89189. _getVRProjectionMatrix(): Matrix;
  89190. protected _updateCameraRotationMatrix(): void;
  89191. protected _updateWebVRCameraRotationMatrix(): void;
  89192. /**
  89193. * This function MUST be overwritten by the different WebVR cameras available.
  89194. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89195. * @hidden
  89196. */
  89197. _getWebVRProjectionMatrix(): Matrix;
  89198. /**
  89199. * This function MUST be overwritten by the different WebVR cameras available.
  89200. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89201. * @hidden
  89202. */
  89203. _getWebVRViewMatrix(): Matrix;
  89204. /** @hidden */
  89205. setCameraRigParameter(name: string, value: any): void;
  89206. /**
  89207. * needs to be overridden by children so sub has required properties to be copied
  89208. * @hidden
  89209. */
  89210. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89211. /**
  89212. * May need to be overridden by children
  89213. * @hidden
  89214. */
  89215. _updateRigCameras(): void;
  89216. /** @hidden */
  89217. _setupInputs(): void;
  89218. /**
  89219. * Serialiaze the camera setup to a json represention
  89220. * @returns the JSON representation
  89221. */
  89222. serialize(): any;
  89223. /**
  89224. * Clones the current camera.
  89225. * @param name The cloned camera name
  89226. * @returns the cloned camera
  89227. */
  89228. clone(name: string): Camera;
  89229. /**
  89230. * Gets the direction of the camera relative to a given local axis.
  89231. * @param localAxis Defines the reference axis to provide a relative direction.
  89232. * @return the direction
  89233. */
  89234. getDirection(localAxis: Vector3): Vector3;
  89235. /**
  89236. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89237. * @param localAxis Defines the reference axis to provide a relative direction.
  89238. * @param result Defines the vector to store the result in
  89239. */
  89240. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89241. /**
  89242. * Gets a camera constructor for a given camera type
  89243. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89244. * @param name The name of the camera the result will be able to instantiate
  89245. * @param scene The scene the result will construct the camera in
  89246. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89247. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89248. * @returns a factory method to construc the camera
  89249. */
  89250. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89251. /**
  89252. * Compute the world matrix of the camera.
  89253. * @returns the camera workd matrix
  89254. */
  89255. computeWorldMatrix(): Matrix;
  89256. /**
  89257. * Parse a JSON and creates the camera from the parsed information
  89258. * @param parsedCamera The JSON to parse
  89259. * @param scene The scene to instantiate the camera in
  89260. * @returns the newly constructed camera
  89261. */
  89262. static Parse(parsedCamera: any, scene: Scene): Camera;
  89263. }
  89264. }
  89265. declare module BABYLON {
  89266. /**
  89267. * Class containing static functions to help procedurally build meshes
  89268. */
  89269. export class DiscBuilder {
  89270. /**
  89271. * Creates a plane polygonal mesh. By default, this is a disc
  89272. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  89273. * * 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
  89274. * * 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
  89275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89278. * @param name defines the name of the mesh
  89279. * @param options defines the options used to create the mesh
  89280. * @param scene defines the hosting scene
  89281. * @returns the plane polygonal mesh
  89282. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  89283. */
  89284. static CreateDisc(name: string, options: {
  89285. radius?: number;
  89286. tessellation?: number;
  89287. arc?: number;
  89288. updatable?: boolean;
  89289. sideOrientation?: number;
  89290. frontUVs?: Vector4;
  89291. backUVs?: Vector4;
  89292. }, scene?: Nullable<Scene>): Mesh;
  89293. }
  89294. }
  89295. declare module BABYLON {
  89296. /**
  89297. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  89298. *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.
  89299. * The SPS is also a particle system. It provides some methods to manage the particles.
  89300. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  89301. *
  89302. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  89303. */
  89304. export class SolidParticleSystem implements IDisposable {
  89305. /**
  89306. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  89307. * Example : var p = SPS.particles[i];
  89308. */
  89309. particles: SolidParticle[];
  89310. /**
  89311. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  89312. */
  89313. nbParticles: number;
  89314. /**
  89315. * If the particles must ever face the camera (default false). Useful for planar particles.
  89316. */
  89317. billboard: boolean;
  89318. /**
  89319. * Recompute normals when adding a shape
  89320. */
  89321. recomputeNormals: boolean;
  89322. /**
  89323. * This a counter ofr your own usage. It's not set by any SPS functions.
  89324. */
  89325. counter: number;
  89326. /**
  89327. * The SPS name. This name is also given to the underlying mesh.
  89328. */
  89329. name: string;
  89330. /**
  89331. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  89332. */
  89333. mesh: Mesh;
  89334. /**
  89335. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  89336. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  89337. */
  89338. vars: any;
  89339. /**
  89340. * This array is populated when the SPS is set as 'pickable'.
  89341. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  89342. * Each element of this array is an object `{idx: int, faceId: int}`.
  89343. * `idx` is the picked particle index in the `SPS.particles` array
  89344. * `faceId` is the picked face index counted within this particle.
  89345. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  89346. */
  89347. pickedParticles: {
  89348. idx: number;
  89349. faceId: number;
  89350. }[];
  89351. /**
  89352. * This array is populated when `enableDepthSort` is set to true.
  89353. * Each element of this array is an instance of the class DepthSortedParticle.
  89354. */
  89355. depthSortedParticles: DepthSortedParticle[];
  89356. /**
  89357. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  89358. * @hidden
  89359. */
  89360. _bSphereOnly: boolean;
  89361. /**
  89362. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  89363. * @hidden
  89364. */
  89365. _bSphereRadiusFactor: number;
  89366. private _scene;
  89367. private _positions;
  89368. private _indices;
  89369. private _normals;
  89370. private _colors;
  89371. private _uvs;
  89372. private _indices32;
  89373. private _positions32;
  89374. private _normals32;
  89375. private _fixedNormal32;
  89376. private _colors32;
  89377. private _uvs32;
  89378. private _index;
  89379. private _updatable;
  89380. private _pickable;
  89381. private _isVisibilityBoxLocked;
  89382. private _alwaysVisible;
  89383. private _depthSort;
  89384. private _shapeCounter;
  89385. private _copy;
  89386. private _color;
  89387. private _computeParticleColor;
  89388. private _computeParticleTexture;
  89389. private _computeParticleRotation;
  89390. private _computeParticleVertex;
  89391. private _computeBoundingBox;
  89392. private _depthSortParticles;
  89393. private _camera;
  89394. private _mustUnrotateFixedNormals;
  89395. private _particlesIntersect;
  89396. private _needs32Bits;
  89397. /**
  89398. * Creates a SPS (Solid Particle System) object.
  89399. * @param name (String) is the SPS name, this will be the underlying mesh name.
  89400. * @param scene (Scene) is the scene in which the SPS is added.
  89401. * @param options defines the options of the sps e.g.
  89402. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  89403. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  89404. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  89405. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  89406. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  89407. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  89408. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  89409. */
  89410. constructor(name: string, scene: Scene, options?: {
  89411. updatable?: boolean;
  89412. isPickable?: boolean;
  89413. enableDepthSort?: boolean;
  89414. particleIntersection?: boolean;
  89415. boundingSphereOnly?: boolean;
  89416. bSphereRadiusFactor?: number;
  89417. });
  89418. /**
  89419. * Builds the SPS underlying mesh. Returns a standard Mesh.
  89420. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  89421. * @returns the created mesh
  89422. */
  89423. buildMesh(): Mesh;
  89424. /**
  89425. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  89426. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  89427. * Thus the particles generated from `digest()` have their property `position` set yet.
  89428. * @param mesh ( Mesh ) is the mesh to be digested
  89429. * @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
  89430. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  89431. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  89432. * @returns the current SPS
  89433. */
  89434. digest(mesh: Mesh, options?: {
  89435. facetNb?: number;
  89436. number?: number;
  89437. delta?: number;
  89438. }): SolidParticleSystem;
  89439. private _unrotateFixedNormals;
  89440. private _resetCopy;
  89441. private _meshBuilder;
  89442. private _posToShape;
  89443. private _uvsToShapeUV;
  89444. private _addParticle;
  89445. /**
  89446. * Adds some particles to the SPS from the model shape. Returns the shape id.
  89447. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  89448. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  89449. * @param nb (positive integer) the number of particles to be created from this model
  89450. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  89451. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  89452. * @returns the number of shapes in the system
  89453. */
  89454. addShape(mesh: Mesh, nb: number, options?: {
  89455. positionFunction?: any;
  89456. vertexFunction?: any;
  89457. }): number;
  89458. private _rebuildParticle;
  89459. /**
  89460. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  89461. * @returns the SPS.
  89462. */
  89463. rebuildMesh(): SolidParticleSystem;
  89464. /**
  89465. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  89466. * This method calls `updateParticle()` for each particle of the SPS.
  89467. * For an animated SPS, it is usually called within the render loop.
  89468. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  89469. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  89470. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  89471. * @returns the SPS.
  89472. */
  89473. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  89474. /**
  89475. * Disposes the SPS.
  89476. */
  89477. dispose(): void;
  89478. /**
  89479. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  89480. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89481. * @returns the SPS.
  89482. */
  89483. refreshVisibleSize(): SolidParticleSystem;
  89484. /**
  89485. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  89486. * @param size the size (float) of the visibility box
  89487. * note : this doesn't lock the SPS mesh bounding box.
  89488. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89489. */
  89490. setVisibilityBox(size: number): void;
  89491. /**
  89492. * Gets whether the SPS as always visible or not
  89493. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89494. */
  89495. /**
  89496. * Sets the SPS as always visible or not
  89497. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89498. */
  89499. isAlwaysVisible: boolean;
  89500. /**
  89501. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89502. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89503. */
  89504. /**
  89505. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89506. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89507. */
  89508. isVisibilityBoxLocked: boolean;
  89509. /**
  89510. * Tells to `setParticles()` to compute the particle rotations or not.
  89511. * Default value : true. The SPS is faster when it's set to false.
  89512. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89513. */
  89514. /**
  89515. * Gets if `setParticles()` computes the particle rotations or not.
  89516. * Default value : true. The SPS is faster when it's set to false.
  89517. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89518. */
  89519. computeParticleRotation: boolean;
  89520. /**
  89521. * Tells to `setParticles()` to compute the particle colors or not.
  89522. * Default value : true. The SPS is faster when it's set to false.
  89523. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89524. */
  89525. /**
  89526. * Gets if `setParticles()` computes the particle colors or not.
  89527. * Default value : true. The SPS is faster when it's set to false.
  89528. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89529. */
  89530. computeParticleColor: boolean;
  89531. /**
  89532. * Gets if `setParticles()` computes the particle textures or not.
  89533. * Default value : true. The SPS is faster when it's set to false.
  89534. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  89535. */
  89536. computeParticleTexture: boolean;
  89537. /**
  89538. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  89539. * Default value : false. The SPS is faster when it's set to false.
  89540. * Note : the particle custom vertex positions aren't stored values.
  89541. */
  89542. /**
  89543. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  89544. * Default value : false. The SPS is faster when it's set to false.
  89545. * Note : the particle custom vertex positions aren't stored values.
  89546. */
  89547. computeParticleVertex: boolean;
  89548. /**
  89549. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  89550. */
  89551. /**
  89552. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  89553. */
  89554. computeBoundingBox: boolean;
  89555. /**
  89556. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  89557. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89558. * Default : `true`
  89559. */
  89560. /**
  89561. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  89562. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89563. * Default : `true`
  89564. */
  89565. depthSortParticles: boolean;
  89566. /**
  89567. * This function does nothing. It may be overwritten to set all the particle first values.
  89568. * The SPS doesn't call this function, you may have to call it by your own.
  89569. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89570. */
  89571. initParticles(): void;
  89572. /**
  89573. * This function does nothing. It may be overwritten to recycle a particle.
  89574. * The SPS doesn't call this function, you may have to call it by your own.
  89575. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89576. * @param particle The particle to recycle
  89577. * @returns the recycled particle
  89578. */
  89579. recycleParticle(particle: SolidParticle): SolidParticle;
  89580. /**
  89581. * Updates a particle : this function should be overwritten by the user.
  89582. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  89583. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89584. * @example : just set a particle position or velocity and recycle conditions
  89585. * @param particle The particle to update
  89586. * @returns the updated particle
  89587. */
  89588. updateParticle(particle: SolidParticle): SolidParticle;
  89589. /**
  89590. * Updates a vertex of a particle : it can be overwritten by the user.
  89591. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  89592. * @param particle the current particle
  89593. * @param vertex the current index of the current particle
  89594. * @param pt the index of the current vertex in the particle shape
  89595. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  89596. * @example : just set a vertex particle position
  89597. * @returns the updated vertex
  89598. */
  89599. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  89600. /**
  89601. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  89602. * This does nothing and may be overwritten by the user.
  89603. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89604. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89605. * @param update the boolean update value actually passed to setParticles()
  89606. */
  89607. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89608. /**
  89609. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  89610. * This will be passed three parameters.
  89611. * This does nothing and may be overwritten by the user.
  89612. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89613. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89614. * @param update the boolean update value actually passed to setParticles()
  89615. */
  89616. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89617. }
  89618. }
  89619. declare module BABYLON {
  89620. /**
  89621. * Represents one particle of a solid particle system.
  89622. */
  89623. export class SolidParticle {
  89624. /**
  89625. * particle global index
  89626. */
  89627. idx: number;
  89628. /**
  89629. * The color of the particle
  89630. */
  89631. color: Nullable<Color4>;
  89632. /**
  89633. * The world space position of the particle.
  89634. */
  89635. position: Vector3;
  89636. /**
  89637. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  89638. */
  89639. rotation: Vector3;
  89640. /**
  89641. * The world space rotation quaternion of the particle.
  89642. */
  89643. rotationQuaternion: Nullable<Quaternion>;
  89644. /**
  89645. * The scaling of the particle.
  89646. */
  89647. scaling: Vector3;
  89648. /**
  89649. * The uvs of the particle.
  89650. */
  89651. uvs: Vector4;
  89652. /**
  89653. * The current speed of the particle.
  89654. */
  89655. velocity: Vector3;
  89656. /**
  89657. * The pivot point in the particle local space.
  89658. */
  89659. pivot: Vector3;
  89660. /**
  89661. * Must the particle be translated from its pivot point in its local space ?
  89662. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89663. * Default : false
  89664. */
  89665. translateFromPivot: boolean;
  89666. /**
  89667. * Is the particle active or not ?
  89668. */
  89669. alive: boolean;
  89670. /**
  89671. * Is the particle visible or not ?
  89672. */
  89673. isVisible: boolean;
  89674. /**
  89675. * Index of this particle in the global "positions" array (Internal use)
  89676. * @hidden
  89677. */
  89678. _pos: number;
  89679. /**
  89680. * @hidden Index of this particle in the global "indices" array (Internal use)
  89681. */
  89682. _ind: number;
  89683. /**
  89684. * @hidden ModelShape of this particle (Internal use)
  89685. */
  89686. _model: ModelShape;
  89687. /**
  89688. * ModelShape id of this particle
  89689. */
  89690. shapeId: number;
  89691. /**
  89692. * Index of the particle in its shape id (Internal use)
  89693. */
  89694. idxInShape: number;
  89695. /**
  89696. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89697. */
  89698. _modelBoundingInfo: BoundingInfo;
  89699. /**
  89700. * @hidden Particle BoundingInfo object (Internal use)
  89701. */
  89702. _boundingInfo: BoundingInfo;
  89703. /**
  89704. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  89705. */
  89706. _sps: SolidParticleSystem;
  89707. /**
  89708. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  89709. */
  89710. _stillInvisible: boolean;
  89711. /**
  89712. * @hidden Last computed particle rotation matrix
  89713. */
  89714. _rotationMatrix: number[];
  89715. /**
  89716. * Parent particle Id, if any.
  89717. * Default null.
  89718. */
  89719. parentId: Nullable<number>;
  89720. /**
  89721. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  89722. * The possible values are :
  89723. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89724. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89725. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89726. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89727. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89728. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  89729. * */
  89730. cullingStrategy: number;
  89731. /**
  89732. * @hidden Internal global position in the SPS.
  89733. */
  89734. _globalPosition: Vector3;
  89735. /**
  89736. * Creates a Solid Particle object.
  89737. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  89738. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  89739. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  89740. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  89741. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  89742. * @param shapeId (integer) is the model shape identifier in the SPS.
  89743. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  89744. * @param sps defines the sps it is associated to
  89745. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  89746. */
  89747. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  89748. /**
  89749. * Legacy support, changed scale to scaling
  89750. */
  89751. /**
  89752. * Legacy support, changed scale to scaling
  89753. */
  89754. scale: Vector3;
  89755. /**
  89756. * Legacy support, changed quaternion to rotationQuaternion
  89757. */
  89758. /**
  89759. * Legacy support, changed quaternion to rotationQuaternion
  89760. */
  89761. quaternion: Nullable<Quaternion>;
  89762. /**
  89763. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89764. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89765. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89766. * @returns true if it intersects
  89767. */
  89768. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89769. /**
  89770. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89771. * A particle is in the frustum if its bounding box intersects the frustum
  89772. * @param frustumPlanes defines the frustum to test
  89773. * @returns true if the particle is in the frustum planes
  89774. */
  89775. isInFrustum(frustumPlanes: Plane[]): boolean;
  89776. /**
  89777. * get the rotation matrix of the particle
  89778. * @hidden
  89779. */
  89780. getRotationMatrix(m: Matrix): void;
  89781. }
  89782. /**
  89783. * Represents the shape of the model used by one particle of a solid particle system.
  89784. * SPS internal tool, don't use it manually.
  89785. */
  89786. export class ModelShape {
  89787. /**
  89788. * The shape id
  89789. * @hidden
  89790. */
  89791. shapeID: number;
  89792. /**
  89793. * flat array of model positions (internal use)
  89794. * @hidden
  89795. */
  89796. _shape: Vector3[];
  89797. /**
  89798. * flat array of model UVs (internal use)
  89799. * @hidden
  89800. */
  89801. _shapeUV: number[];
  89802. /**
  89803. * length of the shape in the model indices array (internal use)
  89804. * @hidden
  89805. */
  89806. _indicesLength: number;
  89807. /**
  89808. * Custom position function (internal use)
  89809. * @hidden
  89810. */
  89811. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89812. /**
  89813. * Custom vertex function (internal use)
  89814. * @hidden
  89815. */
  89816. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89817. /**
  89818. * 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.
  89819. * SPS internal tool, don't use it manually.
  89820. * @hidden
  89821. */
  89822. 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>);
  89823. }
  89824. /**
  89825. * Represents a Depth Sorted Particle in the solid particle system.
  89826. */
  89827. export class DepthSortedParticle {
  89828. /**
  89829. * Index of the particle in the "indices" array
  89830. */
  89831. ind: number;
  89832. /**
  89833. * Length of the particle shape in the "indices" array
  89834. */
  89835. indicesLength: number;
  89836. /**
  89837. * Squared distance from the particle to the camera
  89838. */
  89839. sqDistance: number;
  89840. }
  89841. }
  89842. declare module BABYLON {
  89843. /**
  89844. * @hidden
  89845. */
  89846. export class _MeshCollisionData {
  89847. _checkCollisions: boolean;
  89848. _collisionMask: number;
  89849. _collisionGroup: number;
  89850. _collider: Nullable<Collider>;
  89851. _oldPositionForCollisions: Vector3;
  89852. _diffPositionForCollisions: Vector3;
  89853. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  89854. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  89855. }
  89856. }
  89857. declare module BABYLON {
  89858. /** @hidden */
  89859. class _FacetDataStorage {
  89860. facetPositions: Vector3[];
  89861. facetNormals: Vector3[];
  89862. facetPartitioning: number[][];
  89863. facetNb: number;
  89864. partitioningSubdivisions: number;
  89865. partitioningBBoxRatio: number;
  89866. facetDataEnabled: boolean;
  89867. facetParameters: any;
  89868. bbSize: Vector3;
  89869. subDiv: {
  89870. max: number;
  89871. X: number;
  89872. Y: number;
  89873. Z: number;
  89874. };
  89875. facetDepthSort: boolean;
  89876. facetDepthSortEnabled: boolean;
  89877. depthSortedIndices: IndicesArray;
  89878. depthSortedFacets: {
  89879. ind: number;
  89880. sqDistance: number;
  89881. }[];
  89882. facetDepthSortFunction: (f1: {
  89883. ind: number;
  89884. sqDistance: number;
  89885. }, f2: {
  89886. ind: number;
  89887. sqDistance: number;
  89888. }) => number;
  89889. facetDepthSortFrom: Vector3;
  89890. facetDepthSortOrigin: Vector3;
  89891. invertedMatrix: Matrix;
  89892. }
  89893. /**
  89894. * @hidden
  89895. **/
  89896. class _InternalAbstractMeshDataInfo {
  89897. _hasVertexAlpha: boolean;
  89898. _useVertexColors: boolean;
  89899. _numBoneInfluencers: number;
  89900. _applyFog: boolean;
  89901. _receiveShadows: boolean;
  89902. _facetData: _FacetDataStorage;
  89903. _visibility: number;
  89904. _skeleton: Nullable<Skeleton>;
  89905. _layerMask: number;
  89906. _computeBonesUsingShaders: boolean;
  89907. _isActive: boolean;
  89908. _onlyForInstances: boolean;
  89909. _isActiveIntermediate: boolean;
  89910. _onlyForInstancesIntermediate: boolean;
  89911. }
  89912. /**
  89913. * Class used to store all common mesh properties
  89914. */
  89915. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  89916. /** No occlusion */
  89917. static OCCLUSION_TYPE_NONE: number;
  89918. /** Occlusion set to optimisitic */
  89919. static OCCLUSION_TYPE_OPTIMISTIC: number;
  89920. /** Occlusion set to strict */
  89921. static OCCLUSION_TYPE_STRICT: number;
  89922. /** Use an accurante occlusion algorithm */
  89923. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  89924. /** Use a conservative occlusion algorithm */
  89925. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  89926. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  89927. * Test order :
  89928. * Is the bounding sphere outside the frustum ?
  89929. * If not, are the bounding box vertices outside the frustum ?
  89930. * It not, then the cullable object is in the frustum.
  89931. */
  89932. static readonly CULLINGSTRATEGY_STANDARD: number;
  89933. /** Culling strategy : Bounding Sphere Only.
  89934. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  89935. * It's also less accurate than the standard because some not visible objects can still be selected.
  89936. * Test : is the bounding sphere outside the frustum ?
  89937. * If not, then the cullable object is in the frustum.
  89938. */
  89939. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  89940. /** Culling strategy : Optimistic Inclusion.
  89941. * This in an inclusion test first, then the standard exclusion test.
  89942. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  89943. * 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.
  89944. * Anyway, it's as accurate as the standard strategy.
  89945. * Test :
  89946. * Is the cullable object bounding sphere center in the frustum ?
  89947. * If not, apply the default culling strategy.
  89948. */
  89949. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  89950. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  89951. * This in an inclusion test first, then the bounding sphere only exclusion test.
  89952. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  89953. * 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.
  89954. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  89955. * Test :
  89956. * Is the cullable object bounding sphere center in the frustum ?
  89957. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  89958. */
  89959. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  89960. /**
  89961. * No billboard
  89962. */
  89963. static readonly BILLBOARDMODE_NONE: number;
  89964. /** Billboard on X axis */
  89965. static readonly BILLBOARDMODE_X: number;
  89966. /** Billboard on Y axis */
  89967. static readonly BILLBOARDMODE_Y: number;
  89968. /** Billboard on Z axis */
  89969. static readonly BILLBOARDMODE_Z: number;
  89970. /** Billboard on all axes */
  89971. static readonly BILLBOARDMODE_ALL: number;
  89972. /** Billboard on using position instead of orientation */
  89973. static readonly BILLBOARDMODE_USE_POSITION: number;
  89974. /** @hidden */
  89975. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  89976. /**
  89977. * The culling strategy to use to check whether the mesh must be rendered or not.
  89978. * This value can be changed at any time and will be used on the next render mesh selection.
  89979. * The possible values are :
  89980. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89981. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89982. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89983. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89984. * Please read each static variable documentation to get details about the culling process.
  89985. * */
  89986. cullingStrategy: number;
  89987. /**
  89988. * Gets the number of facets in the mesh
  89989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89990. */
  89991. readonly facetNb: number;
  89992. /**
  89993. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  89994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89995. */
  89996. partitioningSubdivisions: number;
  89997. /**
  89998. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  89999. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  90000. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90001. */
  90002. partitioningBBoxRatio: number;
  90003. /**
  90004. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  90005. * Works only for updatable meshes.
  90006. * Doesn't work with multi-materials
  90007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90008. */
  90009. mustDepthSortFacets: boolean;
  90010. /**
  90011. * The location (Vector3) where the facet depth sort must be computed from.
  90012. * By default, the active camera position.
  90013. * Used only when facet depth sort is enabled
  90014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90015. */
  90016. facetDepthSortFrom: Vector3;
  90017. /**
  90018. * gets a boolean indicating if facetData is enabled
  90019. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90020. */
  90021. readonly isFacetDataEnabled: boolean;
  90022. /** @hidden */
  90023. _updateNonUniformScalingState(value: boolean): boolean;
  90024. /**
  90025. * An event triggered when this mesh collides with another one
  90026. */
  90027. onCollideObservable: Observable<AbstractMesh>;
  90028. /** Set a function to call when this mesh collides with another one */
  90029. onCollide: () => void;
  90030. /**
  90031. * An event triggered when the collision's position changes
  90032. */
  90033. onCollisionPositionChangeObservable: Observable<Vector3>;
  90034. /** Set a function to call when the collision's position changes */
  90035. onCollisionPositionChange: () => void;
  90036. /**
  90037. * An event triggered when material is changed
  90038. */
  90039. onMaterialChangedObservable: Observable<AbstractMesh>;
  90040. /**
  90041. * Gets or sets the orientation for POV movement & rotation
  90042. */
  90043. definedFacingForward: boolean;
  90044. /** @hidden */
  90045. _occlusionQuery: Nullable<WebGLQuery>;
  90046. /** @hidden */
  90047. _renderingGroup: Nullable<RenderingGroup>;
  90048. /**
  90049. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90050. */
  90051. /**
  90052. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90053. */
  90054. visibility: number;
  90055. /** Gets or sets the alpha index used to sort transparent meshes
  90056. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  90057. */
  90058. alphaIndex: number;
  90059. /**
  90060. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  90061. */
  90062. isVisible: boolean;
  90063. /**
  90064. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90065. */
  90066. isPickable: boolean;
  90067. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  90068. showSubMeshesBoundingBox: boolean;
  90069. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  90070. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  90071. */
  90072. isBlocker: boolean;
  90073. /**
  90074. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  90075. */
  90076. enablePointerMoveEvents: boolean;
  90077. /**
  90078. * Specifies the rendering group id for this mesh (0 by default)
  90079. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90080. */
  90081. renderingGroupId: number;
  90082. private _material;
  90083. /** Gets or sets current material */
  90084. material: Nullable<Material>;
  90085. /**
  90086. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  90087. * @see http://doc.babylonjs.com/babylon101/shadows
  90088. */
  90089. receiveShadows: boolean;
  90090. /** Defines color to use when rendering outline */
  90091. outlineColor: Color3;
  90092. /** Define width to use when rendering outline */
  90093. outlineWidth: number;
  90094. /** Defines color to use when rendering overlay */
  90095. overlayColor: Color3;
  90096. /** Defines alpha to use when rendering overlay */
  90097. overlayAlpha: number;
  90098. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  90099. hasVertexAlpha: boolean;
  90100. /** 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) */
  90101. useVertexColors: boolean;
  90102. /**
  90103. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  90104. */
  90105. computeBonesUsingShaders: boolean;
  90106. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  90107. numBoneInfluencers: number;
  90108. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  90109. applyFog: boolean;
  90110. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  90111. useOctreeForRenderingSelection: boolean;
  90112. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  90113. useOctreeForPicking: boolean;
  90114. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  90115. useOctreeForCollisions: boolean;
  90116. /**
  90117. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  90118. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  90119. */
  90120. layerMask: number;
  90121. /**
  90122. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  90123. */
  90124. alwaysSelectAsActiveMesh: boolean;
  90125. /**
  90126. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  90127. */
  90128. doNotSyncBoundingInfo: boolean;
  90129. /**
  90130. * Gets or sets the current action manager
  90131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90132. */
  90133. actionManager: Nullable<AbstractActionManager>;
  90134. private _meshCollisionData;
  90135. /**
  90136. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  90137. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90138. */
  90139. ellipsoid: Vector3;
  90140. /**
  90141. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  90142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90143. */
  90144. ellipsoidOffset: Vector3;
  90145. /**
  90146. * Gets or sets a collision mask used to mask collisions (default is -1).
  90147. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90148. */
  90149. collisionMask: number;
  90150. /**
  90151. * Gets or sets the current collision group mask (-1 by default).
  90152. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90153. */
  90154. collisionGroup: number;
  90155. /**
  90156. * Defines edge width used when edgesRenderer is enabled
  90157. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90158. */
  90159. edgesWidth: number;
  90160. /**
  90161. * Defines edge color used when edgesRenderer is enabled
  90162. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90163. */
  90164. edgesColor: Color4;
  90165. /** @hidden */
  90166. _edgesRenderer: Nullable<IEdgesRenderer>;
  90167. /** @hidden */
  90168. _masterMesh: Nullable<AbstractMesh>;
  90169. /** @hidden */
  90170. _boundingInfo: Nullable<BoundingInfo>;
  90171. /** @hidden */
  90172. _renderId: number;
  90173. /**
  90174. * Gets or sets the list of subMeshes
  90175. * @see http://doc.babylonjs.com/how_to/multi_materials
  90176. */
  90177. subMeshes: SubMesh[];
  90178. /** @hidden */
  90179. _intersectionsInProgress: AbstractMesh[];
  90180. /** @hidden */
  90181. _unIndexed: boolean;
  90182. /** @hidden */
  90183. _lightSources: Light[];
  90184. /** Gets the list of lights affecting that mesh */
  90185. readonly lightSources: Light[];
  90186. /** @hidden */
  90187. readonly _positions: Nullable<Vector3[]>;
  90188. /** @hidden */
  90189. _waitingData: {
  90190. lods: Nullable<any>;
  90191. actions: Nullable<any>;
  90192. freezeWorldMatrix: Nullable<boolean>;
  90193. };
  90194. /** @hidden */
  90195. _bonesTransformMatrices: Nullable<Float32Array>;
  90196. /** @hidden */
  90197. _transformMatrixTexture: Nullable<RawTexture>;
  90198. /**
  90199. * Gets or sets a skeleton to apply skining transformations
  90200. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90201. */
  90202. skeleton: Nullable<Skeleton>;
  90203. /**
  90204. * An event triggered when the mesh is rebuilt.
  90205. */
  90206. onRebuildObservable: Observable<AbstractMesh>;
  90207. /**
  90208. * Creates a new AbstractMesh
  90209. * @param name defines the name of the mesh
  90210. * @param scene defines the hosting scene
  90211. */
  90212. constructor(name: string, scene?: Nullable<Scene>);
  90213. /**
  90214. * Returns the string "AbstractMesh"
  90215. * @returns "AbstractMesh"
  90216. */
  90217. getClassName(): string;
  90218. /**
  90219. * Gets a string representation of the current mesh
  90220. * @param fullDetails defines a boolean indicating if full details must be included
  90221. * @returns a string representation of the current mesh
  90222. */
  90223. toString(fullDetails?: boolean): string;
  90224. /**
  90225. * @hidden
  90226. */
  90227. protected _getEffectiveParent(): Nullable<Node>;
  90228. /** @hidden */
  90229. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90230. /** @hidden */
  90231. _rebuild(): void;
  90232. /** @hidden */
  90233. _resyncLightSources(): void;
  90234. /** @hidden */
  90235. _resyncLighSource(light: Light): void;
  90236. /** @hidden */
  90237. _unBindEffect(): void;
  90238. /** @hidden */
  90239. _removeLightSource(light: Light): void;
  90240. private _markSubMeshesAsDirty;
  90241. /** @hidden */
  90242. _markSubMeshesAsLightDirty(): void;
  90243. /** @hidden */
  90244. _markSubMeshesAsAttributesDirty(): void;
  90245. /** @hidden */
  90246. _markSubMeshesAsMiscDirty(): void;
  90247. /**
  90248. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  90249. */
  90250. scaling: Vector3;
  90251. /**
  90252. * Returns true if the mesh is blocked. Implemented by child classes
  90253. */
  90254. readonly isBlocked: boolean;
  90255. /**
  90256. * Returns the mesh itself by default. Implemented by child classes
  90257. * @param camera defines the camera to use to pick the right LOD level
  90258. * @returns the currentAbstractMesh
  90259. */
  90260. getLOD(camera: Camera): Nullable<AbstractMesh>;
  90261. /**
  90262. * Returns 0 by default. Implemented by child classes
  90263. * @returns an integer
  90264. */
  90265. getTotalVertices(): number;
  90266. /**
  90267. * Returns a positive integer : the total number of indices in this mesh geometry.
  90268. * @returns the numner of indices or zero if the mesh has no geometry.
  90269. */
  90270. getTotalIndices(): number;
  90271. /**
  90272. * Returns null by default. Implemented by child classes
  90273. * @returns null
  90274. */
  90275. getIndices(): Nullable<IndicesArray>;
  90276. /**
  90277. * Returns the array of the requested vertex data kind. Implemented by child classes
  90278. * @param kind defines the vertex data kind to use
  90279. * @returns null
  90280. */
  90281. getVerticesData(kind: string): Nullable<FloatArray>;
  90282. /**
  90283. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90284. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90285. * Note that a new underlying VertexBuffer object is created each call.
  90286. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90287. * @param kind defines vertex data kind:
  90288. * * VertexBuffer.PositionKind
  90289. * * VertexBuffer.UVKind
  90290. * * VertexBuffer.UV2Kind
  90291. * * VertexBuffer.UV3Kind
  90292. * * VertexBuffer.UV4Kind
  90293. * * VertexBuffer.UV5Kind
  90294. * * VertexBuffer.UV6Kind
  90295. * * VertexBuffer.ColorKind
  90296. * * VertexBuffer.MatricesIndicesKind
  90297. * * VertexBuffer.MatricesIndicesExtraKind
  90298. * * VertexBuffer.MatricesWeightsKind
  90299. * * VertexBuffer.MatricesWeightsExtraKind
  90300. * @param data defines the data source
  90301. * @param updatable defines if the data must be flagged as updatable (or static)
  90302. * @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
  90303. * @returns the current mesh
  90304. */
  90305. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90306. /**
  90307. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90308. * If the mesh has no geometry, it is simply returned as it is.
  90309. * @param kind defines vertex data kind:
  90310. * * VertexBuffer.PositionKind
  90311. * * VertexBuffer.UVKind
  90312. * * VertexBuffer.UV2Kind
  90313. * * VertexBuffer.UV3Kind
  90314. * * VertexBuffer.UV4Kind
  90315. * * VertexBuffer.UV5Kind
  90316. * * VertexBuffer.UV6Kind
  90317. * * VertexBuffer.ColorKind
  90318. * * VertexBuffer.MatricesIndicesKind
  90319. * * VertexBuffer.MatricesIndicesExtraKind
  90320. * * VertexBuffer.MatricesWeightsKind
  90321. * * VertexBuffer.MatricesWeightsExtraKind
  90322. * @param data defines the data source
  90323. * @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
  90324. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  90325. * @returns the current mesh
  90326. */
  90327. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90328. /**
  90329. * Sets the mesh indices,
  90330. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90331. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  90332. * @param totalVertices Defines the total number of vertices
  90333. * @returns the current mesh
  90334. */
  90335. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  90336. /**
  90337. * Gets a boolean indicating if specific vertex data is present
  90338. * @param kind defines the vertex data kind to use
  90339. * @returns true is data kind is present
  90340. */
  90341. isVerticesDataPresent(kind: string): boolean;
  90342. /**
  90343. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  90344. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  90345. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  90346. * @returns a BoundingInfo
  90347. */
  90348. getBoundingInfo(): BoundingInfo;
  90349. /**
  90350. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90351. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90352. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90353. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90354. * @returns the current mesh
  90355. */
  90356. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  90357. /**
  90358. * Overwrite the current bounding info
  90359. * @param boundingInfo defines the new bounding info
  90360. * @returns the current mesh
  90361. */
  90362. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  90363. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  90364. readonly useBones: boolean;
  90365. /** @hidden */
  90366. _preActivate(): void;
  90367. /** @hidden */
  90368. _preActivateForIntermediateRendering(renderId: number): void;
  90369. /** @hidden */
  90370. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90371. /** @hidden */
  90372. _postActivate(): void;
  90373. /** @hidden */
  90374. _freeze(): void;
  90375. /** @hidden */
  90376. _unFreeze(): void;
  90377. /**
  90378. * Gets the current world matrix
  90379. * @returns a Matrix
  90380. */
  90381. getWorldMatrix(): Matrix;
  90382. /** @hidden */
  90383. _getWorldMatrixDeterminant(): number;
  90384. /**
  90385. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  90386. */
  90387. readonly isAnInstance: boolean;
  90388. /**
  90389. * Perform relative position change from the point of view of behind the front of the mesh.
  90390. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90391. * Supports definition of mesh facing forward or backward
  90392. * @param amountRight defines the distance on the right axis
  90393. * @param amountUp defines the distance on the up axis
  90394. * @param amountForward defines the distance on the forward axis
  90395. * @returns the current mesh
  90396. */
  90397. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  90398. /**
  90399. * Calculate relative position change from the point of view of behind the front of the mesh.
  90400. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90401. * Supports definition of mesh facing forward or backward
  90402. * @param amountRight defines the distance on the right axis
  90403. * @param amountUp defines the distance on the up axis
  90404. * @param amountForward defines the distance on the forward axis
  90405. * @returns the new displacement vector
  90406. */
  90407. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  90408. /**
  90409. * Perform relative rotation change from the point of view of behind the front of the mesh.
  90410. * Supports definition of mesh facing forward or backward
  90411. * @param flipBack defines the flip
  90412. * @param twirlClockwise defines the twirl
  90413. * @param tiltRight defines the tilt
  90414. * @returns the current mesh
  90415. */
  90416. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  90417. /**
  90418. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  90419. * Supports definition of mesh facing forward or backward.
  90420. * @param flipBack defines the flip
  90421. * @param twirlClockwise defines the twirl
  90422. * @param tiltRight defines the tilt
  90423. * @returns the new rotation vector
  90424. */
  90425. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  90426. /**
  90427. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90428. * This means the mesh underlying bounding box and sphere are recomputed.
  90429. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90430. * @returns the current mesh
  90431. */
  90432. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  90433. /** @hidden */
  90434. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  90435. /** @hidden */
  90436. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  90437. /** @hidden */
  90438. _updateBoundingInfo(): AbstractMesh;
  90439. /** @hidden */
  90440. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  90441. /** @hidden */
  90442. protected _afterComputeWorldMatrix(): void;
  90443. /** @hidden */
  90444. readonly _effectiveMesh: AbstractMesh;
  90445. /**
  90446. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90447. * A mesh is in the frustum if its bounding box intersects the frustum
  90448. * @param frustumPlanes defines the frustum to test
  90449. * @returns true if the mesh is in the frustum planes
  90450. */
  90451. isInFrustum(frustumPlanes: Plane[]): boolean;
  90452. /**
  90453. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  90454. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  90455. * @param frustumPlanes defines the frustum to test
  90456. * @returns true if the mesh is completely in the frustum planes
  90457. */
  90458. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90459. /**
  90460. * True if the mesh intersects another mesh or a SolidParticle object
  90461. * @param mesh defines a target mesh or SolidParticle to test
  90462. * @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)
  90463. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  90464. * @returns true if there is an intersection
  90465. */
  90466. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  90467. /**
  90468. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  90469. * @param point defines the point to test
  90470. * @returns true if there is an intersection
  90471. */
  90472. intersectsPoint(point: Vector3): boolean;
  90473. /**
  90474. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  90475. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90476. */
  90477. checkCollisions: boolean;
  90478. /**
  90479. * Gets Collider object used to compute collisions (not physics)
  90480. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90481. */
  90482. readonly collider: Nullable<Collider>;
  90483. /**
  90484. * Move the mesh using collision engine
  90485. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90486. * @param displacement defines the requested displacement vector
  90487. * @returns the current mesh
  90488. */
  90489. moveWithCollisions(displacement: Vector3): AbstractMesh;
  90490. private _onCollisionPositionChange;
  90491. /** @hidden */
  90492. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  90493. /** @hidden */
  90494. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  90495. /** @hidden */
  90496. _checkCollision(collider: Collider): AbstractMesh;
  90497. /** @hidden */
  90498. _generatePointsArray(): boolean;
  90499. /**
  90500. * Checks if the passed Ray intersects with the mesh
  90501. * @param ray defines the ray to use
  90502. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  90503. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90504. * @returns the picking info
  90505. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  90506. */
  90507. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  90508. /**
  90509. * Clones the current mesh
  90510. * @param name defines the mesh name
  90511. * @param newParent defines the new mesh parent
  90512. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  90513. * @returns the new mesh
  90514. */
  90515. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90516. /**
  90517. * Disposes all the submeshes of the current meshnp
  90518. * @returns the current mesh
  90519. */
  90520. releaseSubMeshes(): AbstractMesh;
  90521. /**
  90522. * Releases resources associated with this abstract mesh.
  90523. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90524. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90525. */
  90526. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90527. /**
  90528. * Adds the passed mesh as a child to the current mesh
  90529. * @param mesh defines the child mesh
  90530. * @returns the current mesh
  90531. */
  90532. addChild(mesh: AbstractMesh): AbstractMesh;
  90533. /**
  90534. * Removes the passed mesh from the current mesh children list
  90535. * @param mesh defines the child mesh
  90536. * @returns the current mesh
  90537. */
  90538. removeChild(mesh: AbstractMesh): AbstractMesh;
  90539. /** @hidden */
  90540. private _initFacetData;
  90541. /**
  90542. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  90543. * This method can be called within the render loop.
  90544. * 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
  90545. * @returns the current mesh
  90546. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90547. */
  90548. updateFacetData(): AbstractMesh;
  90549. /**
  90550. * Returns the facetLocalNormals array.
  90551. * The normals are expressed in the mesh local spac
  90552. * @returns an array of Vector3
  90553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90554. */
  90555. getFacetLocalNormals(): Vector3[];
  90556. /**
  90557. * Returns the facetLocalPositions array.
  90558. * The facet positions are expressed in the mesh local space
  90559. * @returns an array of Vector3
  90560. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90561. */
  90562. getFacetLocalPositions(): Vector3[];
  90563. /**
  90564. * Returns the facetLocalPartioning array
  90565. * @returns an array of array of numbers
  90566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90567. */
  90568. getFacetLocalPartitioning(): number[][];
  90569. /**
  90570. * Returns the i-th facet position in the world system.
  90571. * This method allocates a new Vector3 per call
  90572. * @param i defines the facet index
  90573. * @returns a new Vector3
  90574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90575. */
  90576. getFacetPosition(i: number): Vector3;
  90577. /**
  90578. * Sets the reference Vector3 with the i-th facet position in the world system
  90579. * @param i defines the facet index
  90580. * @param ref defines the target vector
  90581. * @returns the current mesh
  90582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90583. */
  90584. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  90585. /**
  90586. * Returns the i-th facet normal in the world system.
  90587. * This method allocates a new Vector3 per call
  90588. * @param i defines the facet index
  90589. * @returns a new Vector3
  90590. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90591. */
  90592. getFacetNormal(i: number): Vector3;
  90593. /**
  90594. * Sets the reference Vector3 with the i-th facet normal in the world system
  90595. * @param i defines the facet index
  90596. * @param ref defines the target vector
  90597. * @returns the current mesh
  90598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90599. */
  90600. getFacetNormalToRef(i: number, ref: Vector3): this;
  90601. /**
  90602. * 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)
  90603. * @param x defines x coordinate
  90604. * @param y defines y coordinate
  90605. * @param z defines z coordinate
  90606. * @returns the array of facet indexes
  90607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90608. */
  90609. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  90610. /**
  90611. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  90612. * @param projected sets as the (x,y,z) world projection on the facet
  90613. * @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
  90614. * @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
  90615. * @param x defines x coordinate
  90616. * @param y defines y coordinate
  90617. * @param z defines z coordinate
  90618. * @returns the face index if found (or null instead)
  90619. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90620. */
  90621. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90622. /**
  90623. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  90624. * @param projected sets as the (x,y,z) local projection on the facet
  90625. * @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
  90626. * @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
  90627. * @param x defines x coordinate
  90628. * @param y defines y coordinate
  90629. * @param z defines z coordinate
  90630. * @returns the face index if found (or null instead)
  90631. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90632. */
  90633. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90634. /**
  90635. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  90636. * @returns the parameters
  90637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90638. */
  90639. getFacetDataParameters(): any;
  90640. /**
  90641. * Disables the feature FacetData and frees the related memory
  90642. * @returns the current mesh
  90643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90644. */
  90645. disableFacetData(): AbstractMesh;
  90646. /**
  90647. * Updates the AbstractMesh indices array
  90648. * @param indices defines the data source
  90649. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90650. * @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)
  90651. * @returns the current mesh
  90652. */
  90653. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90654. /**
  90655. * Creates new normals data for the mesh
  90656. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  90657. * @returns the current mesh
  90658. */
  90659. createNormals(updatable: boolean): AbstractMesh;
  90660. /**
  90661. * Align the mesh with a normal
  90662. * @param normal defines the normal to use
  90663. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90664. * @returns the current mesh
  90665. */
  90666. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90667. /** @hidden */
  90668. _checkOcclusionQuery(): boolean;
  90669. /**
  90670. * Disables the mesh edge rendering mode
  90671. * @returns the currentAbstractMesh
  90672. */
  90673. disableEdgesRendering(): AbstractMesh;
  90674. /**
  90675. * Enables the edge rendering mode on the mesh.
  90676. * This mode makes the mesh edges visible
  90677. * @param epsilon defines the maximal distance between two angles to detect a face
  90678. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90679. * @returns the currentAbstractMesh
  90680. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90681. */
  90682. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90683. }
  90684. }
  90685. declare module BABYLON {
  90686. /**
  90687. * Interface used to define ActionEvent
  90688. */
  90689. export interface IActionEvent {
  90690. /** The mesh or sprite that triggered the action */
  90691. source: any;
  90692. /** The X mouse cursor position at the time of the event */
  90693. pointerX: number;
  90694. /** The Y mouse cursor position at the time of the event */
  90695. pointerY: number;
  90696. /** The mesh that is currently pointed at (can be null) */
  90697. meshUnderPointer: Nullable<AbstractMesh>;
  90698. /** the original (browser) event that triggered the ActionEvent */
  90699. sourceEvent?: any;
  90700. /** additional data for the event */
  90701. additionalData?: any;
  90702. }
  90703. /**
  90704. * ActionEvent is the event being sent when an action is triggered.
  90705. */
  90706. export class ActionEvent implements IActionEvent {
  90707. /** The mesh or sprite that triggered the action */
  90708. source: any;
  90709. /** The X mouse cursor position at the time of the event */
  90710. pointerX: number;
  90711. /** The Y mouse cursor position at the time of the event */
  90712. pointerY: number;
  90713. /** The mesh that is currently pointed at (can be null) */
  90714. meshUnderPointer: Nullable<AbstractMesh>;
  90715. /** the original (browser) event that triggered the ActionEvent */
  90716. sourceEvent?: any;
  90717. /** additional data for the event */
  90718. additionalData?: any;
  90719. /**
  90720. * Creates a new ActionEvent
  90721. * @param source The mesh or sprite that triggered the action
  90722. * @param pointerX The X mouse cursor position at the time of the event
  90723. * @param pointerY The Y mouse cursor position at the time of the event
  90724. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  90725. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  90726. * @param additionalData additional data for the event
  90727. */
  90728. constructor(
  90729. /** The mesh or sprite that triggered the action */
  90730. source: any,
  90731. /** The X mouse cursor position at the time of the event */
  90732. pointerX: number,
  90733. /** The Y mouse cursor position at the time of the event */
  90734. pointerY: number,
  90735. /** The mesh that is currently pointed at (can be null) */
  90736. meshUnderPointer: Nullable<AbstractMesh>,
  90737. /** the original (browser) event that triggered the ActionEvent */
  90738. sourceEvent?: any,
  90739. /** additional data for the event */
  90740. additionalData?: any);
  90741. /**
  90742. * Helper function to auto-create an ActionEvent from a source mesh.
  90743. * @param source The source mesh that triggered the event
  90744. * @param evt The original (browser) event
  90745. * @param additionalData additional data for the event
  90746. * @returns the new ActionEvent
  90747. */
  90748. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  90749. /**
  90750. * Helper function to auto-create an ActionEvent from a source sprite
  90751. * @param source The source sprite that triggered the event
  90752. * @param scene Scene associated with the sprite
  90753. * @param evt The original (browser) event
  90754. * @param additionalData additional data for the event
  90755. * @returns the new ActionEvent
  90756. */
  90757. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  90758. /**
  90759. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90760. * @param scene the scene where the event occurred
  90761. * @param evt The original (browser) event
  90762. * @returns the new ActionEvent
  90763. */
  90764. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90765. /**
  90766. * Helper function to auto-create an ActionEvent from a primitive
  90767. * @param prim defines the target primitive
  90768. * @param pointerPos defines the pointer position
  90769. * @param evt The original (browser) event
  90770. * @param additionalData additional data for the event
  90771. * @returns the new ActionEvent
  90772. */
  90773. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90774. }
  90775. }
  90776. declare module BABYLON {
  90777. /**
  90778. * Abstract class used to decouple action Manager from scene and meshes.
  90779. * Do not instantiate.
  90780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90781. */
  90782. export abstract class AbstractActionManager implements IDisposable {
  90783. /** Gets the list of active triggers */
  90784. static Triggers: {
  90785. [key: string]: number;
  90786. };
  90787. /** Gets the cursor to use when hovering items */
  90788. hoverCursor: string;
  90789. /** Gets the list of actions */
  90790. actions: IAction[];
  90791. /**
  90792. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90793. */
  90794. isRecursive: boolean;
  90795. /**
  90796. * Releases all associated resources
  90797. */
  90798. abstract dispose(): void;
  90799. /**
  90800. * Does this action manager has pointer triggers
  90801. */
  90802. abstract readonly hasPointerTriggers: boolean;
  90803. /**
  90804. * Does this action manager has pick triggers
  90805. */
  90806. abstract readonly hasPickTriggers: boolean;
  90807. /**
  90808. * Process a specific trigger
  90809. * @param trigger defines the trigger to process
  90810. * @param evt defines the event details to be processed
  90811. */
  90812. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90813. /**
  90814. * Does this action manager handles actions of any of the given triggers
  90815. * @param triggers defines the triggers to be tested
  90816. * @return a boolean indicating whether one (or more) of the triggers is handled
  90817. */
  90818. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90819. /**
  90820. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90821. * speed.
  90822. * @param triggerA defines the trigger to be tested
  90823. * @param triggerB defines the trigger to be tested
  90824. * @return a boolean indicating whether one (or more) of the triggers is handled
  90825. */
  90826. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90827. /**
  90828. * Does this action manager handles actions of a given trigger
  90829. * @param trigger defines the trigger to be tested
  90830. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90831. * @return whether the trigger is handled
  90832. */
  90833. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90834. /**
  90835. * Serialize this manager to a JSON object
  90836. * @param name defines the property name to store this manager
  90837. * @returns a JSON representation of this manager
  90838. */
  90839. abstract serialize(name: string): any;
  90840. /**
  90841. * Registers an action to this action manager
  90842. * @param action defines the action to be registered
  90843. * @return the action amended (prepared) after registration
  90844. */
  90845. abstract registerAction(action: IAction): Nullable<IAction>;
  90846. /**
  90847. * Unregisters an action to this action manager
  90848. * @param action defines the action to be unregistered
  90849. * @return a boolean indicating whether the action has been unregistered
  90850. */
  90851. abstract unregisterAction(action: IAction): Boolean;
  90852. /**
  90853. * Does exist one action manager with at least one trigger
  90854. **/
  90855. static readonly HasTriggers: boolean;
  90856. /**
  90857. * Does exist one action manager with at least one pick trigger
  90858. **/
  90859. static readonly HasPickTriggers: boolean;
  90860. /**
  90861. * Does exist one action manager that handles actions of a given trigger
  90862. * @param trigger defines the trigger to be tested
  90863. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  90864. **/
  90865. static HasSpecificTrigger(trigger: number): boolean;
  90866. }
  90867. }
  90868. declare module BABYLON {
  90869. /**
  90870. * Defines how a node can be built from a string name.
  90871. */
  90872. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  90873. /**
  90874. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  90875. */
  90876. export class Node implements IBehaviorAware<Node> {
  90877. /** @hidden */
  90878. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  90879. private static _NodeConstructors;
  90880. /**
  90881. * Add a new node constructor
  90882. * @param type defines the type name of the node to construct
  90883. * @param constructorFunc defines the constructor function
  90884. */
  90885. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  90886. /**
  90887. * Returns a node constructor based on type name
  90888. * @param type defines the type name
  90889. * @param name defines the new node name
  90890. * @param scene defines the hosting scene
  90891. * @param options defines optional options to transmit to constructors
  90892. * @returns the new constructor or null
  90893. */
  90894. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  90895. /**
  90896. * Gets or sets the name of the node
  90897. */
  90898. name: string;
  90899. /**
  90900. * Gets or sets the id of the node
  90901. */
  90902. id: string;
  90903. /**
  90904. * Gets or sets the unique id of the node
  90905. */
  90906. uniqueId: number;
  90907. /**
  90908. * Gets or sets a string used to store user defined state for the node
  90909. */
  90910. state: string;
  90911. /**
  90912. * Gets or sets an object used to store user defined information for the node
  90913. */
  90914. metadata: any;
  90915. /**
  90916. * For internal use only. Please do not use.
  90917. */
  90918. reservedDataStore: any;
  90919. /**
  90920. * List of inspectable custom properties (used by the Inspector)
  90921. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90922. */
  90923. inspectableCustomProperties: IInspectable[];
  90924. /**
  90925. * Gets or sets a boolean used to define if the node must be serialized
  90926. */
  90927. doNotSerialize: boolean;
  90928. /** @hidden */
  90929. _isDisposed: boolean;
  90930. /**
  90931. * Gets a list of Animations associated with the node
  90932. */
  90933. animations: Animation[];
  90934. protected _ranges: {
  90935. [name: string]: Nullable<AnimationRange>;
  90936. };
  90937. /**
  90938. * Callback raised when the node is ready to be used
  90939. */
  90940. onReady: Nullable<(node: Node) => void>;
  90941. private _isEnabled;
  90942. private _isParentEnabled;
  90943. private _isReady;
  90944. /** @hidden */
  90945. _currentRenderId: number;
  90946. private _parentUpdateId;
  90947. /** @hidden */
  90948. _childUpdateId: number;
  90949. /** @hidden */
  90950. _waitingParentId: Nullable<string>;
  90951. /** @hidden */
  90952. _scene: Scene;
  90953. /** @hidden */
  90954. _cache: any;
  90955. private _parentNode;
  90956. private _children;
  90957. /** @hidden */
  90958. _worldMatrix: Matrix;
  90959. /** @hidden */
  90960. _worldMatrixDeterminant: number;
  90961. /** @hidden */
  90962. _worldMatrixDeterminantIsDirty: boolean;
  90963. /** @hidden */
  90964. private _sceneRootNodesIndex;
  90965. /**
  90966. * Gets a boolean indicating if the node has been disposed
  90967. * @returns true if the node was disposed
  90968. */
  90969. isDisposed(): boolean;
  90970. /**
  90971. * Gets or sets the parent of the node (without keeping the current position in the scene)
  90972. * @see https://doc.babylonjs.com/how_to/parenting
  90973. */
  90974. parent: Nullable<Node>;
  90975. private addToSceneRootNodes;
  90976. private removeFromSceneRootNodes;
  90977. private _animationPropertiesOverride;
  90978. /**
  90979. * Gets or sets the animation properties override
  90980. */
  90981. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90982. /**
  90983. * Gets a string idenfifying the name of the class
  90984. * @returns "Node" string
  90985. */
  90986. getClassName(): string;
  90987. /** @hidden */
  90988. readonly _isNode: boolean;
  90989. /**
  90990. * An event triggered when the mesh is disposed
  90991. */
  90992. onDisposeObservable: Observable<Node>;
  90993. private _onDisposeObserver;
  90994. /**
  90995. * Sets a callback that will be raised when the node will be disposed
  90996. */
  90997. onDispose: () => void;
  90998. /**
  90999. * Creates a new Node
  91000. * @param name the name and id to be given to this node
  91001. * @param scene the scene this node will be added to
  91002. * @param addToRootNodes the node will be added to scene.rootNodes
  91003. */
  91004. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  91005. /**
  91006. * Gets the scene of the node
  91007. * @returns a scene
  91008. */
  91009. getScene(): Scene;
  91010. /**
  91011. * Gets the engine of the node
  91012. * @returns a Engine
  91013. */
  91014. getEngine(): Engine;
  91015. private _behaviors;
  91016. /**
  91017. * Attach a behavior to the node
  91018. * @see http://doc.babylonjs.com/features/behaviour
  91019. * @param behavior defines the behavior to attach
  91020. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  91021. * @returns the current Node
  91022. */
  91023. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  91024. /**
  91025. * Remove an attached behavior
  91026. * @see http://doc.babylonjs.com/features/behaviour
  91027. * @param behavior defines the behavior to attach
  91028. * @returns the current Node
  91029. */
  91030. removeBehavior(behavior: Behavior<Node>): Node;
  91031. /**
  91032. * Gets the list of attached behaviors
  91033. * @see http://doc.babylonjs.com/features/behaviour
  91034. */
  91035. readonly behaviors: Behavior<Node>[];
  91036. /**
  91037. * Gets an attached behavior by name
  91038. * @param name defines the name of the behavior to look for
  91039. * @see http://doc.babylonjs.com/features/behaviour
  91040. * @returns null if behavior was not found else the requested behavior
  91041. */
  91042. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  91043. /**
  91044. * Returns the latest update of the World matrix
  91045. * @returns a Matrix
  91046. */
  91047. getWorldMatrix(): Matrix;
  91048. /** @hidden */
  91049. _getWorldMatrixDeterminant(): number;
  91050. /**
  91051. * Returns directly the latest state of the mesh World matrix.
  91052. * A Matrix is returned.
  91053. */
  91054. readonly worldMatrixFromCache: Matrix;
  91055. /** @hidden */
  91056. _initCache(): void;
  91057. /** @hidden */
  91058. updateCache(force?: boolean): void;
  91059. /** @hidden */
  91060. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91061. /** @hidden */
  91062. _updateCache(ignoreParentClass?: boolean): void;
  91063. /** @hidden */
  91064. _isSynchronized(): boolean;
  91065. /** @hidden */
  91066. _markSyncedWithParent(): void;
  91067. /** @hidden */
  91068. isSynchronizedWithParent(): boolean;
  91069. /** @hidden */
  91070. isSynchronized(): boolean;
  91071. /**
  91072. * Is this node ready to be used/rendered
  91073. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91074. * @return true if the node is ready
  91075. */
  91076. isReady(completeCheck?: boolean): boolean;
  91077. /**
  91078. * Is this node enabled?
  91079. * 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
  91080. * @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
  91081. * @return whether this node (and its parent) is enabled
  91082. */
  91083. isEnabled(checkAncestors?: boolean): boolean;
  91084. /** @hidden */
  91085. protected _syncParentEnabledState(): void;
  91086. /**
  91087. * Set the enabled state of this node
  91088. * @param value defines the new enabled state
  91089. */
  91090. setEnabled(value: boolean): void;
  91091. /**
  91092. * Is this node a descendant of the given node?
  91093. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  91094. * @param ancestor defines the parent node to inspect
  91095. * @returns a boolean indicating if this node is a descendant of the given node
  91096. */
  91097. isDescendantOf(ancestor: Node): boolean;
  91098. /** @hidden */
  91099. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  91100. /**
  91101. * Will return all nodes that have this node as ascendant
  91102. * @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
  91103. * @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
  91104. * @return all children nodes of all types
  91105. */
  91106. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  91107. /**
  91108. * Get all child-meshes of this node
  91109. * @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)
  91110. * @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
  91111. * @returns an array of AbstractMesh
  91112. */
  91113. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  91114. /**
  91115. * Get all direct children of this node
  91116. * @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
  91117. * @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)
  91118. * @returns an array of Node
  91119. */
  91120. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  91121. /** @hidden */
  91122. _setReady(state: boolean): void;
  91123. /**
  91124. * Get an animation by name
  91125. * @param name defines the name of the animation to look for
  91126. * @returns null if not found else the requested animation
  91127. */
  91128. getAnimationByName(name: string): Nullable<Animation>;
  91129. /**
  91130. * Creates an animation range for this node
  91131. * @param name defines the name of the range
  91132. * @param from defines the starting key
  91133. * @param to defines the end key
  91134. */
  91135. createAnimationRange(name: string, from: number, to: number): void;
  91136. /**
  91137. * Delete a specific animation range
  91138. * @param name defines the name of the range to delete
  91139. * @param deleteFrames defines if animation frames from the range must be deleted as well
  91140. */
  91141. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91142. /**
  91143. * Get an animation range by name
  91144. * @param name defines the name of the animation range to look for
  91145. * @returns null if not found else the requested animation range
  91146. */
  91147. getAnimationRange(name: string): Nullable<AnimationRange>;
  91148. /**
  91149. * Gets the list of all animation ranges defined on this node
  91150. * @returns an array
  91151. */
  91152. getAnimationRanges(): Nullable<AnimationRange>[];
  91153. /**
  91154. * Will start the animation sequence
  91155. * @param name defines the range frames for animation sequence
  91156. * @param loop defines if the animation should loop (false by default)
  91157. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  91158. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  91159. * @returns the object created for this animation. If range does not exist, it will return null
  91160. */
  91161. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91162. /**
  91163. * Serialize animation ranges into a JSON compatible object
  91164. * @returns serialization object
  91165. */
  91166. serializeAnimationRanges(): any;
  91167. /**
  91168. * Computes the world matrix of the node
  91169. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91170. * @returns the world matrix
  91171. */
  91172. computeWorldMatrix(force?: boolean): Matrix;
  91173. /**
  91174. * Releases resources associated with this node.
  91175. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91176. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91177. */
  91178. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91179. /**
  91180. * Parse animation range data from a serialization object and store them into a given node
  91181. * @param node defines where to store the animation ranges
  91182. * @param parsedNode defines the serialization object to read data from
  91183. * @param scene defines the hosting scene
  91184. */
  91185. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  91186. /**
  91187. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  91188. * @param includeDescendants Include bounding info from descendants as well (true by default)
  91189. * @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
  91190. * @returns the new bounding vectors
  91191. */
  91192. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  91193. min: Vector3;
  91194. max: Vector3;
  91195. };
  91196. }
  91197. }
  91198. declare module BABYLON {
  91199. /**
  91200. * @hidden
  91201. */
  91202. export class _IAnimationState {
  91203. key: number;
  91204. repeatCount: number;
  91205. workValue?: any;
  91206. loopMode?: number;
  91207. offsetValue?: any;
  91208. highLimitValue?: any;
  91209. }
  91210. /**
  91211. * Class used to store any kind of animation
  91212. */
  91213. export class Animation {
  91214. /**Name of the animation */
  91215. name: string;
  91216. /**Property to animate */
  91217. targetProperty: string;
  91218. /**The frames per second of the animation */
  91219. framePerSecond: number;
  91220. /**The data type of the animation */
  91221. dataType: number;
  91222. /**The loop mode of the animation */
  91223. loopMode?: number | undefined;
  91224. /**Specifies if blending should be enabled */
  91225. enableBlending?: boolean | undefined;
  91226. /**
  91227. * Use matrix interpolation instead of using direct key value when animating matrices
  91228. */
  91229. static AllowMatricesInterpolation: boolean;
  91230. /**
  91231. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  91232. */
  91233. static AllowMatrixDecomposeForInterpolation: boolean;
  91234. /**
  91235. * Stores the key frames of the animation
  91236. */
  91237. private _keys;
  91238. /**
  91239. * Stores the easing function of the animation
  91240. */
  91241. private _easingFunction;
  91242. /**
  91243. * @hidden Internal use only
  91244. */
  91245. _runtimeAnimations: RuntimeAnimation[];
  91246. /**
  91247. * The set of event that will be linked to this animation
  91248. */
  91249. private _events;
  91250. /**
  91251. * Stores an array of target property paths
  91252. */
  91253. targetPropertyPath: string[];
  91254. /**
  91255. * Stores the blending speed of the animation
  91256. */
  91257. blendingSpeed: number;
  91258. /**
  91259. * Stores the animation ranges for the animation
  91260. */
  91261. private _ranges;
  91262. /**
  91263. * @hidden Internal use
  91264. */
  91265. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  91266. /**
  91267. * Sets up an animation
  91268. * @param property The property to animate
  91269. * @param animationType The animation type to apply
  91270. * @param framePerSecond The frames per second of the animation
  91271. * @param easingFunction The easing function used in the animation
  91272. * @returns The created animation
  91273. */
  91274. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  91275. /**
  91276. * Create and start an animation on a node
  91277. * @param name defines the name of the global animation that will be run on all nodes
  91278. * @param node defines the root node where the animation will take place
  91279. * @param targetProperty defines property to animate
  91280. * @param framePerSecond defines the number of frame per second yo use
  91281. * @param totalFrame defines the number of frames in total
  91282. * @param from defines the initial value
  91283. * @param to defines the final value
  91284. * @param loopMode defines which loop mode you want to use (off by default)
  91285. * @param easingFunction defines the easing function to use (linear by default)
  91286. * @param onAnimationEnd defines the callback to call when animation end
  91287. * @returns the animatable created for this animation
  91288. */
  91289. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91290. /**
  91291. * Create and start an animation on a node and its descendants
  91292. * @param name defines the name of the global animation that will be run on all nodes
  91293. * @param node defines the root node where the animation will take place
  91294. * @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
  91295. * @param targetProperty defines property to animate
  91296. * @param framePerSecond defines the number of frame per second to use
  91297. * @param totalFrame defines the number of frames in total
  91298. * @param from defines the initial value
  91299. * @param to defines the final value
  91300. * @param loopMode defines which loop mode you want to use (off by default)
  91301. * @param easingFunction defines the easing function to use (linear by default)
  91302. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91303. * @returns the list of animatables created for all nodes
  91304. * @example https://www.babylonjs-playground.com/#MH0VLI
  91305. */
  91306. 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[]>;
  91307. /**
  91308. * Creates a new animation, merges it with the existing animations and starts it
  91309. * @param name Name of the animation
  91310. * @param node Node which contains the scene that begins the animations
  91311. * @param targetProperty Specifies which property to animate
  91312. * @param framePerSecond The frames per second of the animation
  91313. * @param totalFrame The total number of frames
  91314. * @param from The frame at the beginning of the animation
  91315. * @param to The frame at the end of the animation
  91316. * @param loopMode Specifies the loop mode of the animation
  91317. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  91318. * @param onAnimationEnd Callback to run once the animation is complete
  91319. * @returns Nullable animation
  91320. */
  91321. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91322. /**
  91323. * Transition property of an host to the target Value
  91324. * @param property The property to transition
  91325. * @param targetValue The target Value of the property
  91326. * @param host The object where the property to animate belongs
  91327. * @param scene Scene used to run the animation
  91328. * @param frameRate Framerate (in frame/s) to use
  91329. * @param transition The transition type we want to use
  91330. * @param duration The duration of the animation, in milliseconds
  91331. * @param onAnimationEnd Callback trigger at the end of the animation
  91332. * @returns Nullable animation
  91333. */
  91334. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  91335. /**
  91336. * Return the array of runtime animations currently using this animation
  91337. */
  91338. readonly runtimeAnimations: RuntimeAnimation[];
  91339. /**
  91340. * Specifies if any of the runtime animations are currently running
  91341. */
  91342. readonly hasRunningRuntimeAnimations: boolean;
  91343. /**
  91344. * Initializes the animation
  91345. * @param name Name of the animation
  91346. * @param targetProperty Property to animate
  91347. * @param framePerSecond The frames per second of the animation
  91348. * @param dataType The data type of the animation
  91349. * @param loopMode The loop mode of the animation
  91350. * @param enableBlending Specifies if blending should be enabled
  91351. */
  91352. constructor(
  91353. /**Name of the animation */
  91354. name: string,
  91355. /**Property to animate */
  91356. targetProperty: string,
  91357. /**The frames per second of the animation */
  91358. framePerSecond: number,
  91359. /**The data type of the animation */
  91360. dataType: number,
  91361. /**The loop mode of the animation */
  91362. loopMode?: number | undefined,
  91363. /**Specifies if blending should be enabled */
  91364. enableBlending?: boolean | undefined);
  91365. /**
  91366. * Converts the animation to a string
  91367. * @param fullDetails support for multiple levels of logging within scene loading
  91368. * @returns String form of the animation
  91369. */
  91370. toString(fullDetails?: boolean): string;
  91371. /**
  91372. * Add an event to this animation
  91373. * @param event Event to add
  91374. */
  91375. addEvent(event: AnimationEvent): void;
  91376. /**
  91377. * Remove all events found at the given frame
  91378. * @param frame The frame to remove events from
  91379. */
  91380. removeEvents(frame: number): void;
  91381. /**
  91382. * Retrieves all the events from the animation
  91383. * @returns Events from the animation
  91384. */
  91385. getEvents(): AnimationEvent[];
  91386. /**
  91387. * Creates an animation range
  91388. * @param name Name of the animation range
  91389. * @param from Starting frame of the animation range
  91390. * @param to Ending frame of the animation
  91391. */
  91392. createRange(name: string, from: number, to: number): void;
  91393. /**
  91394. * Deletes an animation range by name
  91395. * @param name Name of the animation range to delete
  91396. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  91397. */
  91398. deleteRange(name: string, deleteFrames?: boolean): void;
  91399. /**
  91400. * Gets the animation range by name, or null if not defined
  91401. * @param name Name of the animation range
  91402. * @returns Nullable animation range
  91403. */
  91404. getRange(name: string): Nullable<AnimationRange>;
  91405. /**
  91406. * Gets the key frames from the animation
  91407. * @returns The key frames of the animation
  91408. */
  91409. getKeys(): Array<IAnimationKey>;
  91410. /**
  91411. * Gets the highest frame rate of the animation
  91412. * @returns Highest frame rate of the animation
  91413. */
  91414. getHighestFrame(): number;
  91415. /**
  91416. * Gets the easing function of the animation
  91417. * @returns Easing function of the animation
  91418. */
  91419. getEasingFunction(): IEasingFunction;
  91420. /**
  91421. * Sets the easing function of the animation
  91422. * @param easingFunction A custom mathematical formula for animation
  91423. */
  91424. setEasingFunction(easingFunction: EasingFunction): void;
  91425. /**
  91426. * Interpolates a scalar linearly
  91427. * @param startValue Start value of the animation curve
  91428. * @param endValue End value of the animation curve
  91429. * @param gradient Scalar amount to interpolate
  91430. * @returns Interpolated scalar value
  91431. */
  91432. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  91433. /**
  91434. * Interpolates a scalar cubically
  91435. * @param startValue Start value of the animation curve
  91436. * @param outTangent End tangent of the animation
  91437. * @param endValue End value of the animation curve
  91438. * @param inTangent Start tangent of the animation curve
  91439. * @param gradient Scalar amount to interpolate
  91440. * @returns Interpolated scalar value
  91441. */
  91442. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  91443. /**
  91444. * Interpolates a quaternion using a spherical linear interpolation
  91445. * @param startValue Start value of the animation curve
  91446. * @param endValue End value of the animation curve
  91447. * @param gradient Scalar amount to interpolate
  91448. * @returns Interpolated quaternion value
  91449. */
  91450. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  91451. /**
  91452. * Interpolates a quaternion cubically
  91453. * @param startValue Start value of the animation curve
  91454. * @param outTangent End tangent of the animation curve
  91455. * @param endValue End value of the animation curve
  91456. * @param inTangent Start tangent of the animation curve
  91457. * @param gradient Scalar amount to interpolate
  91458. * @returns Interpolated quaternion value
  91459. */
  91460. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  91461. /**
  91462. * Interpolates a Vector3 linearl
  91463. * @param startValue Start value of the animation curve
  91464. * @param endValue End value of the animation curve
  91465. * @param gradient Scalar amount to interpolate
  91466. * @returns Interpolated scalar value
  91467. */
  91468. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  91469. /**
  91470. * Interpolates a Vector3 cubically
  91471. * @param startValue Start value of the animation curve
  91472. * @param outTangent End tangent of the animation
  91473. * @param endValue End value of the animation curve
  91474. * @param inTangent Start tangent of the animation curve
  91475. * @param gradient Scalar amount to interpolate
  91476. * @returns InterpolatedVector3 value
  91477. */
  91478. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  91479. /**
  91480. * Interpolates a Vector2 linearly
  91481. * @param startValue Start value of the animation curve
  91482. * @param endValue End value of the animation curve
  91483. * @param gradient Scalar amount to interpolate
  91484. * @returns Interpolated Vector2 value
  91485. */
  91486. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  91487. /**
  91488. * Interpolates a Vector2 cubically
  91489. * @param startValue Start value of the animation curve
  91490. * @param outTangent End tangent of the animation
  91491. * @param endValue End value of the animation curve
  91492. * @param inTangent Start tangent of the animation curve
  91493. * @param gradient Scalar amount to interpolate
  91494. * @returns Interpolated Vector2 value
  91495. */
  91496. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  91497. /**
  91498. * Interpolates a size linearly
  91499. * @param startValue Start value of the animation curve
  91500. * @param endValue End value of the animation curve
  91501. * @param gradient Scalar amount to interpolate
  91502. * @returns Interpolated Size value
  91503. */
  91504. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  91505. /**
  91506. * Interpolates a Color3 linearly
  91507. * @param startValue Start value of the animation curve
  91508. * @param endValue End value of the animation curve
  91509. * @param gradient Scalar amount to interpolate
  91510. * @returns Interpolated Color3 value
  91511. */
  91512. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  91513. /**
  91514. * @hidden Internal use only
  91515. */
  91516. _getKeyValue(value: any): any;
  91517. /**
  91518. * @hidden Internal use only
  91519. */
  91520. _interpolate(currentFrame: number, state: _IAnimationState): any;
  91521. /**
  91522. * Defines the function to use to interpolate matrices
  91523. * @param startValue defines the start matrix
  91524. * @param endValue defines the end matrix
  91525. * @param gradient defines the gradient between both matrices
  91526. * @param result defines an optional target matrix where to store the interpolation
  91527. * @returns the interpolated matrix
  91528. */
  91529. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  91530. /**
  91531. * Makes a copy of the animation
  91532. * @returns Cloned animation
  91533. */
  91534. clone(): Animation;
  91535. /**
  91536. * Sets the key frames of the animation
  91537. * @param values The animation key frames to set
  91538. */
  91539. setKeys(values: Array<IAnimationKey>): void;
  91540. /**
  91541. * Serializes the animation to an object
  91542. * @returns Serialized object
  91543. */
  91544. serialize(): any;
  91545. /**
  91546. * Float animation type
  91547. */
  91548. private static _ANIMATIONTYPE_FLOAT;
  91549. /**
  91550. * Vector3 animation type
  91551. */
  91552. private static _ANIMATIONTYPE_VECTOR3;
  91553. /**
  91554. * Quaternion animation type
  91555. */
  91556. private static _ANIMATIONTYPE_QUATERNION;
  91557. /**
  91558. * Matrix animation type
  91559. */
  91560. private static _ANIMATIONTYPE_MATRIX;
  91561. /**
  91562. * Color3 animation type
  91563. */
  91564. private static _ANIMATIONTYPE_COLOR3;
  91565. /**
  91566. * Vector2 animation type
  91567. */
  91568. private static _ANIMATIONTYPE_VECTOR2;
  91569. /**
  91570. * Size animation type
  91571. */
  91572. private static _ANIMATIONTYPE_SIZE;
  91573. /**
  91574. * Relative Loop Mode
  91575. */
  91576. private static _ANIMATIONLOOPMODE_RELATIVE;
  91577. /**
  91578. * Cycle Loop Mode
  91579. */
  91580. private static _ANIMATIONLOOPMODE_CYCLE;
  91581. /**
  91582. * Constant Loop Mode
  91583. */
  91584. private static _ANIMATIONLOOPMODE_CONSTANT;
  91585. /**
  91586. * Get the float animation type
  91587. */
  91588. static readonly ANIMATIONTYPE_FLOAT: number;
  91589. /**
  91590. * Get the Vector3 animation type
  91591. */
  91592. static readonly ANIMATIONTYPE_VECTOR3: number;
  91593. /**
  91594. * Get the Vector2 animation type
  91595. */
  91596. static readonly ANIMATIONTYPE_VECTOR2: number;
  91597. /**
  91598. * Get the Size animation type
  91599. */
  91600. static readonly ANIMATIONTYPE_SIZE: number;
  91601. /**
  91602. * Get the Quaternion animation type
  91603. */
  91604. static readonly ANIMATIONTYPE_QUATERNION: number;
  91605. /**
  91606. * Get the Matrix animation type
  91607. */
  91608. static readonly ANIMATIONTYPE_MATRIX: number;
  91609. /**
  91610. * Get the Color3 animation type
  91611. */
  91612. static readonly ANIMATIONTYPE_COLOR3: number;
  91613. /**
  91614. * Get the Relative Loop Mode
  91615. */
  91616. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  91617. /**
  91618. * Get the Cycle Loop Mode
  91619. */
  91620. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  91621. /**
  91622. * Get the Constant Loop Mode
  91623. */
  91624. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  91625. /** @hidden */
  91626. static _UniversalLerp(left: any, right: any, amount: number): any;
  91627. /**
  91628. * Parses an animation object and creates an animation
  91629. * @param parsedAnimation Parsed animation object
  91630. * @returns Animation object
  91631. */
  91632. static Parse(parsedAnimation: any): Animation;
  91633. /**
  91634. * Appends the serialized animations from the source animations
  91635. * @param source Source containing the animations
  91636. * @param destination Target to store the animations
  91637. */
  91638. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91639. }
  91640. }
  91641. declare module BABYLON {
  91642. /**
  91643. * Interface containing an array of animations
  91644. */
  91645. export interface IAnimatable {
  91646. /**
  91647. * Array of animations
  91648. */
  91649. animations: Nullable<Array<Animation>>;
  91650. }
  91651. }
  91652. declare module BABYLON {
  91653. /**
  91654. * This represents all the required information to add a fresnel effect on a material:
  91655. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  91656. */
  91657. export class FresnelParameters {
  91658. private _isEnabled;
  91659. /**
  91660. * Define if the fresnel effect is enable or not.
  91661. */
  91662. isEnabled: boolean;
  91663. /**
  91664. * Define the color used on edges (grazing angle)
  91665. */
  91666. leftColor: Color3;
  91667. /**
  91668. * Define the color used on center
  91669. */
  91670. rightColor: Color3;
  91671. /**
  91672. * Define bias applied to computed fresnel term
  91673. */
  91674. bias: number;
  91675. /**
  91676. * Defined the power exponent applied to fresnel term
  91677. */
  91678. power: number;
  91679. /**
  91680. * Clones the current fresnel and its valuues
  91681. * @returns a clone fresnel configuration
  91682. */
  91683. clone(): FresnelParameters;
  91684. /**
  91685. * Serializes the current fresnel parameters to a JSON representation.
  91686. * @return the JSON serialization
  91687. */
  91688. serialize(): any;
  91689. /**
  91690. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91691. * @param parsedFresnelParameters Define the JSON representation
  91692. * @returns the parsed parameters
  91693. */
  91694. static Parse(parsedFresnelParameters: any): FresnelParameters;
  91695. }
  91696. }
  91697. declare module BABYLON {
  91698. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  91699. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91700. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91701. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91702. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91703. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91704. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91705. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91706. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91707. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91708. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91709. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91710. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91711. /**
  91712. * Decorator used to define property that can be serialized as reference to a camera
  91713. * @param sourceName defines the name of the property to decorate
  91714. */
  91715. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91716. /**
  91717. * Class used to help serialization objects
  91718. */
  91719. export class SerializationHelper {
  91720. /** @hidden */
  91721. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  91722. /** @hidden */
  91723. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  91724. /** @hidden */
  91725. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  91726. /** @hidden */
  91727. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  91728. /**
  91729. * Appends the serialized animations from the source animations
  91730. * @param source Source containing the animations
  91731. * @param destination Target to store the animations
  91732. */
  91733. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91734. /**
  91735. * Static function used to serialized a specific entity
  91736. * @param entity defines the entity to serialize
  91737. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  91738. * @returns a JSON compatible object representing the serialization of the entity
  91739. */
  91740. static Serialize<T>(entity: T, serializationObject?: any): any;
  91741. /**
  91742. * Creates a new entity from a serialization data object
  91743. * @param creationFunction defines a function used to instanciated the new entity
  91744. * @param source defines the source serialization data
  91745. * @param scene defines the hosting scene
  91746. * @param rootUrl defines the root url for resources
  91747. * @returns a new entity
  91748. */
  91749. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  91750. /**
  91751. * Clones an object
  91752. * @param creationFunction defines the function used to instanciate the new object
  91753. * @param source defines the source object
  91754. * @returns the cloned object
  91755. */
  91756. static Clone<T>(creationFunction: () => T, source: T): T;
  91757. /**
  91758. * Instanciates a new object based on a source one (some data will be shared between both object)
  91759. * @param creationFunction defines the function used to instanciate the new object
  91760. * @param source defines the source object
  91761. * @returns the new object
  91762. */
  91763. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91764. }
  91765. }
  91766. declare module BABYLON {
  91767. /**
  91768. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91769. */
  91770. export interface CubeMapInfo {
  91771. /**
  91772. * The pixel array for the front face.
  91773. * This is stored in format, left to right, up to down format.
  91774. */
  91775. front: Nullable<ArrayBufferView>;
  91776. /**
  91777. * The pixel array for the back face.
  91778. * This is stored in format, left to right, up to down format.
  91779. */
  91780. back: Nullable<ArrayBufferView>;
  91781. /**
  91782. * The pixel array for the left face.
  91783. * This is stored in format, left to right, up to down format.
  91784. */
  91785. left: Nullable<ArrayBufferView>;
  91786. /**
  91787. * The pixel array for the right face.
  91788. * This is stored in format, left to right, up to down format.
  91789. */
  91790. right: Nullable<ArrayBufferView>;
  91791. /**
  91792. * The pixel array for the up face.
  91793. * This is stored in format, left to right, up to down format.
  91794. */
  91795. up: Nullable<ArrayBufferView>;
  91796. /**
  91797. * The pixel array for the down face.
  91798. * This is stored in format, left to right, up to down format.
  91799. */
  91800. down: Nullable<ArrayBufferView>;
  91801. /**
  91802. * The size of the cubemap stored.
  91803. *
  91804. * Each faces will be size * size pixels.
  91805. */
  91806. size: number;
  91807. /**
  91808. * The format of the texture.
  91809. *
  91810. * RGBA, RGB.
  91811. */
  91812. format: number;
  91813. /**
  91814. * The type of the texture data.
  91815. *
  91816. * UNSIGNED_INT, FLOAT.
  91817. */
  91818. type: number;
  91819. /**
  91820. * Specifies whether the texture is in gamma space.
  91821. */
  91822. gammaSpace: boolean;
  91823. }
  91824. /**
  91825. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91826. */
  91827. export class PanoramaToCubeMapTools {
  91828. private static FACE_FRONT;
  91829. private static FACE_BACK;
  91830. private static FACE_RIGHT;
  91831. private static FACE_LEFT;
  91832. private static FACE_DOWN;
  91833. private static FACE_UP;
  91834. /**
  91835. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91836. *
  91837. * @param float32Array The source data.
  91838. * @param inputWidth The width of the input panorama.
  91839. * @param inputHeight The height of the input panorama.
  91840. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91841. * @return The cubemap data
  91842. */
  91843. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  91844. private static CreateCubemapTexture;
  91845. private static CalcProjectionSpherical;
  91846. }
  91847. }
  91848. declare module BABYLON {
  91849. /**
  91850. * Helper class dealing with the extraction of spherical polynomial dataArray
  91851. * from a cube map.
  91852. */
  91853. export class CubeMapToSphericalPolynomialTools {
  91854. private static FileFaces;
  91855. /**
  91856. * Converts a texture to the according Spherical Polynomial data.
  91857. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91858. *
  91859. * @param texture The texture to extract the information from.
  91860. * @return The Spherical Polynomial data.
  91861. */
  91862. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  91863. /**
  91864. * Converts a cubemap to the according Spherical Polynomial data.
  91865. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91866. *
  91867. * @param cubeInfo The Cube map to extract the information from.
  91868. * @return The Spherical Polynomial data.
  91869. */
  91870. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  91871. }
  91872. }
  91873. declare module BABYLON {
  91874. /**
  91875. * Class used to manipulate GUIDs
  91876. */
  91877. export class GUID {
  91878. /**
  91879. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91880. * Be aware Math.random() could cause collisions, but:
  91881. * "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"
  91882. * @returns a pseudo random id
  91883. */
  91884. static RandomId(): string;
  91885. }
  91886. }
  91887. declare module BABYLON {
  91888. /**
  91889. * Base class of all the textures in babylon.
  91890. * It groups all the common properties the materials, post process, lights... might need
  91891. * in order to make a correct use of the texture.
  91892. */
  91893. export class BaseTexture implements IAnimatable {
  91894. /**
  91895. * Default anisotropic filtering level for the application.
  91896. * It is set to 4 as a good tradeoff between perf and quality.
  91897. */
  91898. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  91899. /**
  91900. * Gets or sets the unique id of the texture
  91901. */
  91902. uniqueId: number;
  91903. /**
  91904. * Define the name of the texture.
  91905. */
  91906. name: string;
  91907. /**
  91908. * Gets or sets an object used to store user defined information.
  91909. */
  91910. metadata: any;
  91911. /**
  91912. * For internal use only. Please do not use.
  91913. */
  91914. reservedDataStore: any;
  91915. private _hasAlpha;
  91916. /**
  91917. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  91918. */
  91919. hasAlpha: boolean;
  91920. /**
  91921. * Defines if the alpha value should be determined via the rgb values.
  91922. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  91923. */
  91924. getAlphaFromRGB: boolean;
  91925. /**
  91926. * Intensity or strength of the texture.
  91927. * It is commonly used by materials to fine tune the intensity of the texture
  91928. */
  91929. level: number;
  91930. /**
  91931. * Define the UV chanel to use starting from 0 and defaulting to 0.
  91932. * This is part of the texture as textures usually maps to one uv set.
  91933. */
  91934. coordinatesIndex: number;
  91935. private _coordinatesMode;
  91936. /**
  91937. * How a texture is mapped.
  91938. *
  91939. * | Value | Type | Description |
  91940. * | ----- | ----------------------------------- | ----------- |
  91941. * | 0 | EXPLICIT_MODE | |
  91942. * | 1 | SPHERICAL_MODE | |
  91943. * | 2 | PLANAR_MODE | |
  91944. * | 3 | CUBIC_MODE | |
  91945. * | 4 | PROJECTION_MODE | |
  91946. * | 5 | SKYBOX_MODE | |
  91947. * | 6 | INVCUBIC_MODE | |
  91948. * | 7 | EQUIRECTANGULAR_MODE | |
  91949. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  91950. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  91951. */
  91952. coordinatesMode: number;
  91953. /**
  91954. * | Value | Type | Description |
  91955. * | ----- | ------------------ | ----------- |
  91956. * | 0 | CLAMP_ADDRESSMODE | |
  91957. * | 1 | WRAP_ADDRESSMODE | |
  91958. * | 2 | MIRROR_ADDRESSMODE | |
  91959. */
  91960. wrapU: number;
  91961. /**
  91962. * | Value | Type | Description |
  91963. * | ----- | ------------------ | ----------- |
  91964. * | 0 | CLAMP_ADDRESSMODE | |
  91965. * | 1 | WRAP_ADDRESSMODE | |
  91966. * | 2 | MIRROR_ADDRESSMODE | |
  91967. */
  91968. wrapV: number;
  91969. /**
  91970. * | Value | Type | Description |
  91971. * | ----- | ------------------ | ----------- |
  91972. * | 0 | CLAMP_ADDRESSMODE | |
  91973. * | 1 | WRAP_ADDRESSMODE | |
  91974. * | 2 | MIRROR_ADDRESSMODE | |
  91975. */
  91976. wrapR: number;
  91977. /**
  91978. * With compliant hardware and browser (supporting anisotropic filtering)
  91979. * this defines the level of anisotropic filtering in the texture.
  91980. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  91981. */
  91982. anisotropicFilteringLevel: number;
  91983. /**
  91984. * Define if the texture is a cube texture or if false a 2d texture.
  91985. */
  91986. isCube: boolean;
  91987. /**
  91988. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  91989. */
  91990. is3D: boolean;
  91991. /**
  91992. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  91993. * HDR texture are usually stored in linear space.
  91994. * This only impacts the PBR and Background materials
  91995. */
  91996. gammaSpace: boolean;
  91997. /**
  91998. * Gets whether or not the texture contains RGBD data.
  91999. */
  92000. readonly isRGBD: boolean;
  92001. /**
  92002. * Is Z inverted in the texture (useful in a cube texture).
  92003. */
  92004. invertZ: boolean;
  92005. /**
  92006. * Are mip maps generated for this texture or not.
  92007. */
  92008. readonly noMipmap: boolean;
  92009. /**
  92010. * @hidden
  92011. */
  92012. lodLevelInAlpha: boolean;
  92013. /**
  92014. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92015. */
  92016. lodGenerationOffset: number;
  92017. /**
  92018. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92019. */
  92020. lodGenerationScale: number;
  92021. /**
  92022. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92023. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92024. * average roughness values.
  92025. */
  92026. linearSpecularLOD: boolean;
  92027. /**
  92028. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92029. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92030. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92031. */
  92032. irradianceTexture: Nullable<BaseTexture>;
  92033. /**
  92034. * Define if the texture is a render target.
  92035. */
  92036. isRenderTarget: boolean;
  92037. /**
  92038. * Define the unique id of the texture in the scene.
  92039. */
  92040. readonly uid: string;
  92041. /**
  92042. * Return a string representation of the texture.
  92043. * @returns the texture as a string
  92044. */
  92045. toString(): string;
  92046. /**
  92047. * Get the class name of the texture.
  92048. * @returns "BaseTexture"
  92049. */
  92050. getClassName(): string;
  92051. /**
  92052. * Define the list of animation attached to the texture.
  92053. */
  92054. animations: Animation[];
  92055. /**
  92056. * An event triggered when the texture is disposed.
  92057. */
  92058. onDisposeObservable: Observable<BaseTexture>;
  92059. private _onDisposeObserver;
  92060. /**
  92061. * Callback triggered when the texture has been disposed.
  92062. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92063. */
  92064. onDispose: () => void;
  92065. /**
  92066. * Define the current state of the loading sequence when in delayed load mode.
  92067. */
  92068. delayLoadState: number;
  92069. private _scene;
  92070. /** @hidden */
  92071. _texture: Nullable<InternalTexture>;
  92072. private _uid;
  92073. /**
  92074. * Define if the texture is preventinga material to render or not.
  92075. * If not and the texture is not ready, the engine will use a default black texture instead.
  92076. */
  92077. readonly isBlocking: boolean;
  92078. /**
  92079. * Instantiates a new BaseTexture.
  92080. * Base class of all the textures in babylon.
  92081. * It groups all the common properties the materials, post process, lights... might need
  92082. * in order to make a correct use of the texture.
  92083. * @param scene Define the scene the texture blongs to
  92084. */
  92085. constructor(scene: Nullable<Scene>);
  92086. /**
  92087. * Get the scene the texture belongs to.
  92088. * @returns the scene or null if undefined
  92089. */
  92090. getScene(): Nullable<Scene>;
  92091. /**
  92092. * Get the texture transform matrix used to offset tile the texture for istance.
  92093. * @returns the transformation matrix
  92094. */
  92095. getTextureMatrix(): Matrix;
  92096. /**
  92097. * Get the texture reflection matrix used to rotate/transform the reflection.
  92098. * @returns the reflection matrix
  92099. */
  92100. getReflectionTextureMatrix(): Matrix;
  92101. /**
  92102. * Get the underlying lower level texture from Babylon.
  92103. * @returns the insternal texture
  92104. */
  92105. getInternalTexture(): Nullable<InternalTexture>;
  92106. /**
  92107. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92108. * @returns true if ready or not blocking
  92109. */
  92110. isReadyOrNotBlocking(): boolean;
  92111. /**
  92112. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  92113. * @returns true if fully ready
  92114. */
  92115. isReady(): boolean;
  92116. private _cachedSize;
  92117. /**
  92118. * Get the size of the texture.
  92119. * @returns the texture size.
  92120. */
  92121. getSize(): ISize;
  92122. /**
  92123. * Get the base size of the texture.
  92124. * It can be different from the size if the texture has been resized for POT for instance
  92125. * @returns the base size
  92126. */
  92127. getBaseSize(): ISize;
  92128. /**
  92129. * Update the sampling mode of the texture.
  92130. * Default is Trilinear mode.
  92131. *
  92132. * | Value | Type | Description |
  92133. * | ----- | ------------------ | ----------- |
  92134. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  92135. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  92136. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  92137. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  92138. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  92139. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  92140. * | 7 | NEAREST_LINEAR | |
  92141. * | 8 | NEAREST_NEAREST | |
  92142. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  92143. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  92144. * | 11 | LINEAR_LINEAR | |
  92145. * | 12 | LINEAR_NEAREST | |
  92146. *
  92147. * > _mag_: magnification filter (close to the viewer)
  92148. * > _min_: minification filter (far from the viewer)
  92149. * > _mip_: filter used between mip map levels
  92150. *@param samplingMode Define the new sampling mode of the texture
  92151. */
  92152. updateSamplingMode(samplingMode: number): void;
  92153. /**
  92154. * Scales the texture if is `canRescale()`
  92155. * @param ratio the resize factor we want to use to rescale
  92156. */
  92157. scale(ratio: number): void;
  92158. /**
  92159. * Get if the texture can rescale.
  92160. */
  92161. readonly canRescale: boolean;
  92162. /** @hidden */
  92163. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92164. /** @hidden */
  92165. _rebuild(): void;
  92166. /**
  92167. * Triggers the load sequence in delayed load mode.
  92168. */
  92169. delayLoad(): void;
  92170. /**
  92171. * Clones the texture.
  92172. * @returns the cloned texture
  92173. */
  92174. clone(): Nullable<BaseTexture>;
  92175. /**
  92176. * Get the texture underlying type (INT, FLOAT...)
  92177. */
  92178. readonly textureType: number;
  92179. /**
  92180. * Get the texture underlying format (RGB, RGBA...)
  92181. */
  92182. readonly textureFormat: number;
  92183. /**
  92184. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92185. * This will returns an RGBA array buffer containing either in values (0-255) or
  92186. * float values (0-1) depending of the underlying buffer type.
  92187. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92188. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92189. * @param buffer defines a user defined buffer to fill with data (can be null)
  92190. * @returns The Array buffer containing the pixels data.
  92191. */
  92192. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  92193. /**
  92194. * Release and destroy the underlying lower level texture aka internalTexture.
  92195. */
  92196. releaseInternalTexture(): void;
  92197. /**
  92198. * Get the polynomial representation of the texture data.
  92199. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  92200. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  92201. */
  92202. sphericalPolynomial: Nullable<SphericalPolynomial>;
  92203. /** @hidden */
  92204. readonly _lodTextureHigh: Nullable<BaseTexture>;
  92205. /** @hidden */
  92206. readonly _lodTextureMid: Nullable<BaseTexture>;
  92207. /** @hidden */
  92208. readonly _lodTextureLow: Nullable<BaseTexture>;
  92209. /**
  92210. * Dispose the texture and release its associated resources.
  92211. */
  92212. dispose(): void;
  92213. /**
  92214. * Serialize the texture into a JSON representation that can be parsed later on.
  92215. * @returns the JSON representation of the texture
  92216. */
  92217. serialize(): any;
  92218. /**
  92219. * Helper function to be called back once a list of texture contains only ready textures.
  92220. * @param textures Define the list of textures to wait for
  92221. * @param callback Define the callback triggered once the entire list will be ready
  92222. */
  92223. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92224. }
  92225. }
  92226. declare module BABYLON {
  92227. /**
  92228. * Class used to store data associated with WebGL texture data for the engine
  92229. * This class should not be used directly
  92230. */
  92231. export class InternalTexture {
  92232. /** @hidden */
  92233. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  92234. /**
  92235. * The source of the texture data is unknown
  92236. */
  92237. static DATASOURCE_UNKNOWN: number;
  92238. /**
  92239. * Texture data comes from an URL
  92240. */
  92241. static DATASOURCE_URL: number;
  92242. /**
  92243. * Texture data is only used for temporary storage
  92244. */
  92245. static DATASOURCE_TEMP: number;
  92246. /**
  92247. * Texture data comes from raw data (ArrayBuffer)
  92248. */
  92249. static DATASOURCE_RAW: number;
  92250. /**
  92251. * Texture content is dynamic (video or dynamic texture)
  92252. */
  92253. static DATASOURCE_DYNAMIC: number;
  92254. /**
  92255. * Texture content is generated by rendering to it
  92256. */
  92257. static DATASOURCE_RENDERTARGET: number;
  92258. /**
  92259. * Texture content is part of a multi render target process
  92260. */
  92261. static DATASOURCE_MULTIRENDERTARGET: number;
  92262. /**
  92263. * Texture data comes from a cube data file
  92264. */
  92265. static DATASOURCE_CUBE: number;
  92266. /**
  92267. * Texture data comes from a raw cube data
  92268. */
  92269. static DATASOURCE_CUBERAW: number;
  92270. /**
  92271. * Texture data come from a prefiltered cube data file
  92272. */
  92273. static DATASOURCE_CUBEPREFILTERED: number;
  92274. /**
  92275. * Texture content is raw 3D data
  92276. */
  92277. static DATASOURCE_RAW3D: number;
  92278. /**
  92279. * Texture content is a depth texture
  92280. */
  92281. static DATASOURCE_DEPTHTEXTURE: number;
  92282. /**
  92283. * Texture data comes from a raw cube data encoded with RGBD
  92284. */
  92285. static DATASOURCE_CUBERAW_RGBD: number;
  92286. /**
  92287. * Defines if the texture is ready
  92288. */
  92289. isReady: boolean;
  92290. /**
  92291. * Defines if the texture is a cube texture
  92292. */
  92293. isCube: boolean;
  92294. /**
  92295. * Defines if the texture contains 3D data
  92296. */
  92297. is3D: boolean;
  92298. /**
  92299. * Defines if the texture contains multiview data
  92300. */
  92301. isMultiview: boolean;
  92302. /**
  92303. * Gets the URL used to load this texture
  92304. */
  92305. url: string;
  92306. /**
  92307. * Gets the sampling mode of the texture
  92308. */
  92309. samplingMode: number;
  92310. /**
  92311. * Gets a boolean indicating if the texture needs mipmaps generation
  92312. */
  92313. generateMipMaps: boolean;
  92314. /**
  92315. * Gets the number of samples used by the texture (WebGL2+ only)
  92316. */
  92317. samples: number;
  92318. /**
  92319. * Gets the type of the texture (int, float...)
  92320. */
  92321. type: number;
  92322. /**
  92323. * Gets the format of the texture (RGB, RGBA...)
  92324. */
  92325. format: number;
  92326. /**
  92327. * Observable called when the texture is loaded
  92328. */
  92329. onLoadedObservable: Observable<InternalTexture>;
  92330. /**
  92331. * Gets the width of the texture
  92332. */
  92333. width: number;
  92334. /**
  92335. * Gets the height of the texture
  92336. */
  92337. height: number;
  92338. /**
  92339. * Gets the depth of the texture
  92340. */
  92341. depth: number;
  92342. /**
  92343. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  92344. */
  92345. baseWidth: number;
  92346. /**
  92347. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  92348. */
  92349. baseHeight: number;
  92350. /**
  92351. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  92352. */
  92353. baseDepth: number;
  92354. /**
  92355. * Gets a boolean indicating if the texture is inverted on Y axis
  92356. */
  92357. invertY: boolean;
  92358. /** @hidden */
  92359. _invertVScale: boolean;
  92360. /** @hidden */
  92361. _associatedChannel: number;
  92362. /** @hidden */
  92363. _dataSource: number;
  92364. /** @hidden */
  92365. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  92366. /** @hidden */
  92367. _bufferView: Nullable<ArrayBufferView>;
  92368. /** @hidden */
  92369. _bufferViewArray: Nullable<ArrayBufferView[]>;
  92370. /** @hidden */
  92371. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  92372. /** @hidden */
  92373. _size: number;
  92374. /** @hidden */
  92375. _extension: string;
  92376. /** @hidden */
  92377. _files: Nullable<string[]>;
  92378. /** @hidden */
  92379. _workingCanvas: Nullable<HTMLCanvasElement>;
  92380. /** @hidden */
  92381. _workingContext: Nullable<CanvasRenderingContext2D>;
  92382. /** @hidden */
  92383. _framebuffer: Nullable<WebGLFramebuffer>;
  92384. /** @hidden */
  92385. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  92386. /** @hidden */
  92387. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  92388. /** @hidden */
  92389. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  92390. /** @hidden */
  92391. _attachments: Nullable<number[]>;
  92392. /** @hidden */
  92393. _cachedCoordinatesMode: Nullable<number>;
  92394. /** @hidden */
  92395. _cachedWrapU: Nullable<number>;
  92396. /** @hidden */
  92397. _cachedWrapV: Nullable<number>;
  92398. /** @hidden */
  92399. _cachedWrapR: Nullable<number>;
  92400. /** @hidden */
  92401. _cachedAnisotropicFilteringLevel: Nullable<number>;
  92402. /** @hidden */
  92403. _isDisabled: boolean;
  92404. /** @hidden */
  92405. _compression: Nullable<string>;
  92406. /** @hidden */
  92407. _generateStencilBuffer: boolean;
  92408. /** @hidden */
  92409. _generateDepthBuffer: boolean;
  92410. /** @hidden */
  92411. _comparisonFunction: number;
  92412. /** @hidden */
  92413. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  92414. /** @hidden */
  92415. _lodGenerationScale: number;
  92416. /** @hidden */
  92417. _lodGenerationOffset: number;
  92418. /** @hidden */
  92419. _colorTextureArray: Nullable<WebGLTexture>;
  92420. /** @hidden */
  92421. _depthStencilTextureArray: Nullable<WebGLTexture>;
  92422. /** @hidden */
  92423. _lodTextureHigh: Nullable<BaseTexture>;
  92424. /** @hidden */
  92425. _lodTextureMid: Nullable<BaseTexture>;
  92426. /** @hidden */
  92427. _lodTextureLow: Nullable<BaseTexture>;
  92428. /** @hidden */
  92429. _isRGBD: boolean;
  92430. /** @hidden */
  92431. _linearSpecularLOD: boolean;
  92432. /** @hidden */
  92433. _irradianceTexture: Nullable<BaseTexture>;
  92434. /** @hidden */
  92435. _webGLTexture: Nullable<WebGLTexture>;
  92436. /** @hidden */
  92437. _references: number;
  92438. private _engine;
  92439. /**
  92440. * Gets the Engine the texture belongs to.
  92441. * @returns The babylon engine
  92442. */
  92443. getEngine(): Engine;
  92444. /**
  92445. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  92446. */
  92447. readonly dataSource: number;
  92448. /**
  92449. * Creates a new InternalTexture
  92450. * @param engine defines the engine to use
  92451. * @param dataSource defines the type of data that will be used
  92452. * @param delayAllocation if the texture allocation should be delayed (default: false)
  92453. */
  92454. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  92455. /**
  92456. * Increments the number of references (ie. the number of Texture that point to it)
  92457. */
  92458. incrementReferences(): void;
  92459. /**
  92460. * Change the size of the texture (not the size of the content)
  92461. * @param width defines the new width
  92462. * @param height defines the new height
  92463. * @param depth defines the new depth (1 by default)
  92464. */
  92465. updateSize(width: int, height: int, depth?: int): void;
  92466. /** @hidden */
  92467. _rebuild(): void;
  92468. /** @hidden */
  92469. _swapAndDie(target: InternalTexture): void;
  92470. /**
  92471. * Dispose the current allocated resources
  92472. */
  92473. dispose(): void;
  92474. }
  92475. }
  92476. declare module BABYLON {
  92477. /**
  92478. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92479. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92480. */
  92481. export class EffectFallbacks {
  92482. private _defines;
  92483. private _currentRank;
  92484. private _maxRank;
  92485. private _mesh;
  92486. /**
  92487. * Removes the fallback from the bound mesh.
  92488. */
  92489. unBindMesh(): void;
  92490. /**
  92491. * Adds a fallback on the specified property.
  92492. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92493. * @param define The name of the define in the shader
  92494. */
  92495. addFallback(rank: number, define: string): void;
  92496. /**
  92497. * Sets the mesh to use CPU skinning when needing to fallback.
  92498. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92499. * @param mesh The mesh to use the fallbacks.
  92500. */
  92501. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92502. /**
  92503. * Checks to see if more fallbacks are still availible.
  92504. */
  92505. readonly isMoreFallbacks: boolean;
  92506. /**
  92507. * Removes the defines that should be removed when falling back.
  92508. * @param currentDefines defines the current define statements for the shader.
  92509. * @param effect defines the current effect we try to compile
  92510. * @returns The resulting defines with defines of the current rank removed.
  92511. */
  92512. reduce(currentDefines: string, effect: Effect): string;
  92513. }
  92514. /**
  92515. * Options to be used when creating an effect.
  92516. */
  92517. export class EffectCreationOptions {
  92518. /**
  92519. * Atrributes that will be used in the shader.
  92520. */
  92521. attributes: string[];
  92522. /**
  92523. * Uniform varible names that will be set in the shader.
  92524. */
  92525. uniformsNames: string[];
  92526. /**
  92527. * Uniform buffer varible names that will be set in the shader.
  92528. */
  92529. uniformBuffersNames: string[];
  92530. /**
  92531. * Sampler texture variable names that will be set in the shader.
  92532. */
  92533. samplers: string[];
  92534. /**
  92535. * Define statements that will be set in the shader.
  92536. */
  92537. defines: any;
  92538. /**
  92539. * Possible fallbacks for this effect to improve performance when needed.
  92540. */
  92541. fallbacks: Nullable<EffectFallbacks>;
  92542. /**
  92543. * Callback that will be called when the shader is compiled.
  92544. */
  92545. onCompiled: Nullable<(effect: Effect) => void>;
  92546. /**
  92547. * Callback that will be called if an error occurs during shader compilation.
  92548. */
  92549. onError: Nullable<(effect: Effect, errors: string) => void>;
  92550. /**
  92551. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92552. */
  92553. indexParameters: any;
  92554. /**
  92555. * Max number of lights that can be used in the shader.
  92556. */
  92557. maxSimultaneousLights: number;
  92558. /**
  92559. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92560. */
  92561. transformFeedbackVaryings: Nullable<string[]>;
  92562. }
  92563. /**
  92564. * Effect containing vertex and fragment shader that can be executed on an object.
  92565. */
  92566. export class Effect implements IDisposable {
  92567. /**
  92568. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92569. */
  92570. static ShadersRepository: string;
  92571. /**
  92572. * Name of the effect.
  92573. */
  92574. name: any;
  92575. /**
  92576. * String container all the define statements that should be set on the shader.
  92577. */
  92578. defines: string;
  92579. /**
  92580. * Callback that will be called when the shader is compiled.
  92581. */
  92582. onCompiled: Nullable<(effect: Effect) => void>;
  92583. /**
  92584. * Callback that will be called if an error occurs during shader compilation.
  92585. */
  92586. onError: Nullable<(effect: Effect, errors: string) => void>;
  92587. /**
  92588. * Callback that will be called when effect is bound.
  92589. */
  92590. onBind: Nullable<(effect: Effect) => void>;
  92591. /**
  92592. * Unique ID of the effect.
  92593. */
  92594. uniqueId: number;
  92595. /**
  92596. * Observable that will be called when the shader is compiled.
  92597. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92598. */
  92599. onCompileObservable: Observable<Effect>;
  92600. /**
  92601. * Observable that will be called if an error occurs during shader compilation.
  92602. */
  92603. onErrorObservable: Observable<Effect>;
  92604. /** @hidden */
  92605. _onBindObservable: Nullable<Observable<Effect>>;
  92606. /**
  92607. * Observable that will be called when effect is bound.
  92608. */
  92609. readonly onBindObservable: Observable<Effect>;
  92610. /** @hidden */
  92611. _bonesComputationForcedToCPU: boolean;
  92612. private static _uniqueIdSeed;
  92613. private _engine;
  92614. private _uniformBuffersNames;
  92615. private _uniformsNames;
  92616. private _samplerList;
  92617. private _samplers;
  92618. private _isReady;
  92619. private _compilationError;
  92620. private _attributesNames;
  92621. private _attributes;
  92622. private _uniforms;
  92623. /**
  92624. * Key for the effect.
  92625. * @hidden
  92626. */
  92627. _key: string;
  92628. private _indexParameters;
  92629. private _fallbacks;
  92630. private _vertexSourceCode;
  92631. private _fragmentSourceCode;
  92632. private _vertexSourceCodeOverride;
  92633. private _fragmentSourceCodeOverride;
  92634. private _transformFeedbackVaryings;
  92635. /**
  92636. * Compiled shader to webGL program.
  92637. * @hidden
  92638. */
  92639. _pipelineContext: Nullable<IPipelineContext>;
  92640. private _valueCache;
  92641. private static _baseCache;
  92642. /**
  92643. * Instantiates an effect.
  92644. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92645. * @param baseName Name of the effect.
  92646. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92647. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92648. * @param samplers List of sampler variables that will be passed to the shader.
  92649. * @param engine Engine to be used to render the effect
  92650. * @param defines Define statements to be added to the shader.
  92651. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92652. * @param onCompiled Callback that will be called when the shader is compiled.
  92653. * @param onError Callback that will be called if an error occurs during shader compilation.
  92654. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92655. */
  92656. 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);
  92657. private _useFinalCode;
  92658. /**
  92659. * Unique key for this effect
  92660. */
  92661. readonly key: string;
  92662. /**
  92663. * If the effect has been compiled and prepared.
  92664. * @returns if the effect is compiled and prepared.
  92665. */
  92666. isReady(): boolean;
  92667. /**
  92668. * The engine the effect was initialized with.
  92669. * @returns the engine.
  92670. */
  92671. getEngine(): Engine;
  92672. /**
  92673. * The pipeline context for this effect
  92674. * @returns the associated pipeline context
  92675. */
  92676. getPipelineContext(): Nullable<IPipelineContext>;
  92677. /**
  92678. * The set of names of attribute variables for the shader.
  92679. * @returns An array of attribute names.
  92680. */
  92681. getAttributesNames(): string[];
  92682. /**
  92683. * Returns the attribute at the given index.
  92684. * @param index The index of the attribute.
  92685. * @returns The location of the attribute.
  92686. */
  92687. getAttributeLocation(index: number): number;
  92688. /**
  92689. * Returns the attribute based on the name of the variable.
  92690. * @param name of the attribute to look up.
  92691. * @returns the attribute location.
  92692. */
  92693. getAttributeLocationByName(name: string): number;
  92694. /**
  92695. * The number of attributes.
  92696. * @returns the numnber of attributes.
  92697. */
  92698. getAttributesCount(): number;
  92699. /**
  92700. * Gets the index of a uniform variable.
  92701. * @param uniformName of the uniform to look up.
  92702. * @returns the index.
  92703. */
  92704. getUniformIndex(uniformName: string): number;
  92705. /**
  92706. * Returns the attribute based on the name of the variable.
  92707. * @param uniformName of the uniform to look up.
  92708. * @returns the location of the uniform.
  92709. */
  92710. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92711. /**
  92712. * Returns an array of sampler variable names
  92713. * @returns The array of sampler variable neames.
  92714. */
  92715. getSamplers(): string[];
  92716. /**
  92717. * The error from the last compilation.
  92718. * @returns the error string.
  92719. */
  92720. getCompilationError(): string;
  92721. /**
  92722. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92723. * @param func The callback to be used.
  92724. */
  92725. executeWhenCompiled(func: (effect: Effect) => void): void;
  92726. private _checkIsReady;
  92727. /** @hidden */
  92728. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92729. /** @hidden */
  92730. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92731. /** @hidden */
  92732. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92733. /**
  92734. * Recompiles the webGL program
  92735. * @param vertexSourceCode The source code for the vertex shader.
  92736. * @param fragmentSourceCode The source code for the fragment shader.
  92737. * @param onCompiled Callback called when completed.
  92738. * @param onError Callback called on error.
  92739. * @hidden
  92740. */
  92741. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92742. /**
  92743. * Prepares the effect
  92744. * @hidden
  92745. */
  92746. _prepareEffect(): void;
  92747. /**
  92748. * Checks if the effect is supported. (Must be called after compilation)
  92749. */
  92750. readonly isSupported: boolean;
  92751. /**
  92752. * Binds a texture to the engine to be used as output of the shader.
  92753. * @param channel Name of the output variable.
  92754. * @param texture Texture to bind.
  92755. * @hidden
  92756. */
  92757. _bindTexture(channel: string, texture: InternalTexture): void;
  92758. /**
  92759. * Sets a texture on the engine to be used in the shader.
  92760. * @param channel Name of the sampler variable.
  92761. * @param texture Texture to set.
  92762. */
  92763. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92764. /**
  92765. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92766. * @param channel Name of the sampler variable.
  92767. * @param texture Texture to set.
  92768. */
  92769. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92770. /**
  92771. * Sets an array of textures on the engine to be used in the shader.
  92772. * @param channel Name of the variable.
  92773. * @param textures Textures to set.
  92774. */
  92775. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92776. /**
  92777. * 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)
  92778. * @param channel Name of the sampler variable.
  92779. * @param postProcess Post process to get the input texture from.
  92780. */
  92781. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92782. /**
  92783. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92784. * 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)
  92785. * @param channel Name of the sampler variable.
  92786. * @param postProcess Post process to get the output texture from.
  92787. */
  92788. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92789. /** @hidden */
  92790. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92791. /** @hidden */
  92792. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92793. /** @hidden */
  92794. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92795. /** @hidden */
  92796. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92797. /**
  92798. * Binds a buffer to a uniform.
  92799. * @param buffer Buffer to bind.
  92800. * @param name Name of the uniform variable to bind to.
  92801. */
  92802. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92803. /**
  92804. * Binds block to a uniform.
  92805. * @param blockName Name of the block to bind.
  92806. * @param index Index to bind.
  92807. */
  92808. bindUniformBlock(blockName: string, index: number): void;
  92809. /**
  92810. * Sets an interger value on a uniform variable.
  92811. * @param uniformName Name of the variable.
  92812. * @param value Value to be set.
  92813. * @returns this effect.
  92814. */
  92815. setInt(uniformName: string, value: number): Effect;
  92816. /**
  92817. * Sets an int array on a uniform variable.
  92818. * @param uniformName Name of the variable.
  92819. * @param array array to be set.
  92820. * @returns this effect.
  92821. */
  92822. setIntArray(uniformName: string, array: Int32Array): Effect;
  92823. /**
  92824. * 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)
  92825. * @param uniformName Name of the variable.
  92826. * @param array array to be set.
  92827. * @returns this effect.
  92828. */
  92829. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92830. /**
  92831. * 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)
  92832. * @param uniformName Name of the variable.
  92833. * @param array array to be set.
  92834. * @returns this effect.
  92835. */
  92836. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92837. /**
  92838. * 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)
  92839. * @param uniformName Name of the variable.
  92840. * @param array array to be set.
  92841. * @returns this effect.
  92842. */
  92843. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92844. /**
  92845. * Sets an float array on a uniform variable.
  92846. * @param uniformName Name of the variable.
  92847. * @param array array to be set.
  92848. * @returns this effect.
  92849. */
  92850. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92851. /**
  92852. * 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)
  92853. * @param uniformName Name of the variable.
  92854. * @param array array to be set.
  92855. * @returns this effect.
  92856. */
  92857. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92858. /**
  92859. * 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)
  92860. * @param uniformName Name of the variable.
  92861. * @param array array to be set.
  92862. * @returns this effect.
  92863. */
  92864. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92865. /**
  92866. * 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)
  92867. * @param uniformName Name of the variable.
  92868. * @param array array to be set.
  92869. * @returns this effect.
  92870. */
  92871. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92872. /**
  92873. * Sets an array on a uniform variable.
  92874. * @param uniformName Name of the variable.
  92875. * @param array array to be set.
  92876. * @returns this effect.
  92877. */
  92878. setArray(uniformName: string, array: number[]): Effect;
  92879. /**
  92880. * 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)
  92881. * @param uniformName Name of the variable.
  92882. * @param array array to be set.
  92883. * @returns this effect.
  92884. */
  92885. setArray2(uniformName: string, array: number[]): Effect;
  92886. /**
  92887. * 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)
  92888. * @param uniformName Name of the variable.
  92889. * @param array array to be set.
  92890. * @returns this effect.
  92891. */
  92892. setArray3(uniformName: string, array: number[]): Effect;
  92893. /**
  92894. * 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)
  92895. * @param uniformName Name of the variable.
  92896. * @param array array to be set.
  92897. * @returns this effect.
  92898. */
  92899. setArray4(uniformName: string, array: number[]): Effect;
  92900. /**
  92901. * Sets matrices on a uniform variable.
  92902. * @param uniformName Name of the variable.
  92903. * @param matrices matrices to be set.
  92904. * @returns this effect.
  92905. */
  92906. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92907. /**
  92908. * Sets matrix on a uniform variable.
  92909. * @param uniformName Name of the variable.
  92910. * @param matrix matrix to be set.
  92911. * @returns this effect.
  92912. */
  92913. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  92914. /**
  92915. * 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)
  92916. * @param uniformName Name of the variable.
  92917. * @param matrix matrix to be set.
  92918. * @returns this effect.
  92919. */
  92920. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92921. /**
  92922. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92923. * @param uniformName Name of the variable.
  92924. * @param matrix matrix to be set.
  92925. * @returns this effect.
  92926. */
  92927. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92928. /**
  92929. * Sets a float on a uniform variable.
  92930. * @param uniformName Name of the variable.
  92931. * @param value value to be set.
  92932. * @returns this effect.
  92933. */
  92934. setFloat(uniformName: string, value: number): Effect;
  92935. /**
  92936. * Sets a boolean on a uniform variable.
  92937. * @param uniformName Name of the variable.
  92938. * @param bool value to be set.
  92939. * @returns this effect.
  92940. */
  92941. setBool(uniformName: string, bool: boolean): Effect;
  92942. /**
  92943. * Sets a Vector2 on a uniform variable.
  92944. * @param uniformName Name of the variable.
  92945. * @param vector2 vector2 to be set.
  92946. * @returns this effect.
  92947. */
  92948. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  92949. /**
  92950. * Sets a float2 on a uniform variable.
  92951. * @param uniformName Name of the variable.
  92952. * @param x First float in float2.
  92953. * @param y Second float in float2.
  92954. * @returns this effect.
  92955. */
  92956. setFloat2(uniformName: string, x: number, y: number): Effect;
  92957. /**
  92958. * Sets a Vector3 on a uniform variable.
  92959. * @param uniformName Name of the variable.
  92960. * @param vector3 Value to be set.
  92961. * @returns this effect.
  92962. */
  92963. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  92964. /**
  92965. * Sets a float3 on a uniform variable.
  92966. * @param uniformName Name of the variable.
  92967. * @param x First float in float3.
  92968. * @param y Second float in float3.
  92969. * @param z Third float in float3.
  92970. * @returns this effect.
  92971. */
  92972. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92973. /**
  92974. * Sets a Vector4 on a uniform variable.
  92975. * @param uniformName Name of the variable.
  92976. * @param vector4 Value to be set.
  92977. * @returns this effect.
  92978. */
  92979. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  92980. /**
  92981. * Sets a float4 on a uniform variable.
  92982. * @param uniformName Name of the variable.
  92983. * @param x First float in float4.
  92984. * @param y Second float in float4.
  92985. * @param z Third float in float4.
  92986. * @param w Fourth float in float4.
  92987. * @returns this effect.
  92988. */
  92989. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92990. /**
  92991. * Sets a Color3 on a uniform variable.
  92992. * @param uniformName Name of the variable.
  92993. * @param color3 Value to be set.
  92994. * @returns this effect.
  92995. */
  92996. setColor3(uniformName: string, color3: IColor3Like): Effect;
  92997. /**
  92998. * Sets a Color4 on a uniform variable.
  92999. * @param uniformName Name of the variable.
  93000. * @param color3 Value to be set.
  93001. * @param alpha Alpha value to be set.
  93002. * @returns this effect.
  93003. */
  93004. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  93005. /**
  93006. * Sets a Color4 on a uniform variable
  93007. * @param uniformName defines the name of the variable
  93008. * @param color4 defines the value to be set
  93009. * @returns this effect.
  93010. */
  93011. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  93012. /** Release all associated resources */
  93013. dispose(): void;
  93014. /**
  93015. * This function will add a new shader to the shader store
  93016. * @param name the name of the shader
  93017. * @param pixelShader optional pixel shader content
  93018. * @param vertexShader optional vertex shader content
  93019. */
  93020. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  93021. /**
  93022. * Store of each shader (The can be looked up using effect.key)
  93023. */
  93024. static ShadersStore: {
  93025. [key: string]: string;
  93026. };
  93027. /**
  93028. * Store of each included file for a shader (The can be looked up using effect.key)
  93029. */
  93030. static IncludesShadersStore: {
  93031. [key: string]: string;
  93032. };
  93033. /**
  93034. * Resets the cache of effects.
  93035. */
  93036. static ResetCache(): void;
  93037. }
  93038. }
  93039. declare module BABYLON {
  93040. /**
  93041. * Uniform buffer objects.
  93042. *
  93043. * Handles blocks of uniform on the GPU.
  93044. *
  93045. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93046. *
  93047. * For more information, please refer to :
  93048. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93049. */
  93050. export class UniformBuffer {
  93051. private _engine;
  93052. private _buffer;
  93053. private _data;
  93054. private _bufferData;
  93055. private _dynamic?;
  93056. private _uniformLocations;
  93057. private _uniformSizes;
  93058. private _uniformLocationPointer;
  93059. private _needSync;
  93060. private _noUBO;
  93061. private _currentEffect;
  93062. private static _MAX_UNIFORM_SIZE;
  93063. private static _tempBuffer;
  93064. /**
  93065. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93066. * This is dynamic to allow compat with webgl 1 and 2.
  93067. * You will need to pass the name of the uniform as well as the value.
  93068. */
  93069. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93070. /**
  93071. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93072. * This is dynamic to allow compat with webgl 1 and 2.
  93073. * You will need to pass the name of the uniform as well as the value.
  93074. */
  93075. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93076. /**
  93077. * Lambda to Update a single float in a uniform buffer.
  93078. * This is dynamic to allow compat with webgl 1 and 2.
  93079. * You will need to pass the name of the uniform as well as the value.
  93080. */
  93081. updateFloat: (name: string, x: number) => void;
  93082. /**
  93083. * Lambda to Update a vec2 of float in a uniform buffer.
  93084. * This is dynamic to allow compat with webgl 1 and 2.
  93085. * You will need to pass the name of the uniform as well as the value.
  93086. */
  93087. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93088. /**
  93089. * Lambda to Update a vec3 of float in a uniform buffer.
  93090. * This is dynamic to allow compat with webgl 1 and 2.
  93091. * You will need to pass the name of the uniform as well as the value.
  93092. */
  93093. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93094. /**
  93095. * Lambda to Update a vec4 of float in a uniform buffer.
  93096. * This is dynamic to allow compat with webgl 1 and 2.
  93097. * You will need to pass the name of the uniform as well as the value.
  93098. */
  93099. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93100. /**
  93101. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93102. * This is dynamic to allow compat with webgl 1 and 2.
  93103. * You will need to pass the name of the uniform as well as the value.
  93104. */
  93105. updateMatrix: (name: string, mat: Matrix) => void;
  93106. /**
  93107. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93108. * This is dynamic to allow compat with webgl 1 and 2.
  93109. * You will need to pass the name of the uniform as well as the value.
  93110. */
  93111. updateVector3: (name: string, vector: Vector3) => void;
  93112. /**
  93113. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93114. * This is dynamic to allow compat with webgl 1 and 2.
  93115. * You will need to pass the name of the uniform as well as the value.
  93116. */
  93117. updateVector4: (name: string, vector: Vector4) => void;
  93118. /**
  93119. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93120. * This is dynamic to allow compat with webgl 1 and 2.
  93121. * You will need to pass the name of the uniform as well as the value.
  93122. */
  93123. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93124. /**
  93125. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93126. * This is dynamic to allow compat with webgl 1 and 2.
  93127. * You will need to pass the name of the uniform as well as the value.
  93128. */
  93129. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93130. /**
  93131. * Instantiates a new Uniform buffer objects.
  93132. *
  93133. * Handles blocks of uniform on the GPU.
  93134. *
  93135. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93136. *
  93137. * For more information, please refer to :
  93138. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93139. * @param engine Define the engine the buffer is associated with
  93140. * @param data Define the data contained in the buffer
  93141. * @param dynamic Define if the buffer is updatable
  93142. */
  93143. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  93144. /**
  93145. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93146. * or just falling back on setUniformXXX calls.
  93147. */
  93148. readonly useUbo: boolean;
  93149. /**
  93150. * Indicates if the WebGL underlying uniform buffer is in sync
  93151. * with the javascript cache data.
  93152. */
  93153. readonly isSync: boolean;
  93154. /**
  93155. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93156. * Also, a dynamic UniformBuffer will disable cache verification and always
  93157. * update the underlying WebGL uniform buffer to the GPU.
  93158. * @returns if Dynamic, otherwise false
  93159. */
  93160. isDynamic(): boolean;
  93161. /**
  93162. * The data cache on JS side.
  93163. * @returns the underlying data as a float array
  93164. */
  93165. getData(): Float32Array;
  93166. /**
  93167. * The underlying WebGL Uniform buffer.
  93168. * @returns the webgl buffer
  93169. */
  93170. getBuffer(): Nullable<DataBuffer>;
  93171. /**
  93172. * std140 layout specifies how to align data within an UBO structure.
  93173. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93174. * for specs.
  93175. */
  93176. private _fillAlignment;
  93177. /**
  93178. * Adds an uniform in the buffer.
  93179. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93180. * for the layout to be correct !
  93181. * @param name Name of the uniform, as used in the uniform block in the shader.
  93182. * @param size Data size, or data directly.
  93183. */
  93184. addUniform(name: string, size: number | number[]): void;
  93185. /**
  93186. * Adds a Matrix 4x4 to the uniform buffer.
  93187. * @param name Name of the uniform, as used in the uniform block in the shader.
  93188. * @param mat A 4x4 matrix.
  93189. */
  93190. addMatrix(name: string, mat: Matrix): void;
  93191. /**
  93192. * Adds a vec2 to the uniform buffer.
  93193. * @param name Name of the uniform, as used in the uniform block in the shader.
  93194. * @param x Define the x component value of the vec2
  93195. * @param y Define the y component value of the vec2
  93196. */
  93197. addFloat2(name: string, x: number, y: number): void;
  93198. /**
  93199. * Adds a vec3 to the uniform buffer.
  93200. * @param name Name of the uniform, as used in the uniform block in the shader.
  93201. * @param x Define the x component value of the vec3
  93202. * @param y Define the y component value of the vec3
  93203. * @param z Define the z component value of the vec3
  93204. */
  93205. addFloat3(name: string, x: number, y: number, z: number): void;
  93206. /**
  93207. * Adds a vec3 to the uniform buffer.
  93208. * @param name Name of the uniform, as used in the uniform block in the shader.
  93209. * @param color Define the vec3 from a Color
  93210. */
  93211. addColor3(name: string, color: Color3): void;
  93212. /**
  93213. * Adds a vec4 to the uniform buffer.
  93214. * @param name Name of the uniform, as used in the uniform block in the shader.
  93215. * @param color Define the rgb components from a Color
  93216. * @param alpha Define the a component of the vec4
  93217. */
  93218. addColor4(name: string, color: Color3, alpha: number): void;
  93219. /**
  93220. * Adds a vec3 to the uniform buffer.
  93221. * @param name Name of the uniform, as used in the uniform block in the shader.
  93222. * @param vector Define the vec3 components from a Vector
  93223. */
  93224. addVector3(name: string, vector: Vector3): void;
  93225. /**
  93226. * Adds a Matrix 3x3 to the uniform buffer.
  93227. * @param name Name of the uniform, as used in the uniform block in the shader.
  93228. */
  93229. addMatrix3x3(name: string): void;
  93230. /**
  93231. * Adds a Matrix 2x2 to the uniform buffer.
  93232. * @param name Name of the uniform, as used in the uniform block in the shader.
  93233. */
  93234. addMatrix2x2(name: string): void;
  93235. /**
  93236. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93237. */
  93238. create(): void;
  93239. /** @hidden */
  93240. _rebuild(): void;
  93241. /**
  93242. * Updates the WebGL Uniform Buffer on the GPU.
  93243. * If the `dynamic` flag is set to true, no cache comparison is done.
  93244. * Otherwise, the buffer will be updated only if the cache differs.
  93245. */
  93246. update(): void;
  93247. /**
  93248. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93249. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93250. * @param data Define the flattened data
  93251. * @param size Define the size of the data.
  93252. */
  93253. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93254. private _updateMatrix3x3ForUniform;
  93255. private _updateMatrix3x3ForEffect;
  93256. private _updateMatrix2x2ForEffect;
  93257. private _updateMatrix2x2ForUniform;
  93258. private _updateFloatForEffect;
  93259. private _updateFloatForUniform;
  93260. private _updateFloat2ForEffect;
  93261. private _updateFloat2ForUniform;
  93262. private _updateFloat3ForEffect;
  93263. private _updateFloat3ForUniform;
  93264. private _updateFloat4ForEffect;
  93265. private _updateFloat4ForUniform;
  93266. private _updateMatrixForEffect;
  93267. private _updateMatrixForUniform;
  93268. private _updateVector3ForEffect;
  93269. private _updateVector3ForUniform;
  93270. private _updateVector4ForEffect;
  93271. private _updateVector4ForUniform;
  93272. private _updateColor3ForEffect;
  93273. private _updateColor3ForUniform;
  93274. private _updateColor4ForEffect;
  93275. private _updateColor4ForUniform;
  93276. /**
  93277. * Sets a sampler uniform on the effect.
  93278. * @param name Define the name of the sampler.
  93279. * @param texture Define the texture to set in the sampler
  93280. */
  93281. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93282. /**
  93283. * Directly updates the value of the uniform in the cache AND on the GPU.
  93284. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93285. * @param data Define the flattened data
  93286. */
  93287. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93288. /**
  93289. * Binds this uniform buffer to an effect.
  93290. * @param effect Define the effect to bind the buffer to
  93291. * @param name Name of the uniform block in the shader.
  93292. */
  93293. bindToEffect(effect: Effect, name: string): void;
  93294. /**
  93295. * Disposes the uniform buffer.
  93296. */
  93297. dispose(): void;
  93298. }
  93299. }
  93300. declare module BABYLON {
  93301. /**
  93302. * Class used to work with sound analyzer using fast fourier transform (FFT)
  93303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93304. */
  93305. export class Analyser {
  93306. /**
  93307. * Gets or sets the smoothing
  93308. * @ignorenaming
  93309. */
  93310. SMOOTHING: number;
  93311. /**
  93312. * Gets or sets the FFT table size
  93313. * @ignorenaming
  93314. */
  93315. FFT_SIZE: number;
  93316. /**
  93317. * Gets or sets the bar graph amplitude
  93318. * @ignorenaming
  93319. */
  93320. BARGRAPHAMPLITUDE: number;
  93321. /**
  93322. * Gets or sets the position of the debug canvas
  93323. * @ignorenaming
  93324. */
  93325. DEBUGCANVASPOS: {
  93326. x: number;
  93327. y: number;
  93328. };
  93329. /**
  93330. * Gets or sets the debug canvas size
  93331. * @ignorenaming
  93332. */
  93333. DEBUGCANVASSIZE: {
  93334. width: number;
  93335. height: number;
  93336. };
  93337. private _byteFreqs;
  93338. private _byteTime;
  93339. private _floatFreqs;
  93340. private _webAudioAnalyser;
  93341. private _debugCanvas;
  93342. private _debugCanvasContext;
  93343. private _scene;
  93344. private _registerFunc;
  93345. private _audioEngine;
  93346. /**
  93347. * Creates a new analyser
  93348. * @param scene defines hosting scene
  93349. */
  93350. constructor(scene: Scene);
  93351. /**
  93352. * Get the number of data values you will have to play with for the visualization
  93353. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  93354. * @returns a number
  93355. */
  93356. getFrequencyBinCount(): number;
  93357. /**
  93358. * Gets the current frequency data as a byte array
  93359. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93360. * @returns a Uint8Array
  93361. */
  93362. getByteFrequencyData(): Uint8Array;
  93363. /**
  93364. * Gets the current waveform as a byte array
  93365. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  93366. * @returns a Uint8Array
  93367. */
  93368. getByteTimeDomainData(): Uint8Array;
  93369. /**
  93370. * Gets the current frequency data as a float array
  93371. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93372. * @returns a Float32Array
  93373. */
  93374. getFloatFrequencyData(): Float32Array;
  93375. /**
  93376. * Renders the debug canvas
  93377. */
  93378. drawDebugCanvas(): void;
  93379. /**
  93380. * Stops rendering the debug canvas and removes it
  93381. */
  93382. stopDebugCanvas(): void;
  93383. /**
  93384. * Connects two audio nodes
  93385. * @param inputAudioNode defines first node to connect
  93386. * @param outputAudioNode defines second node to connect
  93387. */
  93388. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  93389. /**
  93390. * Releases all associated resources
  93391. */
  93392. dispose(): void;
  93393. }
  93394. }
  93395. declare module BABYLON {
  93396. /**
  93397. * This represents an audio engine and it is responsible
  93398. * to play, synchronize and analyse sounds throughout the application.
  93399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93400. */
  93401. export interface IAudioEngine extends IDisposable {
  93402. /**
  93403. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93404. */
  93405. readonly canUseWebAudio: boolean;
  93406. /**
  93407. * Gets the current AudioContext if available.
  93408. */
  93409. readonly audioContext: Nullable<AudioContext>;
  93410. /**
  93411. * The master gain node defines the global audio volume of your audio engine.
  93412. */
  93413. readonly masterGain: GainNode;
  93414. /**
  93415. * Gets whether or not mp3 are supported by your browser.
  93416. */
  93417. readonly isMP3supported: boolean;
  93418. /**
  93419. * Gets whether or not ogg are supported by your browser.
  93420. */
  93421. readonly isOGGsupported: boolean;
  93422. /**
  93423. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93424. * @ignoreNaming
  93425. */
  93426. WarnedWebAudioUnsupported: boolean;
  93427. /**
  93428. * Defines if the audio engine relies on a custom unlocked button.
  93429. * In this case, the embedded button will not be displayed.
  93430. */
  93431. useCustomUnlockedButton: boolean;
  93432. /**
  93433. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  93434. */
  93435. readonly unlocked: boolean;
  93436. /**
  93437. * Event raised when audio has been unlocked on the browser.
  93438. */
  93439. onAudioUnlockedObservable: Observable<AudioEngine>;
  93440. /**
  93441. * Event raised when audio has been locked on the browser.
  93442. */
  93443. onAudioLockedObservable: Observable<AudioEngine>;
  93444. /**
  93445. * Flags the audio engine in Locked state.
  93446. * This happens due to new browser policies preventing audio to autoplay.
  93447. */
  93448. lock(): void;
  93449. /**
  93450. * Unlocks the audio engine once a user action has been done on the dom.
  93451. * This is helpful to resume play once browser policies have been satisfied.
  93452. */
  93453. unlock(): void;
  93454. }
  93455. /**
  93456. * This represents the default audio engine used in babylon.
  93457. * It is responsible to play, synchronize and analyse sounds throughout the application.
  93458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93459. */
  93460. export class AudioEngine implements IAudioEngine {
  93461. private _audioContext;
  93462. private _audioContextInitialized;
  93463. private _muteButton;
  93464. private _hostElement;
  93465. /**
  93466. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93467. */
  93468. canUseWebAudio: boolean;
  93469. /**
  93470. * The master gain node defines the global audio volume of your audio engine.
  93471. */
  93472. masterGain: GainNode;
  93473. /**
  93474. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93475. * @ignoreNaming
  93476. */
  93477. WarnedWebAudioUnsupported: boolean;
  93478. /**
  93479. * Gets whether or not mp3 are supported by your browser.
  93480. */
  93481. isMP3supported: boolean;
  93482. /**
  93483. * Gets whether or not ogg are supported by your browser.
  93484. */
  93485. isOGGsupported: boolean;
  93486. /**
  93487. * Gets whether audio has been unlocked on the device.
  93488. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  93489. * a user interaction has happened.
  93490. */
  93491. unlocked: boolean;
  93492. /**
  93493. * Defines if the audio engine relies on a custom unlocked button.
  93494. * In this case, the embedded button will not be displayed.
  93495. */
  93496. useCustomUnlockedButton: boolean;
  93497. /**
  93498. * Event raised when audio has been unlocked on the browser.
  93499. */
  93500. onAudioUnlockedObservable: Observable<AudioEngine>;
  93501. /**
  93502. * Event raised when audio has been locked on the browser.
  93503. */
  93504. onAudioLockedObservable: Observable<AudioEngine>;
  93505. /**
  93506. * Gets the current AudioContext if available.
  93507. */
  93508. readonly audioContext: Nullable<AudioContext>;
  93509. private _connectedAnalyser;
  93510. /**
  93511. * Instantiates a new audio engine.
  93512. *
  93513. * There should be only one per page as some browsers restrict the number
  93514. * of audio contexts you can create.
  93515. * @param hostElement defines the host element where to display the mute icon if necessary
  93516. */
  93517. constructor(hostElement?: Nullable<HTMLElement>);
  93518. /**
  93519. * Flags the audio engine in Locked state.
  93520. * This happens due to new browser policies preventing audio to autoplay.
  93521. */
  93522. lock(): void;
  93523. /**
  93524. * Unlocks the audio engine once a user action has been done on the dom.
  93525. * This is helpful to resume play once browser policies have been satisfied.
  93526. */
  93527. unlock(): void;
  93528. private _resumeAudioContext;
  93529. private _initializeAudioContext;
  93530. private _tryToRun;
  93531. private _triggerRunningState;
  93532. private _triggerSuspendedState;
  93533. private _displayMuteButton;
  93534. private _moveButtonToTopLeft;
  93535. private _onResize;
  93536. private _hideMuteButton;
  93537. /**
  93538. * Destroy and release the resources associated with the audio ccontext.
  93539. */
  93540. dispose(): void;
  93541. /**
  93542. * Gets the global volume sets on the master gain.
  93543. * @returns the global volume if set or -1 otherwise
  93544. */
  93545. getGlobalVolume(): number;
  93546. /**
  93547. * Sets the global volume of your experience (sets on the master gain).
  93548. * @param newVolume Defines the new global volume of the application
  93549. */
  93550. setGlobalVolume(newVolume: number): void;
  93551. /**
  93552. * Connect the audio engine to an audio analyser allowing some amazing
  93553. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93555. * @param analyser The analyser to connect to the engine
  93556. */
  93557. connectToAnalyser(analyser: Analyser): void;
  93558. }
  93559. }
  93560. declare module BABYLON {
  93561. /**
  93562. * Interface used to present a loading screen while loading a scene
  93563. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93564. */
  93565. export interface ILoadingScreen {
  93566. /**
  93567. * Function called to display the loading screen
  93568. */
  93569. displayLoadingUI: () => void;
  93570. /**
  93571. * Function called to hide the loading screen
  93572. */
  93573. hideLoadingUI: () => void;
  93574. /**
  93575. * Gets or sets the color to use for the background
  93576. */
  93577. loadingUIBackgroundColor: string;
  93578. /**
  93579. * Gets or sets the text to display while loading
  93580. */
  93581. loadingUIText: string;
  93582. }
  93583. /**
  93584. * Class used for the default loading screen
  93585. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93586. */
  93587. export class DefaultLoadingScreen implements ILoadingScreen {
  93588. private _renderingCanvas;
  93589. private _loadingText;
  93590. private _loadingDivBackgroundColor;
  93591. private _loadingDiv;
  93592. private _loadingTextDiv;
  93593. /** Gets or sets the logo url to use for the default loading screen */
  93594. static DefaultLogoUrl: string;
  93595. /** Gets or sets the spinner url to use for the default loading screen */
  93596. static DefaultSpinnerUrl: string;
  93597. /**
  93598. * Creates a new default loading screen
  93599. * @param _renderingCanvas defines the canvas used to render the scene
  93600. * @param _loadingText defines the default text to display
  93601. * @param _loadingDivBackgroundColor defines the default background color
  93602. */
  93603. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  93604. /**
  93605. * Function called to display the loading screen
  93606. */
  93607. displayLoadingUI(): void;
  93608. /**
  93609. * Function called to hide the loading screen
  93610. */
  93611. hideLoadingUI(): void;
  93612. /**
  93613. * Gets or sets the text to display while loading
  93614. */
  93615. loadingUIText: string;
  93616. /**
  93617. * Gets or sets the color to use for the background
  93618. */
  93619. loadingUIBackgroundColor: string;
  93620. private _resizeLoadingUI;
  93621. }
  93622. }
  93623. declare module BABYLON {
  93624. /** @hidden */
  93625. export class WebGLPipelineContext implements IPipelineContext {
  93626. engine: Engine;
  93627. program: Nullable<WebGLProgram>;
  93628. context?: WebGLRenderingContext;
  93629. vertexShader?: WebGLShader;
  93630. fragmentShader?: WebGLShader;
  93631. isParallelCompiled: boolean;
  93632. onCompiled?: () => void;
  93633. transformFeedback?: WebGLTransformFeedback | null;
  93634. readonly isAsync: boolean;
  93635. readonly isReady: boolean;
  93636. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93637. }
  93638. }
  93639. declare module BABYLON {
  93640. /** @hidden */
  93641. export class WebGLDataBuffer extends DataBuffer {
  93642. private _buffer;
  93643. constructor(resource: WebGLBuffer);
  93644. readonly underlyingResource: any;
  93645. }
  93646. }
  93647. declare module BABYLON {
  93648. /** @hidden */
  93649. export class WebGL2ShaderProcessor implements IShaderProcessor {
  93650. attributeProcessor(attribute: string): string;
  93651. varyingProcessor(varying: string, isFragment: boolean): string;
  93652. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  93653. }
  93654. }
  93655. declare module BABYLON {
  93656. /**
  93657. * This class is used to track a performance counter which is number based.
  93658. * The user has access to many properties which give statistics of different nature.
  93659. *
  93660. * The implementer can track two kinds of Performance Counter: time and count.
  93661. * 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.
  93662. * 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.
  93663. */
  93664. export class PerfCounter {
  93665. /**
  93666. * Gets or sets a global boolean to turn on and off all the counters
  93667. */
  93668. static Enabled: boolean;
  93669. /**
  93670. * Returns the smallest value ever
  93671. */
  93672. readonly min: number;
  93673. /**
  93674. * Returns the biggest value ever
  93675. */
  93676. readonly max: number;
  93677. /**
  93678. * Returns the average value since the performance counter is running
  93679. */
  93680. readonly average: number;
  93681. /**
  93682. * Returns the average value of the last second the counter was monitored
  93683. */
  93684. readonly lastSecAverage: number;
  93685. /**
  93686. * Returns the current value
  93687. */
  93688. readonly current: number;
  93689. /**
  93690. * Gets the accumulated total
  93691. */
  93692. readonly total: number;
  93693. /**
  93694. * Gets the total value count
  93695. */
  93696. readonly count: number;
  93697. /**
  93698. * Creates a new counter
  93699. */
  93700. constructor();
  93701. /**
  93702. * Call this method to start monitoring a new frame.
  93703. * 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.
  93704. */
  93705. fetchNewFrame(): void;
  93706. /**
  93707. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93708. * @param newCount the count value to add to the monitored count
  93709. * @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.
  93710. */
  93711. addCount(newCount: number, fetchResult: boolean): void;
  93712. /**
  93713. * Start monitoring this performance counter
  93714. */
  93715. beginMonitoring(): void;
  93716. /**
  93717. * Compute the time lapsed since the previous beginMonitoring() call.
  93718. * @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
  93719. */
  93720. endMonitoring(newFrame?: boolean): void;
  93721. private _fetchResult;
  93722. private _startMonitoringTime;
  93723. private _min;
  93724. private _max;
  93725. private _average;
  93726. private _current;
  93727. private _totalValueCount;
  93728. private _totalAccumulated;
  93729. private _lastSecAverage;
  93730. private _lastSecAccumulated;
  93731. private _lastSecTime;
  93732. private _lastSecValueCount;
  93733. }
  93734. }
  93735. declare module BABYLON {
  93736. /**
  93737. * Interface for any object that can request an animation frame
  93738. */
  93739. export interface ICustomAnimationFrameRequester {
  93740. /**
  93741. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93742. */
  93743. renderFunction?: Function;
  93744. /**
  93745. * Called to request the next frame to render to
  93746. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93747. */
  93748. requestAnimationFrame: Function;
  93749. /**
  93750. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93751. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93752. */
  93753. requestID?: number;
  93754. }
  93755. }
  93756. declare module BABYLON {
  93757. /**
  93758. * Settings for finer control over video usage
  93759. */
  93760. export interface VideoTextureSettings {
  93761. /**
  93762. * Applies `autoplay` to video, if specified
  93763. */
  93764. autoPlay?: boolean;
  93765. /**
  93766. * Applies `loop` to video, if specified
  93767. */
  93768. loop?: boolean;
  93769. /**
  93770. * Automatically updates internal texture from video at every frame in the render loop
  93771. */
  93772. autoUpdateTexture: boolean;
  93773. /**
  93774. * Image src displayed during the video loading or until the user interacts with the video.
  93775. */
  93776. poster?: string;
  93777. }
  93778. /**
  93779. * If you want to display a video in your scene, this is the special texture for that.
  93780. * This special texture works similar to other textures, with the exception of a few parameters.
  93781. * @see https://doc.babylonjs.com/how_to/video_texture
  93782. */
  93783. export class VideoTexture extends Texture {
  93784. /**
  93785. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93786. */
  93787. readonly autoUpdateTexture: boolean;
  93788. /**
  93789. * The video instance used by the texture internally
  93790. */
  93791. readonly video: HTMLVideoElement;
  93792. private _onUserActionRequestedObservable;
  93793. /**
  93794. * Event triggerd when a dom action is required by the user to play the video.
  93795. * This happens due to recent changes in browser policies preventing video to auto start.
  93796. */
  93797. readonly onUserActionRequestedObservable: Observable<Texture>;
  93798. private _generateMipMaps;
  93799. private _engine;
  93800. private _stillImageCaptured;
  93801. private _displayingPosterTexture;
  93802. private _settings;
  93803. private _createInternalTextureOnEvent;
  93804. /**
  93805. * Creates a video texture.
  93806. * If you want to display a video in your scene, this is the special texture for that.
  93807. * This special texture works similar to other textures, with the exception of a few parameters.
  93808. * @see https://doc.babylonjs.com/how_to/video_texture
  93809. * @param name optional name, will detect from video source, if not defined
  93810. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93811. * @param scene is obviously the current scene.
  93812. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93813. * @param invertY is false by default but can be used to invert video on Y axis
  93814. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93815. * @param settings allows finer control over video usage
  93816. */
  93817. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93818. private _getName;
  93819. private _getVideo;
  93820. private _createInternalTexture;
  93821. private reset;
  93822. /**
  93823. * @hidden Internal method to initiate `update`.
  93824. */
  93825. _rebuild(): void;
  93826. /**
  93827. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93828. */
  93829. update(): void;
  93830. /**
  93831. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  93832. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  93833. */
  93834. updateTexture(isVisible: boolean): void;
  93835. protected _updateInternalTexture: () => void;
  93836. /**
  93837. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  93838. * @param url New url.
  93839. */
  93840. updateURL(url: string): void;
  93841. /**
  93842. * Dispose the texture and release its associated resources.
  93843. */
  93844. dispose(): void;
  93845. /**
  93846. * Creates a video texture straight from a stream.
  93847. * @param scene Define the scene the texture should be created in
  93848. * @param stream Define the stream the texture should be created from
  93849. * @returns The created video texture as a promise
  93850. */
  93851. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  93852. /**
  93853. * Creates a video texture straight from your WebCam video feed.
  93854. * @param scene Define the scene the texture should be created in
  93855. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93856. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93857. * @returns The created video texture as a promise
  93858. */
  93859. static CreateFromWebCamAsync(scene: Scene, constraints: {
  93860. minWidth: number;
  93861. maxWidth: number;
  93862. minHeight: number;
  93863. maxHeight: number;
  93864. deviceId: string;
  93865. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  93866. /**
  93867. * Creates a video texture straight from your WebCam video feed.
  93868. * @param scene Define the scene the texture should be created in
  93869. * @param onReady Define a callback to triggered once the texture will be ready
  93870. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93871. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93872. */
  93873. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  93874. minWidth: number;
  93875. maxWidth: number;
  93876. minHeight: number;
  93877. maxHeight: number;
  93878. deviceId: string;
  93879. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  93880. }
  93881. }
  93882. declare module BABYLON {
  93883. /**
  93884. * Defines the interface used by objects containing a viewport (like a camera)
  93885. */
  93886. interface IViewportOwnerLike {
  93887. /**
  93888. * Gets or sets the viewport
  93889. */
  93890. viewport: IViewportLike;
  93891. }
  93892. /**
  93893. * Interface for attribute information associated with buffer instanciation
  93894. */
  93895. export class InstancingAttributeInfo {
  93896. /**
  93897. * Index/offset of the attribute in the vertex shader
  93898. */
  93899. index: number;
  93900. /**
  93901. * size of the attribute, 1, 2, 3 or 4
  93902. */
  93903. attributeSize: number;
  93904. /**
  93905. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  93906. * default is FLOAT
  93907. */
  93908. attribyteType: number;
  93909. /**
  93910. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  93911. */
  93912. normalized: boolean;
  93913. /**
  93914. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  93915. */
  93916. offset: number;
  93917. /**
  93918. * Name of the GLSL attribute, for debugging purpose only
  93919. */
  93920. attributeName: string;
  93921. }
  93922. /**
  93923. * Define options used to create a depth texture
  93924. */
  93925. export class DepthTextureCreationOptions {
  93926. /** Specifies whether or not a stencil should be allocated in the texture */
  93927. generateStencil?: boolean;
  93928. /** Specifies whether or not bilinear filtering is enable on the texture */
  93929. bilinearFiltering?: boolean;
  93930. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  93931. comparisonFunction?: number;
  93932. /** Specifies if the created texture is a cube texture */
  93933. isCube?: boolean;
  93934. }
  93935. /**
  93936. * Class used to describe the capabilities of the engine relatively to the current browser
  93937. */
  93938. export class EngineCapabilities {
  93939. /** Maximum textures units per fragment shader */
  93940. maxTexturesImageUnits: number;
  93941. /** Maximum texture units per vertex shader */
  93942. maxVertexTextureImageUnits: number;
  93943. /** Maximum textures units in the entire pipeline */
  93944. maxCombinedTexturesImageUnits: number;
  93945. /** Maximum texture size */
  93946. maxTextureSize: number;
  93947. /** Maximum cube texture size */
  93948. maxCubemapTextureSize: number;
  93949. /** Maximum render texture size */
  93950. maxRenderTextureSize: number;
  93951. /** Maximum number of vertex attributes */
  93952. maxVertexAttribs: number;
  93953. /** Maximum number of varyings */
  93954. maxVaryingVectors: number;
  93955. /** Maximum number of uniforms per vertex shader */
  93956. maxVertexUniformVectors: number;
  93957. /** Maximum number of uniforms per fragment shader */
  93958. maxFragmentUniformVectors: number;
  93959. /** Defines if standard derivates (dx/dy) are supported */
  93960. standardDerivatives: boolean;
  93961. /** Defines if s3tc texture compression is supported */
  93962. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  93963. /** Defines if pvrtc texture compression is supported */
  93964. pvrtc: any;
  93965. /** Defines if etc1 texture compression is supported */
  93966. etc1: any;
  93967. /** Defines if etc2 texture compression is supported */
  93968. etc2: any;
  93969. /** Defines if astc texture compression is supported */
  93970. astc: any;
  93971. /** Defines if float textures are supported */
  93972. textureFloat: boolean;
  93973. /** Defines if vertex array objects are supported */
  93974. vertexArrayObject: boolean;
  93975. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  93976. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  93977. /** Gets the maximum level of anisotropy supported */
  93978. maxAnisotropy: number;
  93979. /** Defines if instancing is supported */
  93980. instancedArrays: boolean;
  93981. /** Defines if 32 bits indices are supported */
  93982. uintIndices: boolean;
  93983. /** Defines if high precision shaders are supported */
  93984. highPrecisionShaderSupported: boolean;
  93985. /** Defines if depth reading in the fragment shader is supported */
  93986. fragmentDepthSupported: boolean;
  93987. /** Defines if float texture linear filtering is supported*/
  93988. textureFloatLinearFiltering: boolean;
  93989. /** Defines if rendering to float textures is supported */
  93990. textureFloatRender: boolean;
  93991. /** Defines if half float textures are supported*/
  93992. textureHalfFloat: boolean;
  93993. /** Defines if half float texture linear filtering is supported*/
  93994. textureHalfFloatLinearFiltering: boolean;
  93995. /** Defines if rendering to half float textures is supported */
  93996. textureHalfFloatRender: boolean;
  93997. /** Defines if textureLOD shader command is supported */
  93998. textureLOD: boolean;
  93999. /** Defines if draw buffers extension is supported */
  94000. drawBuffersExtension: boolean;
  94001. /** Defines if depth textures are supported */
  94002. depthTextureExtension: boolean;
  94003. /** Defines if float color buffer are supported */
  94004. colorBufferFloat: boolean;
  94005. /** Gets disjoint timer query extension (null if not supported) */
  94006. timerQuery: EXT_disjoint_timer_query;
  94007. /** Defines if timestamp can be used with timer query */
  94008. canUseTimestampForTimerQuery: boolean;
  94009. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  94010. multiview: any;
  94011. /** Function used to let the system compiles shaders in background */
  94012. parallelShaderCompile: {
  94013. COMPLETION_STATUS_KHR: number;
  94014. };
  94015. /** Max number of texture samples for MSAA */
  94016. maxMSAASamples: number;
  94017. }
  94018. /** Interface defining initialization parameters for Engine class */
  94019. export interface EngineOptions extends WebGLContextAttributes {
  94020. /**
  94021. * Defines if the engine should no exceed a specified device ratio
  94022. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  94023. */
  94024. limitDeviceRatio?: number;
  94025. /**
  94026. * Defines if webvr should be enabled automatically
  94027. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94028. */
  94029. autoEnableWebVR?: boolean;
  94030. /**
  94031. * Defines if webgl2 should be turned off even if supported
  94032. * @see http://doc.babylonjs.com/features/webgl2
  94033. */
  94034. disableWebGL2Support?: boolean;
  94035. /**
  94036. * Defines if webaudio should be initialized as well
  94037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94038. */
  94039. audioEngine?: boolean;
  94040. /**
  94041. * Defines if animations should run using a deterministic lock step
  94042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94043. */
  94044. deterministicLockstep?: boolean;
  94045. /** Defines the maximum steps to use with deterministic lock step mode */
  94046. lockstepMaxSteps?: number;
  94047. /**
  94048. * Defines that engine should ignore context lost events
  94049. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  94050. */
  94051. doNotHandleContextLost?: boolean;
  94052. /**
  94053. * Defines that engine should ignore modifying touch action attribute and style
  94054. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  94055. */
  94056. doNotHandleTouchAction?: boolean;
  94057. /**
  94058. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  94059. */
  94060. useHighPrecisionFloats?: boolean;
  94061. }
  94062. /**
  94063. * Defines the interface used by display changed events
  94064. */
  94065. export interface IDisplayChangedEventArgs {
  94066. /** Gets the vrDisplay object (if any) */
  94067. vrDisplay: Nullable<any>;
  94068. /** Gets a boolean indicating if webVR is supported */
  94069. vrSupported: boolean;
  94070. }
  94071. /**
  94072. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  94073. */
  94074. export class Engine {
  94075. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  94076. static ExceptionList: ({
  94077. key: string;
  94078. capture: string;
  94079. captureConstraint: number;
  94080. targets: string[];
  94081. } | {
  94082. key: string;
  94083. capture: null;
  94084. captureConstraint: null;
  94085. targets: string[];
  94086. })[];
  94087. /** Gets the list of created engines */
  94088. static readonly Instances: Engine[];
  94089. /**
  94090. * Gets the latest created engine
  94091. */
  94092. static readonly LastCreatedEngine: Nullable<Engine>;
  94093. /**
  94094. * Gets the latest created scene
  94095. */
  94096. static readonly LastCreatedScene: Nullable<Scene>;
  94097. /**
  94098. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  94099. * @param flag defines which part of the materials must be marked as dirty
  94100. * @param predicate defines a predicate used to filter which materials should be affected
  94101. */
  94102. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  94103. /** @hidden */
  94104. static _TextureLoaders: IInternalTextureLoader[];
  94105. /** Defines that alpha blending is disabled */
  94106. static readonly ALPHA_DISABLE: number;
  94107. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  94108. static readonly ALPHA_ADD: number;
  94109. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  94110. static readonly ALPHA_COMBINE: number;
  94111. /** Defines that alpha blending to DEST - SRC * DEST */
  94112. static readonly ALPHA_SUBTRACT: number;
  94113. /** Defines that alpha blending to SRC * DEST */
  94114. static readonly ALPHA_MULTIPLY: number;
  94115. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  94116. static readonly ALPHA_MAXIMIZED: number;
  94117. /** Defines that alpha blending to SRC + DEST */
  94118. static readonly ALPHA_ONEONE: number;
  94119. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  94120. static readonly ALPHA_PREMULTIPLIED: number;
  94121. /**
  94122. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  94123. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  94124. */
  94125. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  94126. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  94127. static readonly ALPHA_INTERPOLATE: number;
  94128. /**
  94129. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  94130. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  94131. */
  94132. static readonly ALPHA_SCREENMODE: number;
  94133. /** Defines that the ressource is not delayed*/
  94134. static readonly DELAYLOADSTATE_NONE: number;
  94135. /** Defines that the ressource was successfully delay loaded */
  94136. static readonly DELAYLOADSTATE_LOADED: number;
  94137. /** Defines that the ressource is currently delay loading */
  94138. static readonly DELAYLOADSTATE_LOADING: number;
  94139. /** Defines that the ressource is delayed and has not started loading */
  94140. static readonly DELAYLOADSTATE_NOTLOADED: number;
  94141. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  94142. static readonly NEVER: number;
  94143. /** 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 */
  94144. static readonly ALWAYS: number;
  94145. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  94146. static readonly LESS: number;
  94147. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  94148. static readonly EQUAL: number;
  94149. /** 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 */
  94150. static readonly LEQUAL: number;
  94151. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  94152. static readonly GREATER: number;
  94153. /** 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 */
  94154. static readonly GEQUAL: number;
  94155. /** 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 */
  94156. static readonly NOTEQUAL: number;
  94157. /** Passed to stencilOperation to specify that stencil value must be kept */
  94158. static readonly KEEP: number;
  94159. /** Passed to stencilOperation to specify that stencil value must be replaced */
  94160. static readonly REPLACE: number;
  94161. /** Passed to stencilOperation to specify that stencil value must be incremented */
  94162. static readonly INCR: number;
  94163. /** Passed to stencilOperation to specify that stencil value must be decremented */
  94164. static readonly DECR: number;
  94165. /** Passed to stencilOperation to specify that stencil value must be inverted */
  94166. static readonly INVERT: number;
  94167. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  94168. static readonly INCR_WRAP: number;
  94169. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  94170. static readonly DECR_WRAP: number;
  94171. /** Texture is not repeating outside of 0..1 UVs */
  94172. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  94173. /** Texture is repeating outside of 0..1 UVs */
  94174. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  94175. /** Texture is repeating and mirrored */
  94176. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  94177. /** ALPHA */
  94178. static readonly TEXTUREFORMAT_ALPHA: number;
  94179. /** LUMINANCE */
  94180. static readonly TEXTUREFORMAT_LUMINANCE: number;
  94181. /** LUMINANCE_ALPHA */
  94182. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  94183. /** RGB */
  94184. static readonly TEXTUREFORMAT_RGB: number;
  94185. /** RGBA */
  94186. static readonly TEXTUREFORMAT_RGBA: number;
  94187. /** RED */
  94188. static readonly TEXTUREFORMAT_RED: number;
  94189. /** RED (2nd reference) */
  94190. static readonly TEXTUREFORMAT_R: number;
  94191. /** RG */
  94192. static readonly TEXTUREFORMAT_RG: number;
  94193. /** RED_INTEGER */
  94194. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  94195. /** RED_INTEGER (2nd reference) */
  94196. static readonly TEXTUREFORMAT_R_INTEGER: number;
  94197. /** RG_INTEGER */
  94198. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  94199. /** RGB_INTEGER */
  94200. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  94201. /** RGBA_INTEGER */
  94202. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  94203. /** UNSIGNED_BYTE */
  94204. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  94205. /** UNSIGNED_BYTE (2nd reference) */
  94206. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  94207. /** FLOAT */
  94208. static readonly TEXTURETYPE_FLOAT: number;
  94209. /** HALF_FLOAT */
  94210. static readonly TEXTURETYPE_HALF_FLOAT: number;
  94211. /** BYTE */
  94212. static readonly TEXTURETYPE_BYTE: number;
  94213. /** SHORT */
  94214. static readonly TEXTURETYPE_SHORT: number;
  94215. /** UNSIGNED_SHORT */
  94216. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  94217. /** INT */
  94218. static readonly TEXTURETYPE_INT: number;
  94219. /** UNSIGNED_INT */
  94220. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  94221. /** UNSIGNED_SHORT_4_4_4_4 */
  94222. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  94223. /** UNSIGNED_SHORT_5_5_5_1 */
  94224. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  94225. /** UNSIGNED_SHORT_5_6_5 */
  94226. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  94227. /** UNSIGNED_INT_2_10_10_10_REV */
  94228. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  94229. /** UNSIGNED_INT_24_8 */
  94230. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  94231. /** UNSIGNED_INT_10F_11F_11F_REV */
  94232. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  94233. /** UNSIGNED_INT_5_9_9_9_REV */
  94234. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  94235. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  94236. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  94237. /** nearest is mag = nearest and min = nearest and mip = linear */
  94238. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  94239. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94240. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  94241. /** Trilinear is mag = linear and min = linear and mip = linear */
  94242. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  94243. /** nearest is mag = nearest and min = nearest and mip = linear */
  94244. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  94245. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94246. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  94247. /** Trilinear is mag = linear and min = linear and mip = linear */
  94248. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  94249. /** mag = nearest and min = nearest and mip = nearest */
  94250. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  94251. /** mag = nearest and min = linear and mip = nearest */
  94252. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  94253. /** mag = nearest and min = linear and mip = linear */
  94254. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  94255. /** mag = nearest and min = linear and mip = none */
  94256. static readonly TEXTURE_NEAREST_LINEAR: number;
  94257. /** mag = nearest and min = nearest and mip = none */
  94258. static readonly TEXTURE_NEAREST_NEAREST: number;
  94259. /** mag = linear and min = nearest and mip = nearest */
  94260. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  94261. /** mag = linear and min = nearest and mip = linear */
  94262. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  94263. /** mag = linear and min = linear and mip = none */
  94264. static readonly TEXTURE_LINEAR_LINEAR: number;
  94265. /** mag = linear and min = nearest and mip = none */
  94266. static readonly TEXTURE_LINEAR_NEAREST: number;
  94267. /** Explicit coordinates mode */
  94268. static readonly TEXTURE_EXPLICIT_MODE: number;
  94269. /** Spherical coordinates mode */
  94270. static readonly TEXTURE_SPHERICAL_MODE: number;
  94271. /** Planar coordinates mode */
  94272. static readonly TEXTURE_PLANAR_MODE: number;
  94273. /** Cubic coordinates mode */
  94274. static readonly TEXTURE_CUBIC_MODE: number;
  94275. /** Projection coordinates mode */
  94276. static readonly TEXTURE_PROJECTION_MODE: number;
  94277. /** Skybox coordinates mode */
  94278. static readonly TEXTURE_SKYBOX_MODE: number;
  94279. /** Inverse Cubic coordinates mode */
  94280. static readonly TEXTURE_INVCUBIC_MODE: number;
  94281. /** Equirectangular coordinates mode */
  94282. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  94283. /** Equirectangular Fixed coordinates mode */
  94284. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  94285. /** Equirectangular Fixed Mirrored coordinates mode */
  94286. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94287. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  94288. static readonly SCALEMODE_FLOOR: number;
  94289. /** Defines that texture rescaling will look for the nearest power of 2 size */
  94290. static readonly SCALEMODE_NEAREST: number;
  94291. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  94292. static readonly SCALEMODE_CEILING: number;
  94293. /**
  94294. * Returns the current npm package of the sdk
  94295. */
  94296. static readonly NpmPackage: string;
  94297. /**
  94298. * Returns the current version of the framework
  94299. */
  94300. static readonly Version: string;
  94301. /**
  94302. * Returns a string describing the current engine
  94303. */
  94304. readonly description: string;
  94305. /**
  94306. * Gets or sets the epsilon value used by collision engine
  94307. */
  94308. static CollisionsEpsilon: number;
  94309. /**
  94310. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94311. */
  94312. static ShadersRepository: string;
  94313. /**
  94314. * Method called to create the default loading screen.
  94315. * This can be overriden in your own app.
  94316. * @param canvas The rendering canvas element
  94317. * @returns The loading screen
  94318. */
  94319. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  94320. /**
  94321. * Method called to create the default rescale post process on each engine.
  94322. */
  94323. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  94324. /** @hidden */
  94325. _shaderProcessor: IShaderProcessor;
  94326. /**
  94327. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  94328. */
  94329. forcePOTTextures: boolean;
  94330. /**
  94331. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  94332. */
  94333. isFullscreen: boolean;
  94334. /**
  94335. * Gets a boolean indicating if the pointer is currently locked
  94336. */
  94337. isPointerLock: boolean;
  94338. /**
  94339. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  94340. */
  94341. cullBackFaces: boolean;
  94342. /**
  94343. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  94344. */
  94345. renderEvenInBackground: boolean;
  94346. /**
  94347. * Gets or sets a boolean indicating that cache can be kept between frames
  94348. */
  94349. preventCacheWipeBetweenFrames: boolean;
  94350. /**
  94351. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  94352. **/
  94353. enableOfflineSupport: boolean;
  94354. /**
  94355. * 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)
  94356. **/
  94357. disableManifestCheck: boolean;
  94358. /**
  94359. * Gets the list of created scenes
  94360. */
  94361. scenes: Scene[];
  94362. /**
  94363. * Event raised when a new scene is created
  94364. */
  94365. onNewSceneAddedObservable: Observable<Scene>;
  94366. /**
  94367. * Gets the list of created postprocesses
  94368. */
  94369. postProcesses: PostProcess[];
  94370. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  94371. validateShaderPrograms: boolean;
  94372. /**
  94373. * Observable event triggered each time the rendering canvas is resized
  94374. */
  94375. onResizeObservable: Observable<Engine>;
  94376. /**
  94377. * Observable event triggered each time the canvas loses focus
  94378. */
  94379. onCanvasBlurObservable: Observable<Engine>;
  94380. /**
  94381. * Observable event triggered each time the canvas gains focus
  94382. */
  94383. onCanvasFocusObservable: Observable<Engine>;
  94384. /**
  94385. * Observable event triggered each time the canvas receives pointerout event
  94386. */
  94387. onCanvasPointerOutObservable: Observable<PointerEvent>;
  94388. /**
  94389. * Observable event triggered before each texture is initialized
  94390. */
  94391. onBeforeTextureInitObservable: Observable<Texture>;
  94392. /**
  94393. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  94394. */
  94395. disableUniformBuffers: boolean;
  94396. /** @hidden */
  94397. _uniformBuffers: UniformBuffer[];
  94398. /**
  94399. * Gets a boolean indicating that the engine supports uniform buffers
  94400. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94401. */
  94402. readonly supportsUniformBuffers: boolean;
  94403. /**
  94404. * Observable raised when the engine begins a new frame
  94405. */
  94406. onBeginFrameObservable: Observable<Engine>;
  94407. /**
  94408. * If set, will be used to request the next animation frame for the render loop
  94409. */
  94410. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  94411. /**
  94412. * Observable raised when the engine ends the current frame
  94413. */
  94414. onEndFrameObservable: Observable<Engine>;
  94415. /**
  94416. * Observable raised when the engine is about to compile a shader
  94417. */
  94418. onBeforeShaderCompilationObservable: Observable<Engine>;
  94419. /**
  94420. * Observable raised when the engine has jsut compiled a shader
  94421. */
  94422. onAfterShaderCompilationObservable: Observable<Engine>;
  94423. /** @hidden */
  94424. _gl: WebGLRenderingContext;
  94425. private _renderingCanvas;
  94426. private _windowIsBackground;
  94427. private _webGLVersion;
  94428. protected _highPrecisionShadersAllowed: boolean;
  94429. /** @hidden */
  94430. readonly _shouldUseHighPrecisionShader: boolean;
  94431. /**
  94432. * Gets a boolean indicating that only power of 2 textures are supported
  94433. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  94434. */
  94435. readonly needPOTTextures: boolean;
  94436. /** @hidden */
  94437. _badOS: boolean;
  94438. /** @hidden */
  94439. _badDesktopOS: boolean;
  94440. /**
  94441. * Gets the audio engine
  94442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94443. * @ignorenaming
  94444. */
  94445. static audioEngine: IAudioEngine;
  94446. /**
  94447. * Default AudioEngine factory responsible of creating the Audio Engine.
  94448. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  94449. */
  94450. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  94451. /**
  94452. * Default offline support factory responsible of creating a tool used to store data locally.
  94453. * By default, this will create a Database object if the workload has been embedded.
  94454. */
  94455. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  94456. private _onFocus;
  94457. private _onBlur;
  94458. private _onCanvasPointerOut;
  94459. private _onCanvasBlur;
  94460. private _onCanvasFocus;
  94461. private _onFullscreenChange;
  94462. private _onPointerLockChange;
  94463. private _hardwareScalingLevel;
  94464. /** @hidden */
  94465. _caps: EngineCapabilities;
  94466. private _pointerLockRequested;
  94467. private _isStencilEnable;
  94468. private _colorWrite;
  94469. private _loadingScreen;
  94470. /** @hidden */
  94471. _drawCalls: PerfCounter;
  94472. private _glVersion;
  94473. private _glRenderer;
  94474. private _glVendor;
  94475. private _videoTextureSupported;
  94476. private _renderingQueueLaunched;
  94477. private _activeRenderLoops;
  94478. private _deterministicLockstep;
  94479. private _lockstepMaxSteps;
  94480. /**
  94481. * Observable signaled when a context lost event is raised
  94482. */
  94483. onContextLostObservable: Observable<Engine>;
  94484. /**
  94485. * Observable signaled when a context restored event is raised
  94486. */
  94487. onContextRestoredObservable: Observable<Engine>;
  94488. private _onContextLost;
  94489. private _onContextRestored;
  94490. private _contextWasLost;
  94491. /** @hidden */
  94492. _doNotHandleContextLost: boolean;
  94493. /**
  94494. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  94495. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  94496. */
  94497. doNotHandleContextLost: boolean;
  94498. private _performanceMonitor;
  94499. private _fps;
  94500. private _deltaTime;
  94501. /**
  94502. * Turn this value on if you want to pause FPS computation when in background
  94503. */
  94504. disablePerformanceMonitorInBackground: boolean;
  94505. /**
  94506. * Gets the performance monitor attached to this engine
  94507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  94508. */
  94509. readonly performanceMonitor: PerformanceMonitor;
  94510. /**
  94511. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  94512. */
  94513. disableVertexArrayObjects: boolean;
  94514. /** @hidden */
  94515. protected _depthCullingState: _DepthCullingState;
  94516. /** @hidden */
  94517. protected _stencilState: _StencilState;
  94518. /** @hidden */
  94519. protected _alphaState: _AlphaState;
  94520. /** @hidden */
  94521. protected _alphaMode: number;
  94522. /** @hidden */
  94523. _internalTexturesCache: InternalTexture[];
  94524. /** @hidden */
  94525. protected _activeChannel: number;
  94526. private _currentTextureChannel;
  94527. /** @hidden */
  94528. protected _boundTexturesCache: {
  94529. [key: string]: Nullable<InternalTexture>;
  94530. };
  94531. /** @hidden */
  94532. protected _currentEffect: Nullable<Effect>;
  94533. /** @hidden */
  94534. protected _currentProgram: Nullable<WebGLProgram>;
  94535. private _compiledEffects;
  94536. private _vertexAttribArraysEnabled;
  94537. /** @hidden */
  94538. protected _cachedViewport: Nullable<IViewportLike>;
  94539. private _cachedVertexArrayObject;
  94540. /** @hidden */
  94541. protected _cachedVertexBuffers: any;
  94542. /** @hidden */
  94543. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  94544. /** @hidden */
  94545. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  94546. /** @hidden */
  94547. _currentRenderTarget: Nullable<InternalTexture>;
  94548. private _uintIndicesCurrentlySet;
  94549. private _currentBoundBuffer;
  94550. /** @hidden */
  94551. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  94552. private _currentBufferPointers;
  94553. private _currentInstanceLocations;
  94554. private _currentInstanceBuffers;
  94555. private _textureUnits;
  94556. /** @hidden */
  94557. _workingCanvas: Nullable<HTMLCanvasElement>;
  94558. /** @hidden */
  94559. _workingContext: Nullable<CanvasRenderingContext2D>;
  94560. private _rescalePostProcess;
  94561. private _dummyFramebuffer;
  94562. private _externalData;
  94563. /** @hidden */
  94564. _bindedRenderFunction: any;
  94565. private _vaoRecordInProgress;
  94566. private _mustWipeVertexAttributes;
  94567. private _emptyTexture;
  94568. private _emptyCubeTexture;
  94569. private _emptyTexture3D;
  94570. /** @hidden */
  94571. _frameHandler: number;
  94572. private _nextFreeTextureSlots;
  94573. private _maxSimultaneousTextures;
  94574. private _activeRequests;
  94575. private _texturesSupported;
  94576. /** @hidden */
  94577. _textureFormatInUse: Nullable<string>;
  94578. /**
  94579. * Gets the list of texture formats supported
  94580. */
  94581. readonly texturesSupported: Array<string>;
  94582. /**
  94583. * Gets the list of texture formats in use
  94584. */
  94585. readonly textureFormatInUse: Nullable<string>;
  94586. /**
  94587. * Gets the current viewport
  94588. */
  94589. readonly currentViewport: Nullable<IViewportLike>;
  94590. /**
  94591. * Gets the default empty texture
  94592. */
  94593. readonly emptyTexture: InternalTexture;
  94594. /**
  94595. * Gets the default empty 3D texture
  94596. */
  94597. readonly emptyTexture3D: InternalTexture;
  94598. /**
  94599. * Gets the default empty cube texture
  94600. */
  94601. readonly emptyCubeTexture: InternalTexture;
  94602. /**
  94603. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  94604. */
  94605. readonly premultipliedAlpha: boolean;
  94606. /**
  94607. * Creates a new engine
  94608. * @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
  94609. * @param antialias defines enable antialiasing (default: false)
  94610. * @param options defines further options to be sent to the getContext() function
  94611. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  94612. */
  94613. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  94614. /**
  94615. * Initializes a webVR display and starts listening to display change events
  94616. * The onVRDisplayChangedObservable will be notified upon these changes
  94617. * @returns The onVRDisplayChangedObservable
  94618. */
  94619. initWebVR(): Observable<IDisplayChangedEventArgs>;
  94620. /** @hidden */
  94621. _prepareVRComponent(): void;
  94622. /** @hidden */
  94623. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  94624. /** @hidden */
  94625. _submitVRFrame(): void;
  94626. /**
  94627. * Call this function to leave webVR mode
  94628. * Will do nothing if webVR is not supported or if there is no webVR device
  94629. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94630. */
  94631. disableVR(): void;
  94632. /**
  94633. * Gets a boolean indicating that the system is in VR mode and is presenting
  94634. * @returns true if VR mode is engaged
  94635. */
  94636. isVRPresenting(): boolean;
  94637. /** @hidden */
  94638. _requestVRFrame(): void;
  94639. private _disableTouchAction;
  94640. private _rebuildInternalTextures;
  94641. private _rebuildEffects;
  94642. /**
  94643. * Gets a boolean indicating if all created effects are ready
  94644. * @returns true if all effects are ready
  94645. */
  94646. areAllEffectsReady(): boolean;
  94647. private _rebuildBuffers;
  94648. private _initGLContext;
  94649. /**
  94650. * Gets version of the current webGL context
  94651. */
  94652. readonly webGLVersion: number;
  94653. /**
  94654. * Gets a string idenfifying the name of the class
  94655. * @returns "Engine" string
  94656. */
  94657. getClassName(): string;
  94658. /**
  94659. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  94660. */
  94661. readonly isStencilEnable: boolean;
  94662. /** @hidden */
  94663. _prepareWorkingCanvas(): void;
  94664. /**
  94665. * Reset the texture cache to empty state
  94666. */
  94667. resetTextureCache(): void;
  94668. /**
  94669. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94670. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94671. * @returns true if engine is in deterministic lock step mode
  94672. */
  94673. isDeterministicLockStep(): boolean;
  94674. /**
  94675. * Gets the max steps when engine is running in deterministic lock step
  94676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94677. * @returns the max steps
  94678. */
  94679. getLockstepMaxSteps(): number;
  94680. /**
  94681. * Gets an object containing information about the current webGL context
  94682. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94683. */
  94684. getGlInfo(): {
  94685. vendor: string;
  94686. renderer: string;
  94687. version: string;
  94688. };
  94689. /**
  94690. * Gets current aspect ratio
  94691. * @param viewportOwner defines the camera to use to get the aspect ratio
  94692. * @param useScreen defines if screen size must be used (or the current render target if any)
  94693. * @returns a number defining the aspect ratio
  94694. */
  94695. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  94696. /**
  94697. * Gets current screen aspect ratio
  94698. * @returns a number defining the aspect ratio
  94699. */
  94700. getScreenAspectRatio(): number;
  94701. /**
  94702. * Gets the current render width
  94703. * @param useScreen defines if screen size must be used (or the current render target if any)
  94704. * @returns a number defining the current render width
  94705. */
  94706. getRenderWidth(useScreen?: boolean): number;
  94707. /**
  94708. * Gets the current render height
  94709. * @param useScreen defines if screen size must be used (or the current render target if any)
  94710. * @returns a number defining the current render height
  94711. */
  94712. getRenderHeight(useScreen?: boolean): number;
  94713. /**
  94714. * Gets the HTML canvas attached with the current webGL context
  94715. * @returns a HTML canvas
  94716. */
  94717. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  94718. /**
  94719. * Gets host window
  94720. * @returns the host window object
  94721. */
  94722. getHostWindow(): Window;
  94723. /**
  94724. * Gets host document
  94725. * @returns the host document object
  94726. */
  94727. getHostDocument(): Document;
  94728. /**
  94729. * Gets the client rect of the HTML canvas attached with the current webGL context
  94730. * @returns a client rectanglee
  94731. */
  94732. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  94733. /**
  94734. * Defines the hardware scaling level.
  94735. * By default the hardware scaling level is computed from the window device ratio.
  94736. * 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.
  94737. * @param level defines the level to use
  94738. */
  94739. setHardwareScalingLevel(level: number): void;
  94740. /**
  94741. * Gets the current hardware scaling level.
  94742. * By default the hardware scaling level is computed from the window device ratio.
  94743. * 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.
  94744. * @returns a number indicating the current hardware scaling level
  94745. */
  94746. getHardwareScalingLevel(): number;
  94747. /**
  94748. * Gets the list of loaded textures
  94749. * @returns an array containing all loaded textures
  94750. */
  94751. getLoadedTexturesCache(): InternalTexture[];
  94752. /**
  94753. * Gets the object containing all engine capabilities
  94754. * @returns the EngineCapabilities object
  94755. */
  94756. getCaps(): EngineCapabilities;
  94757. /**
  94758. * Gets the current depth function
  94759. * @returns a number defining the depth function
  94760. */
  94761. getDepthFunction(): Nullable<number>;
  94762. /**
  94763. * Sets the current depth function
  94764. * @param depthFunc defines the function to use
  94765. */
  94766. setDepthFunction(depthFunc: number): void;
  94767. /**
  94768. * Sets the current depth function to GREATER
  94769. */
  94770. setDepthFunctionToGreater(): void;
  94771. /**
  94772. * Sets the current depth function to GEQUAL
  94773. */
  94774. setDepthFunctionToGreaterOrEqual(): void;
  94775. /**
  94776. * Sets the current depth function to LESS
  94777. */
  94778. setDepthFunctionToLess(): void;
  94779. private _cachedStencilBuffer;
  94780. private _cachedStencilFunction;
  94781. private _cachedStencilMask;
  94782. private _cachedStencilOperationPass;
  94783. private _cachedStencilOperationFail;
  94784. private _cachedStencilOperationDepthFail;
  94785. private _cachedStencilReference;
  94786. /**
  94787. * Caches the the state of the stencil buffer
  94788. */
  94789. cacheStencilState(): void;
  94790. /**
  94791. * Restores the state of the stencil buffer
  94792. */
  94793. restoreStencilState(): void;
  94794. /**
  94795. * Sets the current depth function to LEQUAL
  94796. */
  94797. setDepthFunctionToLessOrEqual(): void;
  94798. /**
  94799. * Gets a boolean indicating if stencil buffer is enabled
  94800. * @returns the current stencil buffer state
  94801. */
  94802. getStencilBuffer(): boolean;
  94803. /**
  94804. * Enable or disable the stencil buffer
  94805. * @param enable defines if the stencil buffer must be enabled or disabled
  94806. */
  94807. setStencilBuffer(enable: boolean): void;
  94808. /**
  94809. * Gets the current stencil mask
  94810. * @returns a number defining the new stencil mask to use
  94811. */
  94812. getStencilMask(): number;
  94813. /**
  94814. * Sets the current stencil mask
  94815. * @param mask defines the new stencil mask to use
  94816. */
  94817. setStencilMask(mask: number): void;
  94818. /**
  94819. * Gets the current stencil function
  94820. * @returns a number defining the stencil function to use
  94821. */
  94822. getStencilFunction(): number;
  94823. /**
  94824. * Gets the current stencil reference value
  94825. * @returns a number defining the stencil reference value to use
  94826. */
  94827. getStencilFunctionReference(): number;
  94828. /**
  94829. * Gets the current stencil mask
  94830. * @returns a number defining the stencil mask to use
  94831. */
  94832. getStencilFunctionMask(): number;
  94833. /**
  94834. * Sets the current stencil function
  94835. * @param stencilFunc defines the new stencil function to use
  94836. */
  94837. setStencilFunction(stencilFunc: number): void;
  94838. /**
  94839. * Sets the current stencil reference
  94840. * @param reference defines the new stencil reference to use
  94841. */
  94842. setStencilFunctionReference(reference: number): void;
  94843. /**
  94844. * Sets the current stencil mask
  94845. * @param mask defines the new stencil mask to use
  94846. */
  94847. setStencilFunctionMask(mask: number): void;
  94848. /**
  94849. * Gets the current stencil operation when stencil fails
  94850. * @returns a number defining stencil operation to use when stencil fails
  94851. */
  94852. getStencilOperationFail(): number;
  94853. /**
  94854. * Gets the current stencil operation when depth fails
  94855. * @returns a number defining stencil operation to use when depth fails
  94856. */
  94857. getStencilOperationDepthFail(): number;
  94858. /**
  94859. * Gets the current stencil operation when stencil passes
  94860. * @returns a number defining stencil operation to use when stencil passes
  94861. */
  94862. getStencilOperationPass(): number;
  94863. /**
  94864. * Sets the stencil operation to use when stencil fails
  94865. * @param operation defines the stencil operation to use when stencil fails
  94866. */
  94867. setStencilOperationFail(operation: number): void;
  94868. /**
  94869. * Sets the stencil operation to use when depth fails
  94870. * @param operation defines the stencil operation to use when depth fails
  94871. */
  94872. setStencilOperationDepthFail(operation: number): void;
  94873. /**
  94874. * Sets the stencil operation to use when stencil passes
  94875. * @param operation defines the stencil operation to use when stencil passes
  94876. */
  94877. setStencilOperationPass(operation: number): void;
  94878. /**
  94879. * Sets a boolean indicating if the dithering state is enabled or disabled
  94880. * @param value defines the dithering state
  94881. */
  94882. setDitheringState(value: boolean): void;
  94883. /**
  94884. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  94885. * @param value defines the rasterizer state
  94886. */
  94887. setRasterizerState(value: boolean): void;
  94888. /**
  94889. * stop executing a render loop function and remove it from the execution array
  94890. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  94891. */
  94892. stopRenderLoop(renderFunction?: () => void): void;
  94893. /** @hidden */
  94894. _renderLoop(): void;
  94895. /**
  94896. * Register and execute a render loop. The engine can have more than one render function
  94897. * @param renderFunction defines the function to continuously execute
  94898. */
  94899. runRenderLoop(renderFunction: () => void): void;
  94900. /**
  94901. * Toggle full screen mode
  94902. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94903. */
  94904. switchFullscreen(requestPointerLock: boolean): void;
  94905. /**
  94906. * Enters full screen mode
  94907. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94908. */
  94909. enterFullscreen(requestPointerLock: boolean): void;
  94910. /**
  94911. * Exits full screen mode
  94912. */
  94913. exitFullscreen(): void;
  94914. /**
  94915. * Enters Pointerlock mode
  94916. */
  94917. enterPointerlock(): void;
  94918. /**
  94919. * Exits Pointerlock mode
  94920. */
  94921. exitPointerlock(): void;
  94922. /**
  94923. * Clear the current render buffer or the current render target (if any is set up)
  94924. * @param color defines the color to use
  94925. * @param backBuffer defines if the back buffer must be cleared
  94926. * @param depth defines if the depth buffer must be cleared
  94927. * @param stencil defines if the stencil buffer must be cleared
  94928. */
  94929. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  94930. /**
  94931. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  94932. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94933. * @param y defines the y-coordinate of the corner of the clear rectangle
  94934. * @param width defines the width of the clear rectangle
  94935. * @param height defines the height of the clear rectangle
  94936. * @param clearColor defines the clear color
  94937. */
  94938. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  94939. /**
  94940. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  94941. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94942. * @param y defines the y-coordinate of the corner of the clear rectangle
  94943. * @param width defines the width of the clear rectangle
  94944. * @param height defines the height of the clear rectangle
  94945. */
  94946. enableScissor(x: number, y: number, width: number, height: number): void;
  94947. /**
  94948. * Disable previously set scissor test rectangle
  94949. */
  94950. disableScissor(): void;
  94951. private _viewportCached;
  94952. /** @hidden */
  94953. _viewport(x: number, y: number, width: number, height: number): void;
  94954. /**
  94955. * Set the WebGL's viewport
  94956. * @param viewport defines the viewport element to be used
  94957. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  94958. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  94959. */
  94960. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  94961. /**
  94962. * Directly set the WebGL Viewport
  94963. * @param x defines the x coordinate of the viewport (in screen space)
  94964. * @param y defines the y coordinate of the viewport (in screen space)
  94965. * @param width defines the width of the viewport (in screen space)
  94966. * @param height defines the height of the viewport (in screen space)
  94967. * @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
  94968. */
  94969. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  94970. /**
  94971. * Begin a new frame
  94972. */
  94973. beginFrame(): void;
  94974. /**
  94975. * Enf the current frame
  94976. */
  94977. endFrame(): void;
  94978. /**
  94979. * Resize the view according to the canvas' size
  94980. */
  94981. resize(): void;
  94982. /**
  94983. * Force a specific size of the canvas
  94984. * @param width defines the new canvas' width
  94985. * @param height defines the new canvas' height
  94986. */
  94987. setSize(width: number, height: number): void;
  94988. /**
  94989. * Binds the frame buffer to the specified texture.
  94990. * @param texture The texture to render to or null for the default canvas
  94991. * @param faceIndex The face of the texture to render to in case of cube texture
  94992. * @param requiredWidth The width of the target to render to
  94993. * @param requiredHeight The height of the target to render to
  94994. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  94995. * @param depthStencilTexture The depth stencil texture to use to render
  94996. * @param lodLevel defines le lod level to bind to the frame buffer
  94997. */
  94998. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  94999. /** @hidden */
  95000. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95001. /**
  95002. * Unbind the current render target texture from the webGL context
  95003. * @param texture defines the render target texture to unbind
  95004. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95005. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95006. */
  95007. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95008. /**
  95009. * Force the mipmap generation for the given render target texture
  95010. * @param texture defines the render target texture to use
  95011. */
  95012. generateMipMapsForCubemap(texture: InternalTexture): void;
  95013. /**
  95014. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95015. */
  95016. flushFramebuffer(): void;
  95017. /**
  95018. * Unbind the current render target and bind the default framebuffer
  95019. */
  95020. restoreDefaultFramebuffer(): void;
  95021. /**
  95022. * Create an uniform buffer
  95023. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95024. * @param elements defines the content of the uniform buffer
  95025. * @returns the webGL uniform buffer
  95026. */
  95027. createUniformBuffer(elements: FloatArray): DataBuffer;
  95028. /**
  95029. * Create a dynamic uniform buffer
  95030. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95031. * @param elements defines the content of the uniform buffer
  95032. * @returns the webGL uniform buffer
  95033. */
  95034. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  95035. /**
  95036. * Update an existing uniform buffer
  95037. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95038. * @param uniformBuffer defines the target uniform buffer
  95039. * @param elements defines the content to update
  95040. * @param offset defines the offset in the uniform buffer where update should start
  95041. * @param count defines the size of the data to update
  95042. */
  95043. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  95044. private _resetVertexBufferBinding;
  95045. /**
  95046. * Creates a vertex buffer
  95047. * @param data the data for the vertex buffer
  95048. * @returns the new WebGL static buffer
  95049. */
  95050. createVertexBuffer(data: DataArray): DataBuffer;
  95051. /**
  95052. * Creates a dynamic vertex buffer
  95053. * @param data the data for the dynamic vertex buffer
  95054. * @returns the new WebGL dynamic buffer
  95055. */
  95056. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  95057. /**
  95058. * Update a dynamic index buffer
  95059. * @param indexBuffer defines the target index buffer
  95060. * @param indices defines the data to update
  95061. * @param offset defines the offset in the target index buffer where update should start
  95062. */
  95063. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95064. /**
  95065. * Updates a dynamic vertex buffer.
  95066. * @param vertexBuffer the vertex buffer to update
  95067. * @param data the data used to update the vertex buffer
  95068. * @param byteOffset the byte offset of the data
  95069. * @param byteLength the byte length of the data
  95070. */
  95071. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95072. private _resetIndexBufferBinding;
  95073. /**
  95074. * Creates a new index buffer
  95075. * @param indices defines the content of the index buffer
  95076. * @param updatable defines if the index buffer must be updatable
  95077. * @returns a new webGL buffer
  95078. */
  95079. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  95080. /**
  95081. * Bind a webGL buffer to the webGL context
  95082. * @param buffer defines the buffer to bind
  95083. */
  95084. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  95085. /**
  95086. * Bind an uniform buffer to the current webGL context
  95087. * @param buffer defines the buffer to bind
  95088. */
  95089. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  95090. /**
  95091. * Bind a buffer to the current webGL context at a given location
  95092. * @param buffer defines the buffer to bind
  95093. * @param location defines the index where to bind the buffer
  95094. */
  95095. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  95096. /**
  95097. * Bind a specific block at a given index in a specific shader program
  95098. * @param pipelineContext defines the pipeline context to use
  95099. * @param blockName defines the block name
  95100. * @param index defines the index where to bind the block
  95101. */
  95102. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  95103. private bindIndexBuffer;
  95104. private bindBuffer;
  95105. /**
  95106. * update the bound buffer with the given data
  95107. * @param data defines the data to update
  95108. */
  95109. updateArrayBuffer(data: Float32Array): void;
  95110. private _vertexAttribPointer;
  95111. private _bindIndexBufferWithCache;
  95112. private _bindVertexBuffersAttributes;
  95113. /**
  95114. * Records a vertex array object
  95115. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95116. * @param vertexBuffers defines the list of vertex buffers to store
  95117. * @param indexBuffer defines the index buffer to store
  95118. * @param effect defines the effect to store
  95119. * @returns the new vertex array object
  95120. */
  95121. recordVertexArrayObject(vertexBuffers: {
  95122. [key: string]: VertexBuffer;
  95123. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  95124. /**
  95125. * Bind a specific vertex array object
  95126. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95127. * @param vertexArrayObject defines the vertex array object to bind
  95128. * @param indexBuffer defines the index buffer to bind
  95129. */
  95130. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  95131. /**
  95132. * Bind webGl buffers directly to the webGL context
  95133. * @param vertexBuffer defines the vertex buffer to bind
  95134. * @param indexBuffer defines the index buffer to bind
  95135. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  95136. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  95137. * @param effect defines the effect associated with the vertex buffer
  95138. */
  95139. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  95140. private _unbindVertexArrayObject;
  95141. /**
  95142. * Bind a list of vertex buffers to the webGL context
  95143. * @param vertexBuffers defines the list of vertex buffers to bind
  95144. * @param indexBuffer defines the index buffer to bind
  95145. * @param effect defines the effect associated with the vertex buffers
  95146. */
  95147. bindBuffers(vertexBuffers: {
  95148. [key: string]: Nullable<VertexBuffer>;
  95149. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  95150. /**
  95151. * Unbind all instance attributes
  95152. */
  95153. unbindInstanceAttributes(): void;
  95154. /**
  95155. * Release and free the memory of a vertex array object
  95156. * @param vao defines the vertex array object to delete
  95157. */
  95158. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  95159. /** @hidden */
  95160. _releaseBuffer(buffer: DataBuffer): boolean;
  95161. /**
  95162. * Creates a webGL buffer to use with instanciation
  95163. * @param capacity defines the size of the buffer
  95164. * @returns the webGL buffer
  95165. */
  95166. createInstancesBuffer(capacity: number): DataBuffer;
  95167. /**
  95168. * Delete a webGL buffer used with instanciation
  95169. * @param buffer defines the webGL buffer to delete
  95170. */
  95171. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  95172. /**
  95173. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  95174. * @param instancesBuffer defines the webGL buffer to update and bind
  95175. * @param data defines the data to store in the buffer
  95176. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  95177. */
  95178. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  95179. /**
  95180. * Apply all cached states (depth, culling, stencil and alpha)
  95181. */
  95182. applyStates(): void;
  95183. /**
  95184. * Send a draw order
  95185. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95186. * @param indexStart defines the starting index
  95187. * @param indexCount defines the number of index to draw
  95188. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95189. */
  95190. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95191. /**
  95192. * Draw a list of points
  95193. * @param verticesStart defines the index of first vertex to draw
  95194. * @param verticesCount defines the count of vertices to draw
  95195. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95196. */
  95197. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95198. /**
  95199. * Draw a list of unindexed primitives
  95200. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95201. * @param verticesStart defines the index of first vertex to draw
  95202. * @param verticesCount defines the count of vertices to draw
  95203. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95204. */
  95205. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95206. /**
  95207. * Draw a list of indexed primitives
  95208. * @param fillMode defines the primitive to use
  95209. * @param indexStart defines the starting index
  95210. * @param indexCount defines the number of index to draw
  95211. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95212. */
  95213. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  95214. /**
  95215. * Draw a list of unindexed primitives
  95216. * @param fillMode defines the primitive to use
  95217. * @param verticesStart defines the index of first vertex to draw
  95218. * @param verticesCount defines the count of vertices to draw
  95219. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95220. */
  95221. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95222. private _drawMode;
  95223. /** @hidden */
  95224. _releaseEffect(effect: Effect): void;
  95225. /** @hidden */
  95226. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  95227. /**
  95228. * Create a new effect (used to store vertex/fragment shaders)
  95229. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  95230. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  95231. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  95232. * @param samplers defines an array of string used to represent textures
  95233. * @param defines defines the string containing the defines to use to compile the shaders
  95234. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  95235. * @param onCompiled defines a function to call when the effect creation is successful
  95236. * @param onError defines a function to call when the effect creation has failed
  95237. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  95238. * @returns the new Effect
  95239. */
  95240. 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;
  95241. private _compileShader;
  95242. private _compileRawShader;
  95243. /**
  95244. * Directly creates a webGL program
  95245. * @param pipelineContext defines the pipeline context to attach to
  95246. * @param vertexCode defines the vertex shader code to use
  95247. * @param fragmentCode defines the fragment shader code to use
  95248. * @param context defines the webGL context to use (if not set, the current one will be used)
  95249. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95250. * @returns the new webGL program
  95251. */
  95252. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95253. /**
  95254. * Creates a webGL program
  95255. * @param pipelineContext defines the pipeline context to attach to
  95256. * @param vertexCode defines the vertex shader code to use
  95257. * @param fragmentCode defines the fragment shader code to use
  95258. * @param defines defines the string containing the defines to use to compile the shaders
  95259. * @param context defines the webGL context to use (if not set, the current one will be used)
  95260. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95261. * @returns the new webGL program
  95262. */
  95263. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95264. /**
  95265. * Creates a new pipeline context
  95266. * @returns the new pipeline
  95267. */
  95268. createPipelineContext(): WebGLPipelineContext;
  95269. private _createShaderProgram;
  95270. private _finalizePipelineContext;
  95271. /** @hidden */
  95272. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  95273. /** @hidden */
  95274. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  95275. /** @hidden */
  95276. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  95277. /**
  95278. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  95279. * @param pipelineContext defines the pipeline context to use
  95280. * @param uniformsNames defines the list of uniform names
  95281. * @returns an array of webGL uniform locations
  95282. */
  95283. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  95284. /**
  95285. * Gets the lsit of active attributes for a given webGL program
  95286. * @param pipelineContext defines the pipeline context to use
  95287. * @param attributesNames defines the list of attribute names to get
  95288. * @returns an array of indices indicating the offset of each attribute
  95289. */
  95290. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  95291. /**
  95292. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  95293. * @param effect defines the effect to activate
  95294. */
  95295. enableEffect(effect: Nullable<Effect>): void;
  95296. /**
  95297. * Set the value of an uniform to an array of int32
  95298. * @param uniform defines the webGL uniform location where to store the value
  95299. * @param array defines the array of int32 to store
  95300. */
  95301. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95302. /**
  95303. * Set the value of an uniform to an array of int32 (stored as vec2)
  95304. * @param uniform defines the webGL uniform location where to store the value
  95305. * @param array defines the array of int32 to store
  95306. */
  95307. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95308. /**
  95309. * Set the value of an uniform to an array of int32 (stored as vec3)
  95310. * @param uniform defines the webGL uniform location where to store the value
  95311. * @param array defines the array of int32 to store
  95312. */
  95313. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95314. /**
  95315. * Set the value of an uniform to an array of int32 (stored as vec4)
  95316. * @param uniform defines the webGL uniform location where to store the value
  95317. * @param array defines the array of int32 to store
  95318. */
  95319. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95320. /**
  95321. * Set the value of an uniform to an array of float32
  95322. * @param uniform defines the webGL uniform location where to store the value
  95323. * @param array defines the array of float32 to store
  95324. */
  95325. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95326. /**
  95327. * Set the value of an uniform to an array of float32 (stored as vec2)
  95328. * @param uniform defines the webGL uniform location where to store the value
  95329. * @param array defines the array of float32 to store
  95330. */
  95331. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95332. /**
  95333. * Set the value of an uniform to an array of float32 (stored as vec3)
  95334. * @param uniform defines the webGL uniform location where to store the value
  95335. * @param array defines the array of float32 to store
  95336. */
  95337. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95338. /**
  95339. * Set the value of an uniform to an array of float32 (stored as vec4)
  95340. * @param uniform defines the webGL uniform location where to store the value
  95341. * @param array defines the array of float32 to store
  95342. */
  95343. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95344. /**
  95345. * Set the value of an uniform to an array of number
  95346. * @param uniform defines the webGL uniform location where to store the value
  95347. * @param array defines the array of number to store
  95348. */
  95349. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95350. /**
  95351. * Set the value of an uniform to an array of number (stored as vec2)
  95352. * @param uniform defines the webGL uniform location where to store the value
  95353. * @param array defines the array of number to store
  95354. */
  95355. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95356. /**
  95357. * Set the value of an uniform to an array of number (stored as vec3)
  95358. * @param uniform defines the webGL uniform location where to store the value
  95359. * @param array defines the array of number to store
  95360. */
  95361. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95362. /**
  95363. * Set the value of an uniform to an array of number (stored as vec4)
  95364. * @param uniform defines the webGL uniform location where to store the value
  95365. * @param array defines the array of number to store
  95366. */
  95367. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95368. /**
  95369. * Set the value of an uniform to an array of float32 (stored as matrices)
  95370. * @param uniform defines the webGL uniform location where to store the value
  95371. * @param matrices defines the array of float32 to store
  95372. */
  95373. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  95374. /**
  95375. * Set the value of an uniform to a matrix (3x3)
  95376. * @param uniform defines the webGL uniform location where to store the value
  95377. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  95378. */
  95379. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95380. /**
  95381. * Set the value of an uniform to a matrix (2x2)
  95382. * @param uniform defines the webGL uniform location where to store the value
  95383. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  95384. */
  95385. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95386. /**
  95387. * Set the value of an uniform to a number (int)
  95388. * @param uniform defines the webGL uniform location where to store the value
  95389. * @param value defines the int number to store
  95390. */
  95391. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95392. /**
  95393. * Set the value of an uniform to a number (float)
  95394. * @param uniform defines the webGL uniform location where to store the value
  95395. * @param value defines the float number to store
  95396. */
  95397. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95398. /**
  95399. * Set the value of an uniform to a vec2
  95400. * @param uniform defines the webGL uniform location where to store the value
  95401. * @param x defines the 1st component of the value
  95402. * @param y defines the 2nd component of the value
  95403. */
  95404. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  95405. /**
  95406. * Set the value of an uniform to a vec3
  95407. * @param uniform defines the webGL uniform location where to store the value
  95408. * @param x defines the 1st component of the value
  95409. * @param y defines the 2nd component of the value
  95410. * @param z defines the 3rd component of the value
  95411. */
  95412. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  95413. /**
  95414. * Set the value of an uniform to a boolean
  95415. * @param uniform defines the webGL uniform location where to store the value
  95416. * @param bool defines the boolean to store
  95417. */
  95418. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  95419. /**
  95420. * Set the value of an uniform to a vec4
  95421. * @param uniform defines the webGL uniform location where to store the value
  95422. * @param x defines the 1st component of the value
  95423. * @param y defines the 2nd component of the value
  95424. * @param z defines the 3rd component of the value
  95425. * @param w defines the 4th component of the value
  95426. */
  95427. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  95428. /**
  95429. * Sets a Color4 on a uniform variable
  95430. * @param uniform defines the uniform location
  95431. * @param color4 defines the value to be set
  95432. */
  95433. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  95434. /**
  95435. * Set various states to the webGL context
  95436. * @param culling defines backface culling state
  95437. * @param zOffset defines the value to apply to zOffset (0 by default)
  95438. * @param force defines if states must be applied even if cache is up to date
  95439. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  95440. */
  95441. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  95442. /**
  95443. * Set the z offset to apply to current rendering
  95444. * @param value defines the offset to apply
  95445. */
  95446. setZOffset(value: number): void;
  95447. /**
  95448. * Gets the current value of the zOffset
  95449. * @returns the current zOffset state
  95450. */
  95451. getZOffset(): number;
  95452. /**
  95453. * Enable or disable depth buffering
  95454. * @param enable defines the state to set
  95455. */
  95456. setDepthBuffer(enable: boolean): void;
  95457. /**
  95458. * Gets a boolean indicating if depth writing is enabled
  95459. * @returns the current depth writing state
  95460. */
  95461. getDepthWrite(): boolean;
  95462. /**
  95463. * Enable or disable depth writing
  95464. * @param enable defines the state to set
  95465. */
  95466. setDepthWrite(enable: boolean): void;
  95467. /**
  95468. * Enable or disable color writing
  95469. * @param enable defines the state to set
  95470. */
  95471. setColorWrite(enable: boolean): void;
  95472. /**
  95473. * Gets a boolean indicating if color writing is enabled
  95474. * @returns the current color writing state
  95475. */
  95476. getColorWrite(): boolean;
  95477. /**
  95478. * Sets alpha constants used by some alpha blending modes
  95479. * @param r defines the red component
  95480. * @param g defines the green component
  95481. * @param b defines the blue component
  95482. * @param a defines the alpha component
  95483. */
  95484. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  95485. /**
  95486. * Sets the current alpha mode
  95487. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  95488. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  95489. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95490. */
  95491. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  95492. /**
  95493. * Gets the current alpha mode
  95494. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95495. * @returns the current alpha mode
  95496. */
  95497. getAlphaMode(): number;
  95498. /**
  95499. * Clears the list of texture accessible through engine.
  95500. * This can help preventing texture load conflict due to name collision.
  95501. */
  95502. clearInternalTexturesCache(): void;
  95503. /**
  95504. * Force the entire cache to be cleared
  95505. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  95506. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  95507. */
  95508. wipeCaches(bruteForce?: boolean): void;
  95509. /**
  95510. * Set the compressed texture format to use, based on the formats you have, and the formats
  95511. * supported by the hardware / browser.
  95512. *
  95513. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  95514. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  95515. * to API arguments needed to compressed textures. This puts the burden on the container
  95516. * generator to house the arcane code for determining these for current & future formats.
  95517. *
  95518. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  95519. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  95520. *
  95521. * Note: The result of this call is not taken into account when a texture is base64.
  95522. *
  95523. * @param formatsAvailable defines the list of those format families you have created
  95524. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  95525. *
  95526. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  95527. * @returns The extension selected.
  95528. */
  95529. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  95530. /** @hidden */
  95531. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  95532. min: number;
  95533. mag: number;
  95534. };
  95535. /** @hidden */
  95536. _createTexture(): WebGLTexture;
  95537. /**
  95538. * Usually called from Texture.ts.
  95539. * Passed information to create a WebGLTexture
  95540. * @param urlArg defines a value which contains one of the following:
  95541. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  95542. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  95543. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  95544. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  95545. * @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)
  95546. * @param scene needed for loading to the correct scene
  95547. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  95548. * @param onLoad optional callback to be called upon successful completion
  95549. * @param onError optional callback to be called upon failure
  95550. * @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
  95551. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  95552. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  95553. * @param forcedExtension defines the extension to use to pick the right loader
  95554. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  95555. * @returns a InternalTexture for assignment back into BABYLON.Texture
  95556. */
  95557. 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;
  95558. /**
  95559. * @hidden
  95560. * Rescales a texture
  95561. * @param source input texutre
  95562. * @param destination destination texture
  95563. * @param scene scene to use to render the resize
  95564. * @param internalFormat format to use when resizing
  95565. * @param onComplete callback to be called when resize has completed
  95566. */
  95567. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  95568. private _unpackFlipYCached;
  95569. /**
  95570. * In case you are sharing the context with other applications, it might
  95571. * be interested to not cache the unpack flip y state to ensure a consistent
  95572. * value would be set.
  95573. */
  95574. enableUnpackFlipYCached: boolean;
  95575. /** @hidden */
  95576. _unpackFlipY(value: boolean): void;
  95577. /** @hidden */
  95578. _getUnpackAlignement(): number;
  95579. /**
  95580. * Creates a dynamic texture
  95581. * @param width defines the width of the texture
  95582. * @param height defines the height of the texture
  95583. * @param generateMipMaps defines if the engine should generate the mip levels
  95584. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95585. * @returns the dynamic texture inside an InternalTexture
  95586. */
  95587. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  95588. /**
  95589. * Update the sampling mode of a given texture
  95590. * @param samplingMode defines the required sampling mode
  95591. * @param texture defines the texture to update
  95592. */
  95593. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  95594. /**
  95595. * Update the content of a dynamic texture
  95596. * @param texture defines the texture to update
  95597. * @param canvas defines the canvas containing the source
  95598. * @param invertY defines if data must be stored with Y axis inverted
  95599. * @param premulAlpha defines if alpha is stored as premultiplied
  95600. * @param format defines the format of the data
  95601. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  95602. */
  95603. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  95604. /**
  95605. * Update a video texture
  95606. * @param texture defines the texture to update
  95607. * @param video defines the video element to use
  95608. * @param invertY defines if data must be stored with Y axis inverted
  95609. */
  95610. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95611. /**
  95612. * Updates a depth texture Comparison Mode and Function.
  95613. * If the comparison Function is equal to 0, the mode will be set to none.
  95614. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  95615. * @param texture The texture to set the comparison function for
  95616. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  95617. */
  95618. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  95619. /** @hidden */
  95620. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  95621. width: number;
  95622. height: number;
  95623. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  95624. /**
  95625. * Creates a depth stencil texture.
  95626. * This is only available in WebGL 2 or with the depth texture extension available.
  95627. * @param size The size of face edge in the texture.
  95628. * @param options The options defining the texture.
  95629. * @returns The texture
  95630. */
  95631. createDepthStencilTexture(size: number | {
  95632. width: number;
  95633. height: number;
  95634. }, options: DepthTextureCreationOptions): InternalTexture;
  95635. /**
  95636. * Creates a depth stencil texture.
  95637. * This is only available in WebGL 2 or with the depth texture extension available.
  95638. * @param size The size of face edge in the texture.
  95639. * @param options The options defining the texture.
  95640. * @returns The texture
  95641. */
  95642. private _createDepthStencilTexture;
  95643. /**
  95644. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  95645. * @param renderTarget The render target to set the frame buffer for
  95646. */
  95647. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  95648. /**
  95649. * Creates a new render target texture
  95650. * @param size defines the size of the texture
  95651. * @param options defines the options used to create the texture
  95652. * @returns a new render target texture stored in an InternalTexture
  95653. */
  95654. createRenderTargetTexture(size: number | {
  95655. width: number;
  95656. height: number;
  95657. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  95658. /** @hidden */
  95659. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  95660. /**
  95661. * Updates the sample count of a render target texture
  95662. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  95663. * @param texture defines the texture to update
  95664. * @param samples defines the sample count to set
  95665. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  95666. */
  95667. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  95668. /** @hidden */
  95669. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95670. /** @hidden */
  95671. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95672. /** @hidden */
  95673. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95674. /** @hidden */
  95675. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95676. /**
  95677. * @hidden
  95678. */
  95679. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95680. private _prepareWebGLTextureContinuation;
  95681. private _prepareWebGLTexture;
  95682. /** @hidden */
  95683. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95684. /** @hidden */
  95685. _releaseFramebufferObjects(texture: InternalTexture): void;
  95686. /** @hidden */
  95687. _releaseTexture(texture: InternalTexture): void;
  95688. private setProgram;
  95689. private _boundUniforms;
  95690. /**
  95691. * Binds an effect to the webGL context
  95692. * @param effect defines the effect to bind
  95693. */
  95694. bindSamplers(effect: Effect): void;
  95695. private _activateCurrentTexture;
  95696. /** @hidden */
  95697. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  95698. /** @hidden */
  95699. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  95700. /**
  95701. * Sets a texture to the webGL context from a postprocess
  95702. * @param channel defines the channel to use
  95703. * @param postProcess defines the source postprocess
  95704. */
  95705. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  95706. /**
  95707. * Binds the output of the passed in post process to the texture channel specified
  95708. * @param channel The channel the texture should be bound to
  95709. * @param postProcess The post process which's output should be bound
  95710. */
  95711. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  95712. /**
  95713. * Unbind all textures from the webGL context
  95714. */
  95715. unbindAllTextures(): void;
  95716. /**
  95717. * Sets a texture to the according uniform.
  95718. * @param channel The texture channel
  95719. * @param uniform The uniform to set
  95720. * @param texture The texture to apply
  95721. */
  95722. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  95723. /**
  95724. * Sets a depth stencil texture from a render target to the according uniform.
  95725. * @param channel The texture channel
  95726. * @param uniform The uniform to set
  95727. * @param texture The render target texture containing the depth stencil texture to apply
  95728. */
  95729. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  95730. private _bindSamplerUniformToChannel;
  95731. private _getTextureWrapMode;
  95732. private _setTexture;
  95733. /**
  95734. * Sets an array of texture to the webGL context
  95735. * @param channel defines the channel where the texture array must be set
  95736. * @param uniform defines the associated uniform location
  95737. * @param textures defines the array of textures to bind
  95738. */
  95739. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  95740. /** @hidden */
  95741. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  95742. private _setTextureParameterFloat;
  95743. private _setTextureParameterInteger;
  95744. /**
  95745. * Reads pixels from the current frame buffer. Please note that this function can be slow
  95746. * @param x defines the x coordinate of the rectangle where pixels must be read
  95747. * @param y defines the y coordinate of the rectangle where pixels must be read
  95748. * @param width defines the width of the rectangle where pixels must be read
  95749. * @param height defines the height of the rectangle where pixels must be read
  95750. * @returns a Uint8Array containing RGBA colors
  95751. */
  95752. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  95753. /**
  95754. * Add an externaly attached data from its key.
  95755. * This method call will fail and return false, if such key already exists.
  95756. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95757. * @param key the unique key that identifies the data
  95758. * @param data the data object to associate to the key for this Engine instance
  95759. * @return true if no such key were already present and the data was added successfully, false otherwise
  95760. */
  95761. addExternalData<T>(key: string, data: T): boolean;
  95762. /**
  95763. * Get an externaly attached data from its key
  95764. * @param key the unique key that identifies the data
  95765. * @return the associated data, if present (can be null), or undefined if not present
  95766. */
  95767. getExternalData<T>(key: string): T;
  95768. /**
  95769. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95770. * @param key the unique key that identifies the data
  95771. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95772. * @return the associated data, can be null if the factory returned null.
  95773. */
  95774. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95775. /**
  95776. * Remove an externaly attached data from the Engine instance
  95777. * @param key the unique key that identifies the data
  95778. * @return true if the data was successfully removed, false if it doesn't exist
  95779. */
  95780. removeExternalData(key: string): boolean;
  95781. /**
  95782. * Unbind all vertex attributes from the webGL context
  95783. */
  95784. unbindAllAttributes(): void;
  95785. /**
  95786. * 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
  95787. */
  95788. releaseEffects(): void;
  95789. /**
  95790. * Dispose and release all associated resources
  95791. */
  95792. dispose(): void;
  95793. /**
  95794. * Display the loading screen
  95795. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95796. */
  95797. displayLoadingUI(): void;
  95798. /**
  95799. * Hide the loading screen
  95800. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95801. */
  95802. hideLoadingUI(): void;
  95803. /**
  95804. * Gets the current loading screen object
  95805. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95806. */
  95807. /**
  95808. * Sets the current loading screen object
  95809. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95810. */
  95811. loadingScreen: ILoadingScreen;
  95812. /**
  95813. * Sets the current loading screen text
  95814. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95815. */
  95816. loadingUIText: string;
  95817. /**
  95818. * Sets the current loading screen background color
  95819. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95820. */
  95821. loadingUIBackgroundColor: string;
  95822. /**
  95823. * Attach a new callback raised when context lost event is fired
  95824. * @param callback defines the callback to call
  95825. */
  95826. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95827. /**
  95828. * Attach a new callback raised when context restored event is fired
  95829. * @param callback defines the callback to call
  95830. */
  95831. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95832. /**
  95833. * Gets the source code of the vertex shader associated with a specific webGL program
  95834. * @param program defines the program to use
  95835. * @returns a string containing the source code of the vertex shader associated with the program
  95836. */
  95837. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  95838. /**
  95839. * Gets the source code of the fragment shader associated with a specific webGL program
  95840. * @param program defines the program to use
  95841. * @returns a string containing the source code of the fragment shader associated with the program
  95842. */
  95843. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  95844. /**
  95845. * Get the current error code of the webGL context
  95846. * @returns the error code
  95847. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  95848. */
  95849. getError(): number;
  95850. /**
  95851. * Gets the current framerate
  95852. * @returns a number representing the framerate
  95853. */
  95854. getFps(): number;
  95855. /**
  95856. * Gets the time spent between current and previous frame
  95857. * @returns a number representing the delta time in ms
  95858. */
  95859. getDeltaTime(): number;
  95860. private _measureFps;
  95861. /** @hidden */
  95862. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  95863. private _canRenderToFloatFramebuffer;
  95864. private _canRenderToHalfFloatFramebuffer;
  95865. private _canRenderToFramebuffer;
  95866. /** @hidden */
  95867. _getWebGLTextureType(type: number): number;
  95868. /** @hidden */
  95869. _getInternalFormat(format: number): number;
  95870. /** @hidden */
  95871. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  95872. /** @hidden */
  95873. _getRGBAMultiSampleBufferFormat(type: number): number;
  95874. /** @hidden */
  95875. _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;
  95876. /** @hidden */
  95877. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95878. /**
  95879. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  95880. * @returns true if the engine can be created
  95881. * @ignorenaming
  95882. */
  95883. static isSupported(): boolean;
  95884. /**
  95885. * Find the next highest power of two.
  95886. * @param x Number to start search from.
  95887. * @return Next highest power of two.
  95888. */
  95889. static CeilingPOT(x: number): number;
  95890. /**
  95891. * Find the next lowest power of two.
  95892. * @param x Number to start search from.
  95893. * @return Next lowest power of two.
  95894. */
  95895. static FloorPOT(x: number): number;
  95896. /**
  95897. * Find the nearest power of two.
  95898. * @param x Number to start search from.
  95899. * @return Next nearest power of two.
  95900. */
  95901. static NearestPOT(x: number): number;
  95902. /**
  95903. * Get the closest exponent of two
  95904. * @param value defines the value to approximate
  95905. * @param max defines the maximum value to return
  95906. * @param mode defines how to define the closest value
  95907. * @returns closest exponent of two of the given value
  95908. */
  95909. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  95910. /**
  95911. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  95912. * @param func - the function to be called
  95913. * @param requester - the object that will request the next frame. Falls back to window.
  95914. * @returns frame number
  95915. */
  95916. static QueueNewFrame(func: () => void, requester?: any): number;
  95917. /**
  95918. * Ask the browser to promote the current element to pointerlock mode
  95919. * @param element defines the DOM element to promote
  95920. */
  95921. static _RequestPointerlock(element: HTMLElement): void;
  95922. /**
  95923. * Asks the browser to exit pointerlock mode
  95924. */
  95925. static _ExitPointerlock(): void;
  95926. /**
  95927. * Ask the browser to promote the current element to fullscreen rendering mode
  95928. * @param element defines the DOM element to promote
  95929. */
  95930. static _RequestFullscreen(element: HTMLElement): void;
  95931. /**
  95932. * Asks the browser to exit fullscreen mode
  95933. */
  95934. static _ExitFullscreen(): void;
  95935. }
  95936. }
  95937. declare module BABYLON {
  95938. /**
  95939. * The engine store class is responsible to hold all the instances of Engine and Scene created
  95940. * during the life time of the application.
  95941. */
  95942. export class EngineStore {
  95943. /** Gets the list of created engines */
  95944. static Instances: Engine[];
  95945. /** @hidden */
  95946. static _LastCreatedScene: Nullable<Scene>;
  95947. /**
  95948. * Gets the latest created engine
  95949. */
  95950. static readonly LastCreatedEngine: Nullable<Engine>;
  95951. /**
  95952. * Gets the latest created scene
  95953. */
  95954. static readonly LastCreatedScene: Nullable<Scene>;
  95955. /**
  95956. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95957. * @ignorenaming
  95958. */
  95959. static UseFallbackTexture: boolean;
  95960. /**
  95961. * Texture content used if a texture cannot loaded
  95962. * @ignorenaming
  95963. */
  95964. static FallbackTexture: string;
  95965. }
  95966. }
  95967. declare module BABYLON {
  95968. /**
  95969. * Helper class that provides a small promise polyfill
  95970. */
  95971. export class PromisePolyfill {
  95972. /**
  95973. * Static function used to check if the polyfill is required
  95974. * If this is the case then the function will inject the polyfill to window.Promise
  95975. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95976. */
  95977. static Apply(force?: boolean): void;
  95978. }
  95979. }
  95980. declare module BABYLON {
  95981. /**
  95982. * Interface for screenshot methods with describe argument called `size` as object with options
  95983. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  95984. */
  95985. export interface IScreenshotSize {
  95986. /**
  95987. * number in pixels for canvas height
  95988. */
  95989. height?: number;
  95990. /**
  95991. * multiplier allowing render at a higher or lower resolution
  95992. * If value is defined then height and width will be ignored and taken from camera
  95993. */
  95994. precision?: number;
  95995. /**
  95996. * number in pixels for canvas width
  95997. */
  95998. width?: number;
  95999. }
  96000. }
  96001. declare module BABYLON {
  96002. interface IColor4Like {
  96003. r: float;
  96004. g: float;
  96005. b: float;
  96006. a: float;
  96007. }
  96008. /**
  96009. * Class containing a set of static utilities functions
  96010. */
  96011. export class Tools {
  96012. /**
  96013. * Gets or sets the base URL to use to load assets
  96014. */
  96015. static BaseUrl: string;
  96016. /**
  96017. * Enable/Disable Custom HTTP Request Headers globally.
  96018. * default = false
  96019. * @see CustomRequestHeaders
  96020. */
  96021. static UseCustomRequestHeaders: boolean;
  96022. /**
  96023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  96024. * i.e. when loading files, where the server/service expects an Authorization header
  96025. */
  96026. static CustomRequestHeaders: {
  96027. [key: string]: string;
  96028. };
  96029. /**
  96030. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  96031. */
  96032. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  96033. /**
  96034. * Default behaviour for cors in the application.
  96035. * It can be a string if the expected behavior is identical in the entire app.
  96036. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  96037. */
  96038. static CorsBehavior: string | ((url: string | string[]) => string);
  96039. /**
  96040. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96041. * @ignorenaming
  96042. */
  96043. static UseFallbackTexture: boolean;
  96044. /**
  96045. * Use this object to register external classes like custom textures or material
  96046. * to allow the laoders to instantiate them
  96047. */
  96048. static RegisteredExternalClasses: {
  96049. [key: string]: Object;
  96050. };
  96051. /**
  96052. * Texture content used if a texture cannot loaded
  96053. * @ignorenaming
  96054. */
  96055. static fallbackTexture: string;
  96056. /**
  96057. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  96058. * @param u defines the coordinate on X axis
  96059. * @param v defines the coordinate on Y axis
  96060. * @param width defines the width of the source data
  96061. * @param height defines the height of the source data
  96062. * @param pixels defines the source byte array
  96063. * @param color defines the output color
  96064. */
  96065. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  96066. /**
  96067. * Interpolates between a and b via alpha
  96068. * @param a The lower value (returned when alpha = 0)
  96069. * @param b The upper value (returned when alpha = 1)
  96070. * @param alpha The interpolation-factor
  96071. * @return The mixed value
  96072. */
  96073. static Mix(a: number, b: number, alpha: number): number;
  96074. /**
  96075. * Tries to instantiate a new object from a given class name
  96076. * @param className defines the class name to instantiate
  96077. * @returns the new object or null if the system was not able to do the instantiation
  96078. */
  96079. static Instantiate(className: string): any;
  96080. /**
  96081. * Provides a slice function that will work even on IE
  96082. * @param data defines the array to slice
  96083. * @param start defines the start of the data (optional)
  96084. * @param end defines the end of the data (optional)
  96085. * @returns the new sliced array
  96086. */
  96087. static Slice<T>(data: T, start?: number, end?: number): T;
  96088. /**
  96089. * Polyfill for setImmediate
  96090. * @param action defines the action to execute after the current execution block
  96091. */
  96092. static SetImmediate(action: () => void): void;
  96093. /**
  96094. * Function indicating if a number is an exponent of 2
  96095. * @param value defines the value to test
  96096. * @returns true if the value is an exponent of 2
  96097. */
  96098. static IsExponentOfTwo(value: number): boolean;
  96099. private static _tmpFloatArray;
  96100. /**
  96101. * Returns the nearest 32-bit single precision float representation of a Number
  96102. * @param value A Number. If the parameter is of a different type, it will get converted
  96103. * to a number or to NaN if it cannot be converted
  96104. * @returns number
  96105. */
  96106. static FloatRound(value: number): number;
  96107. /**
  96108. * Extracts the filename from a path
  96109. * @param path defines the path to use
  96110. * @returns the filename
  96111. */
  96112. static GetFilename(path: string): string;
  96113. /**
  96114. * Extracts the "folder" part of a path (everything before the filename).
  96115. * @param uri The URI to extract the info from
  96116. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  96117. * @returns The "folder" part of the path
  96118. */
  96119. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  96120. /**
  96121. * Extracts text content from a DOM element hierarchy
  96122. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  96123. */
  96124. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  96125. /**
  96126. * Convert an angle in radians to degrees
  96127. * @param angle defines the angle to convert
  96128. * @returns the angle in degrees
  96129. */
  96130. static ToDegrees(angle: number): number;
  96131. /**
  96132. * Convert an angle in degrees to radians
  96133. * @param angle defines the angle to convert
  96134. * @returns the angle in radians
  96135. */
  96136. static ToRadians(angle: number): number;
  96137. /**
  96138. * Encode a buffer to a base64 string
  96139. * @param buffer defines the buffer to encode
  96140. * @returns the encoded string
  96141. */
  96142. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  96143. /**
  96144. * Returns an array if obj is not an array
  96145. * @param obj defines the object to evaluate as an array
  96146. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  96147. * @returns either obj directly if obj is an array or a new array containing obj
  96148. */
  96149. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  96150. /**
  96151. * Gets the pointer prefix to use
  96152. * @returns "pointer" if touch is enabled. Else returns "mouse"
  96153. */
  96154. static GetPointerPrefix(): string;
  96155. /**
  96156. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  96157. * @param url define the url we are trying
  96158. * @param element define the dom element where to configure the cors policy
  96159. */
  96160. static SetCorsBehavior(url: string | string[], element: {
  96161. crossOrigin: string | null;
  96162. }): void;
  96163. /**
  96164. * Removes unwanted characters from an url
  96165. * @param url defines the url to clean
  96166. * @returns the cleaned url
  96167. */
  96168. static CleanUrl(url: string): string;
  96169. /**
  96170. * Gets or sets a function used to pre-process url before using them to load assets
  96171. */
  96172. static PreprocessUrl: (url: string) => string;
  96173. /**
  96174. * Loads an image as an HTMLImageElement.
  96175. * @param input url string, ArrayBuffer, or Blob to load
  96176. * @param onLoad callback called when the image successfully loads
  96177. * @param onError callback called when the image fails to load
  96178. * @param offlineProvider offline provider for caching
  96179. * @returns the HTMLImageElement of the loaded image
  96180. */
  96181. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  96182. /**
  96183. * Loads a file
  96184. * @param url url string, ArrayBuffer, or Blob to load
  96185. * @param onSuccess callback called when the file successfully loads
  96186. * @param onProgress callback called while file is loading (if the server supports this mode)
  96187. * @param offlineProvider defines the offline provider for caching
  96188. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  96189. * @param onError callback called when the file fails to load
  96190. * @returns a file request object
  96191. */
  96192. 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;
  96193. /**
  96194. * Loads a file from a url
  96195. * @param url the file url to load
  96196. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  96197. */
  96198. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  96199. /**
  96200. * Load a script (identified by an url). When the url returns, the
  96201. * content of this file is added into a new script element, attached to the DOM (body element)
  96202. * @param scriptUrl defines the url of the script to laod
  96203. * @param onSuccess defines the callback called when the script is loaded
  96204. * @param onError defines the callback to call if an error occurs
  96205. * @param scriptId defines the id of the script element
  96206. */
  96207. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  96208. /**
  96209. * Load an asynchronous script (identified by an url). When the url returns, the
  96210. * content of this file is added into a new script element, attached to the DOM (body element)
  96211. * @param scriptUrl defines the url of the script to laod
  96212. * @param scriptId defines the id of the script element
  96213. * @returns a promise request object
  96214. */
  96215. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  96216. /**
  96217. * Loads a file from a blob
  96218. * @param fileToLoad defines the blob to use
  96219. * @param callback defines the callback to call when data is loaded
  96220. * @param progressCallback defines the callback to call during loading process
  96221. * @returns a file request object
  96222. */
  96223. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  96224. /**
  96225. * Loads a file
  96226. * @param fileToLoad defines the file to load
  96227. * @param callback defines the callback to call when data is loaded
  96228. * @param progressCallBack defines the callback to call during loading process
  96229. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  96230. * @returns a file request object
  96231. */
  96232. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  96233. /**
  96234. * Creates a data url from a given string content
  96235. * @param content defines the content to convert
  96236. * @returns the new data url link
  96237. */
  96238. static FileAsURL(content: string): string;
  96239. /**
  96240. * Format the given number to a specific decimal format
  96241. * @param value defines the number to format
  96242. * @param decimals defines the number of decimals to use
  96243. * @returns the formatted string
  96244. */
  96245. static Format(value: number, decimals?: number): string;
  96246. /**
  96247. * Tries to copy an object by duplicating every property
  96248. * @param source defines the source object
  96249. * @param destination defines the target object
  96250. * @param doNotCopyList defines a list of properties to avoid
  96251. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96252. */
  96253. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  96254. /**
  96255. * Gets a boolean indicating if the given object has no own property
  96256. * @param obj defines the object to test
  96257. * @returns true if object has no own property
  96258. */
  96259. static IsEmpty(obj: any): boolean;
  96260. /**
  96261. * Function used to register events at window level
  96262. * @param windowElement defines the Window object to use
  96263. * @param events defines the events to register
  96264. */
  96265. static RegisterTopRootEvents(windowElement: Window, events: {
  96266. name: string;
  96267. handler: Nullable<(e: FocusEvent) => any>;
  96268. }[]): void;
  96269. /**
  96270. * Function used to unregister events from window level
  96271. * @param windowElement defines the Window object to use
  96272. * @param events defines the events to unregister
  96273. */
  96274. static UnregisterTopRootEvents(windowElement: Window, events: {
  96275. name: string;
  96276. handler: Nullable<(e: FocusEvent) => any>;
  96277. }[]): void;
  96278. /**
  96279. * @ignore
  96280. */
  96281. static _ScreenshotCanvas: HTMLCanvasElement;
  96282. /**
  96283. * Dumps the current bound framebuffer
  96284. * @param width defines the rendering width
  96285. * @param height defines the rendering height
  96286. * @param engine defines the hosting engine
  96287. * @param successCallback defines the callback triggered once the data are available
  96288. * @param mimeType defines the mime type of the result
  96289. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  96290. */
  96291. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96292. /**
  96293. * Converts the canvas data to blob.
  96294. * This acts as a polyfill for browsers not supporting the to blob function.
  96295. * @param canvas Defines the canvas to extract the data from
  96296. * @param successCallback Defines the callback triggered once the data are available
  96297. * @param mimeType Defines the mime type of the result
  96298. */
  96299. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  96300. /**
  96301. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  96302. * @param successCallback defines the callback triggered once the data are available
  96303. * @param mimeType defines the mime type of the result
  96304. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  96305. */
  96306. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96307. /**
  96308. * Downloads a blob in the browser
  96309. * @param blob defines the blob to download
  96310. * @param fileName defines the name of the downloaded file
  96311. */
  96312. static Download(blob: Blob, fileName: string): void;
  96313. /**
  96314. * Captures a screenshot of the current rendering
  96315. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96316. * @param engine defines the rendering engine
  96317. * @param camera defines the source camera
  96318. * @param size This parameter can be set to a single number or to an object with the
  96319. * following (optional) properties: precision, width, height. If a single number is passed,
  96320. * it will be used for both width and height. If an object is passed, the screenshot size
  96321. * will be derived from the parameters. The precision property is a multiplier allowing
  96322. * rendering at a higher or lower resolution
  96323. * @param successCallback defines the callback receives a single parameter which contains the
  96324. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96325. * src parameter of an <img> to display it
  96326. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96327. * Check your browser for supported MIME types
  96328. */
  96329. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  96330. /**
  96331. * Captures a screenshot of the current rendering
  96332. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96333. * @param engine defines the rendering engine
  96334. * @param camera defines the source camera
  96335. * @param size This parameter can be set to a single number or to an object with the
  96336. * following (optional) properties: precision, width, height. If a single number is passed,
  96337. * it will be used for both width and height. If an object is passed, the screenshot size
  96338. * will be derived from the parameters. The precision property is a multiplier allowing
  96339. * rendering at a higher or lower resolution
  96340. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96341. * Check your browser for supported MIME types
  96342. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96343. * to the src parameter of an <img> to display it
  96344. */
  96345. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  96346. /**
  96347. * Generates an image screenshot from the specified camera.
  96348. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96349. * @param engine The engine to use for rendering
  96350. * @param camera The camera to use for rendering
  96351. * @param size This parameter can be set to a single number or to an object with the
  96352. * following (optional) properties: precision, width, height. If a single number is passed,
  96353. * it will be used for both width and height. If an object is passed, the screenshot size
  96354. * will be derived from the parameters. The precision property is a multiplier allowing
  96355. * rendering at a higher or lower resolution
  96356. * @param successCallback The callback receives a single parameter which contains the
  96357. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96358. * src parameter of an <img> to display it
  96359. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96360. * Check your browser for supported MIME types
  96361. * @param samples Texture samples (default: 1)
  96362. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96363. * @param fileName A name for for the downloaded file.
  96364. */
  96365. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  96366. /**
  96367. * Generates an image screenshot from the specified camera.
  96368. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96369. * @param engine The engine to use for rendering
  96370. * @param camera The camera to use for rendering
  96371. * @param size This parameter can be set to a single number or to an object with the
  96372. * following (optional) properties: precision, width, height. If a single number is passed,
  96373. * it will be used for both width and height. If an object is passed, the screenshot size
  96374. * will be derived from the parameters. The precision property is a multiplier allowing
  96375. * rendering at a higher or lower resolution
  96376. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96377. * Check your browser for supported MIME types
  96378. * @param samples Texture samples (default: 1)
  96379. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96380. * @param fileName A name for for the downloaded file.
  96381. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96382. * to the src parameter of an <img> to display it
  96383. */
  96384. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  96385. /**
  96386. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96387. * Be aware Math.random() could cause collisions, but:
  96388. * "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"
  96389. * @returns a pseudo random id
  96390. */
  96391. static RandomId(): string;
  96392. /**
  96393. * Test if the given uri is a base64 string
  96394. * @param uri The uri to test
  96395. * @return True if the uri is a base64 string or false otherwise
  96396. */
  96397. static IsBase64(uri: string): boolean;
  96398. /**
  96399. * Decode the given base64 uri.
  96400. * @param uri The uri to decode
  96401. * @return The decoded base64 data.
  96402. */
  96403. static DecodeBase64(uri: string): ArrayBuffer;
  96404. /**
  96405. * Gets the absolute url.
  96406. * @param url the input url
  96407. * @return the absolute url
  96408. */
  96409. static GetAbsoluteUrl(url: string): string;
  96410. /**
  96411. * No log
  96412. */
  96413. static readonly NoneLogLevel: number;
  96414. /**
  96415. * Only message logs
  96416. */
  96417. static readonly MessageLogLevel: number;
  96418. /**
  96419. * Only warning logs
  96420. */
  96421. static readonly WarningLogLevel: number;
  96422. /**
  96423. * Only error logs
  96424. */
  96425. static readonly ErrorLogLevel: number;
  96426. /**
  96427. * All logs
  96428. */
  96429. static readonly AllLogLevel: number;
  96430. /**
  96431. * Gets a value indicating the number of loading errors
  96432. * @ignorenaming
  96433. */
  96434. static readonly errorsCount: number;
  96435. /**
  96436. * Callback called when a new log is added
  96437. */
  96438. static OnNewCacheEntry: (entry: string) => void;
  96439. /**
  96440. * Log a message to the console
  96441. * @param message defines the message to log
  96442. */
  96443. static Log(message: string): void;
  96444. /**
  96445. * Write a warning message to the console
  96446. * @param message defines the message to log
  96447. */
  96448. static Warn(message: string): void;
  96449. /**
  96450. * Write an error message to the console
  96451. * @param message defines the message to log
  96452. */
  96453. static Error(message: string): void;
  96454. /**
  96455. * Gets current log cache (list of logs)
  96456. */
  96457. static readonly LogCache: string;
  96458. /**
  96459. * Clears the log cache
  96460. */
  96461. static ClearLogCache(): void;
  96462. /**
  96463. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  96464. */
  96465. static LogLevels: number;
  96466. /**
  96467. * Checks if the window object exists
  96468. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  96469. */
  96470. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  96471. /**
  96472. * No performance log
  96473. */
  96474. static readonly PerformanceNoneLogLevel: number;
  96475. /**
  96476. * Use user marks to log performance
  96477. */
  96478. static readonly PerformanceUserMarkLogLevel: number;
  96479. /**
  96480. * Log performance to the console
  96481. */
  96482. static readonly PerformanceConsoleLogLevel: number;
  96483. private static _performance;
  96484. /**
  96485. * Sets the current performance log level
  96486. */
  96487. static PerformanceLogLevel: number;
  96488. private static _StartPerformanceCounterDisabled;
  96489. private static _EndPerformanceCounterDisabled;
  96490. private static _StartUserMark;
  96491. private static _EndUserMark;
  96492. private static _StartPerformanceConsole;
  96493. private static _EndPerformanceConsole;
  96494. /**
  96495. * Starts a performance counter
  96496. */
  96497. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96498. /**
  96499. * Ends a specific performance coutner
  96500. */
  96501. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96502. /**
  96503. * Gets either window.performance.now() if supported or Date.now() else
  96504. */
  96505. static readonly Now: number;
  96506. /**
  96507. * This method will return the name of the class used to create the instance of the given object.
  96508. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  96509. * @param object the object to get the class name from
  96510. * @param isType defines if the object is actually a type
  96511. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  96512. */
  96513. static GetClassName(object: any, isType?: boolean): string;
  96514. /**
  96515. * Gets the first element of an array satisfying a given predicate
  96516. * @param array defines the array to browse
  96517. * @param predicate defines the predicate to use
  96518. * @returns null if not found or the element
  96519. */
  96520. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  96521. /**
  96522. * This method will return the name of the full name of the class, including its owning module (if any).
  96523. * 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).
  96524. * @param object the object to get the class name from
  96525. * @param isType defines if the object is actually a type
  96526. * @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.
  96527. * @ignorenaming
  96528. */
  96529. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  96530. /**
  96531. * Returns a promise that resolves after the given amount of time.
  96532. * @param delay Number of milliseconds to delay
  96533. * @returns Promise that resolves after the given amount of time
  96534. */
  96535. static DelayAsync(delay: number): Promise<void>;
  96536. }
  96537. /**
  96538. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  96539. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  96540. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  96541. * @param name The name of the class, case should be preserved
  96542. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  96543. */
  96544. export function className(name: string, module?: string): (target: Object) => void;
  96545. /**
  96546. * An implementation of a loop for asynchronous functions.
  96547. */
  96548. export class AsyncLoop {
  96549. /**
  96550. * Defines the number of iterations for the loop
  96551. */
  96552. iterations: number;
  96553. /**
  96554. * Defines the current index of the loop.
  96555. */
  96556. index: number;
  96557. private _done;
  96558. private _fn;
  96559. private _successCallback;
  96560. /**
  96561. * Constructor.
  96562. * @param iterations the number of iterations.
  96563. * @param func the function to run each iteration
  96564. * @param successCallback the callback that will be called upon succesful execution
  96565. * @param offset starting offset.
  96566. */
  96567. constructor(
  96568. /**
  96569. * Defines the number of iterations for the loop
  96570. */
  96571. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  96572. /**
  96573. * Execute the next iteration. Must be called after the last iteration was finished.
  96574. */
  96575. executeNext(): void;
  96576. /**
  96577. * Break the loop and run the success callback.
  96578. */
  96579. breakLoop(): void;
  96580. /**
  96581. * Create and run an async loop.
  96582. * @param iterations the number of iterations.
  96583. * @param fn the function to run each iteration
  96584. * @param successCallback the callback that will be called upon succesful execution
  96585. * @param offset starting offset.
  96586. * @returns the created async loop object
  96587. */
  96588. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  96589. /**
  96590. * A for-loop that will run a given number of iterations synchronous and the rest async.
  96591. * @param iterations total number of iterations
  96592. * @param syncedIterations number of synchronous iterations in each async iteration.
  96593. * @param fn the function to call each iteration.
  96594. * @param callback a success call back that will be called when iterating stops.
  96595. * @param breakFunction a break condition (optional)
  96596. * @param timeout timeout settings for the setTimeout function. default - 0.
  96597. * @returns the created async loop object
  96598. */
  96599. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  96600. }
  96601. }
  96602. declare module BABYLON {
  96603. /** @hidden */
  96604. export interface ICollisionCoordinator {
  96605. createCollider(): Collider;
  96606. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96607. init(scene: Scene): void;
  96608. }
  96609. /** @hidden */
  96610. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  96611. private _scene;
  96612. private _scaledPosition;
  96613. private _scaledVelocity;
  96614. private _finalPosition;
  96615. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96616. createCollider(): Collider;
  96617. init(scene: Scene): void;
  96618. private _collideWithWorld;
  96619. }
  96620. }
  96621. declare module BABYLON {
  96622. /**
  96623. * Class used to manage all inputs for the scene.
  96624. */
  96625. export class InputManager {
  96626. /** The distance in pixel that you have to move to prevent some events */
  96627. static DragMovementThreshold: number;
  96628. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  96629. static LongPressDelay: number;
  96630. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  96631. static DoubleClickDelay: number;
  96632. /** If you need to check double click without raising a single click at first click, enable this flag */
  96633. static ExclusiveDoubleClickMode: boolean;
  96634. private _wheelEventName;
  96635. private _onPointerMove;
  96636. private _onPointerDown;
  96637. private _onPointerUp;
  96638. private _initClickEvent;
  96639. private _initActionManager;
  96640. private _delayedSimpleClick;
  96641. private _delayedSimpleClickTimeout;
  96642. private _previousDelayedSimpleClickTimeout;
  96643. private _meshPickProceed;
  96644. private _previousButtonPressed;
  96645. private _currentPickResult;
  96646. private _previousPickResult;
  96647. private _totalPointersPressed;
  96648. private _doubleClickOccured;
  96649. private _pointerOverMesh;
  96650. private _pickedDownMesh;
  96651. private _pickedUpMesh;
  96652. private _pointerX;
  96653. private _pointerY;
  96654. private _unTranslatedPointerX;
  96655. private _unTranslatedPointerY;
  96656. private _startingPointerPosition;
  96657. private _previousStartingPointerPosition;
  96658. private _startingPointerTime;
  96659. private _previousStartingPointerTime;
  96660. private _pointerCaptures;
  96661. private _onKeyDown;
  96662. private _onKeyUp;
  96663. private _onCanvasFocusObserver;
  96664. private _onCanvasBlurObserver;
  96665. private _scene;
  96666. /**
  96667. * Creates a new InputManager
  96668. * @param scene defines the hosting scene
  96669. */
  96670. constructor(scene: Scene);
  96671. /**
  96672. * Gets the mesh that is currently under the pointer
  96673. */
  96674. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96675. /**
  96676. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  96677. */
  96678. readonly unTranslatedPointer: Vector2;
  96679. /**
  96680. * Gets or sets the current on-screen X position of the pointer
  96681. */
  96682. pointerX: number;
  96683. /**
  96684. * Gets or sets the current on-screen Y position of the pointer
  96685. */
  96686. pointerY: number;
  96687. private _updatePointerPosition;
  96688. private _processPointerMove;
  96689. private _setRayOnPointerInfo;
  96690. private _checkPrePointerObservable;
  96691. /**
  96692. * Use this method to simulate a pointer move on a mesh
  96693. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96694. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96695. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96696. */
  96697. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96698. /**
  96699. * Use this method to simulate a pointer down on a mesh
  96700. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96701. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96702. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96703. */
  96704. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96705. private _processPointerDown;
  96706. /** @hidden */
  96707. _isPointerSwiping(): boolean;
  96708. /**
  96709. * Use this method to simulate a pointer up on a mesh
  96710. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96711. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96712. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96713. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96714. */
  96715. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  96716. private _processPointerUp;
  96717. /**
  96718. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96719. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96720. * @returns true if the pointer was captured
  96721. */
  96722. isPointerCaptured(pointerId?: number): boolean;
  96723. /**
  96724. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96725. * @param attachUp defines if you want to attach events to pointerup
  96726. * @param attachDown defines if you want to attach events to pointerdown
  96727. * @param attachMove defines if you want to attach events to pointermove
  96728. */
  96729. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96730. /**
  96731. * Detaches all event handlers
  96732. */
  96733. detachControl(): void;
  96734. /**
  96735. * Force the value of meshUnderPointer
  96736. * @param mesh defines the mesh to use
  96737. */
  96738. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96739. /**
  96740. * Gets the mesh under the pointer
  96741. * @returns a Mesh or null if no mesh is under the pointer
  96742. */
  96743. getPointerOverMesh(): Nullable<AbstractMesh>;
  96744. }
  96745. }
  96746. declare module BABYLON {
  96747. /**
  96748. * Helper class used to generate session unique ID
  96749. */
  96750. export class UniqueIdGenerator {
  96751. private static _UniqueIdCounter;
  96752. /**
  96753. * Gets an unique (relatively to the current scene) Id
  96754. */
  96755. static readonly UniqueId: number;
  96756. }
  96757. }
  96758. declare module BABYLON {
  96759. /**
  96760. * This class defines the direct association between an animation and a target
  96761. */
  96762. export class TargetedAnimation {
  96763. /**
  96764. * Animation to perform
  96765. */
  96766. animation: Animation;
  96767. /**
  96768. * Target to animate
  96769. */
  96770. target: any;
  96771. /**
  96772. * Serialize the object
  96773. * @returns the JSON object representing the current entity
  96774. */
  96775. serialize(): any;
  96776. }
  96777. /**
  96778. * Use this class to create coordinated animations on multiple targets
  96779. */
  96780. export class AnimationGroup implements IDisposable {
  96781. /** The name of the animation group */
  96782. name: string;
  96783. private _scene;
  96784. private _targetedAnimations;
  96785. private _animatables;
  96786. private _from;
  96787. private _to;
  96788. private _isStarted;
  96789. private _isPaused;
  96790. private _speedRatio;
  96791. private _loopAnimation;
  96792. /**
  96793. * Gets or sets the unique id of the node
  96794. */
  96795. uniqueId: number;
  96796. /**
  96797. * This observable will notify when one animation have ended
  96798. */
  96799. onAnimationEndObservable: Observable<TargetedAnimation>;
  96800. /**
  96801. * Observer raised when one animation loops
  96802. */
  96803. onAnimationLoopObservable: Observable<TargetedAnimation>;
  96804. /**
  96805. * This observable will notify when all animations have ended.
  96806. */
  96807. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  96808. /**
  96809. * This observable will notify when all animations have paused.
  96810. */
  96811. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  96812. /**
  96813. * This observable will notify when all animations are playing.
  96814. */
  96815. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  96816. /**
  96817. * Gets the first frame
  96818. */
  96819. readonly from: number;
  96820. /**
  96821. * Gets the last frame
  96822. */
  96823. readonly to: number;
  96824. /**
  96825. * Define if the animations are started
  96826. */
  96827. readonly isStarted: boolean;
  96828. /**
  96829. * Gets a value indicating that the current group is playing
  96830. */
  96831. readonly isPlaying: boolean;
  96832. /**
  96833. * Gets or sets the speed ratio to use for all animations
  96834. */
  96835. /**
  96836. * Gets or sets the speed ratio to use for all animations
  96837. */
  96838. speedRatio: number;
  96839. /**
  96840. * Gets or sets if all animations should loop or not
  96841. */
  96842. loopAnimation: boolean;
  96843. /**
  96844. * Gets the targeted animations for this animation group
  96845. */
  96846. readonly targetedAnimations: Array<TargetedAnimation>;
  96847. /**
  96848. * returning the list of animatables controlled by this animation group.
  96849. */
  96850. readonly animatables: Array<Animatable>;
  96851. /**
  96852. * Instantiates a new Animation Group.
  96853. * This helps managing several animations at once.
  96854. * @see http://doc.babylonjs.com/how_to/group
  96855. * @param name Defines the name of the group
  96856. * @param scene Defines the scene the group belongs to
  96857. */
  96858. constructor(
  96859. /** The name of the animation group */
  96860. name: string, scene?: Nullable<Scene>);
  96861. /**
  96862. * Add an animation (with its target) in the group
  96863. * @param animation defines the animation we want to add
  96864. * @param target defines the target of the animation
  96865. * @returns the TargetedAnimation object
  96866. */
  96867. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  96868. /**
  96869. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  96870. * It can add constant keys at begin or end
  96871. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  96872. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  96873. * @returns the animation group
  96874. */
  96875. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  96876. /**
  96877. * Start all animations on given targets
  96878. * @param loop defines if animations must loop
  96879. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  96880. * @param from defines the from key (optional)
  96881. * @param to defines the to key (optional)
  96882. * @returns the current animation group
  96883. */
  96884. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  96885. /**
  96886. * Pause all animations
  96887. * @returns the animation group
  96888. */
  96889. pause(): AnimationGroup;
  96890. /**
  96891. * Play all animations to initial state
  96892. * This function will start() the animations if they were not started or will restart() them if they were paused
  96893. * @param loop defines if animations must loop
  96894. * @returns the animation group
  96895. */
  96896. play(loop?: boolean): AnimationGroup;
  96897. /**
  96898. * Reset all animations to initial state
  96899. * @returns the animation group
  96900. */
  96901. reset(): AnimationGroup;
  96902. /**
  96903. * Restart animations from key 0
  96904. * @returns the animation group
  96905. */
  96906. restart(): AnimationGroup;
  96907. /**
  96908. * Stop all animations
  96909. * @returns the animation group
  96910. */
  96911. stop(): AnimationGroup;
  96912. /**
  96913. * Set animation weight for all animatables
  96914. * @param weight defines the weight to use
  96915. * @return the animationGroup
  96916. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96917. */
  96918. setWeightForAllAnimatables(weight: number): AnimationGroup;
  96919. /**
  96920. * Synchronize and normalize all animatables with a source animatable
  96921. * @param root defines the root animatable to synchronize with
  96922. * @return the animationGroup
  96923. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96924. */
  96925. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  96926. /**
  96927. * Goes to a specific frame in this animation group
  96928. * @param frame the frame number to go to
  96929. * @return the animationGroup
  96930. */
  96931. goToFrame(frame: number): AnimationGroup;
  96932. /**
  96933. * Dispose all associated resources
  96934. */
  96935. dispose(): void;
  96936. private _checkAnimationGroupEnded;
  96937. /**
  96938. * Clone the current animation group and returns a copy
  96939. * @param newName defines the name of the new group
  96940. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  96941. * @returns the new aniamtion group
  96942. */
  96943. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  96944. /**
  96945. * Serializes the animationGroup to an object
  96946. * @returns Serialized object
  96947. */
  96948. serialize(): any;
  96949. /**
  96950. * Returns a new AnimationGroup object parsed from the source provided.
  96951. * @param parsedAnimationGroup defines the source
  96952. * @param scene defines the scene that will receive the animationGroup
  96953. * @returns a new AnimationGroup
  96954. */
  96955. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  96956. /**
  96957. * Returns the string "AnimationGroup"
  96958. * @returns "AnimationGroup"
  96959. */
  96960. getClassName(): string;
  96961. /**
  96962. * Creates a detailled string about the object
  96963. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  96964. * @returns a string representing the object
  96965. */
  96966. toString(fullDetails?: boolean): string;
  96967. }
  96968. }
  96969. declare module BABYLON {
  96970. /**
  96971. * Define an interface for all classes that will hold resources
  96972. */
  96973. export interface IDisposable {
  96974. /**
  96975. * Releases all held resources
  96976. */
  96977. dispose(): void;
  96978. }
  96979. /** Interface defining initialization parameters for Scene class */
  96980. export interface SceneOptions {
  96981. /**
  96982. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  96983. * It will improve performance when the number of geometries becomes important.
  96984. */
  96985. useGeometryUniqueIdsMap?: boolean;
  96986. /**
  96987. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  96988. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96989. */
  96990. useMaterialMeshMap?: boolean;
  96991. /**
  96992. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  96993. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96994. */
  96995. useClonedMeshhMap?: boolean;
  96996. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  96997. virtual?: boolean;
  96998. }
  96999. /**
  97000. * Represents a scene to be rendered by the engine.
  97001. * @see http://doc.babylonjs.com/features/scene
  97002. */
  97003. export class Scene extends AbstractScene implements IAnimatable {
  97004. /** The fog is deactivated */
  97005. static readonly FOGMODE_NONE: number;
  97006. /** The fog density is following an exponential function */
  97007. static readonly FOGMODE_EXP: number;
  97008. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  97009. static readonly FOGMODE_EXP2: number;
  97010. /** The fog density is following a linear function. */
  97011. static readonly FOGMODE_LINEAR: number;
  97012. /**
  97013. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  97014. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97015. */
  97016. static MinDeltaTime: number;
  97017. /**
  97018. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  97019. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97020. */
  97021. static MaxDeltaTime: number;
  97022. /**
  97023. * Factory used to create the default material.
  97024. * @param name The name of the material to create
  97025. * @param scene The scene to create the material for
  97026. * @returns The default material
  97027. */
  97028. static DefaultMaterialFactory(scene: Scene): Material;
  97029. /**
  97030. * Factory used to create the a collision coordinator.
  97031. * @returns The collision coordinator
  97032. */
  97033. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  97034. /** @hidden */
  97035. _inputManager: InputManager;
  97036. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  97037. cameraToUseForPointers: Nullable<Camera>;
  97038. /** @hidden */
  97039. readonly _isScene: boolean;
  97040. /**
  97041. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  97042. */
  97043. autoClear: boolean;
  97044. /**
  97045. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  97046. */
  97047. autoClearDepthAndStencil: boolean;
  97048. /**
  97049. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  97050. */
  97051. clearColor: Color4;
  97052. /**
  97053. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  97054. */
  97055. ambientColor: Color3;
  97056. /**
  97057. * This is use to store the default BRDF lookup for PBR materials in your scene.
  97058. * It should only be one of the following (if not the default embedded one):
  97059. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  97060. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  97061. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  97062. * The material properties need to be setup according to the type of texture in use.
  97063. */
  97064. environmentBRDFTexture: BaseTexture;
  97065. /** @hidden */
  97066. protected _environmentTexture: Nullable<BaseTexture>;
  97067. /**
  97068. * Texture used in all pbr material as the reflection texture.
  97069. * As in the majority of the scene they are the same (exception for multi room and so on),
  97070. * this is easier to reference from here than from all the materials.
  97071. */
  97072. /**
  97073. * Texture used in all pbr material as the reflection texture.
  97074. * As in the majority of the scene they are the same (exception for multi room and so on),
  97075. * this is easier to set here than in all the materials.
  97076. */
  97077. environmentTexture: Nullable<BaseTexture>;
  97078. /** @hidden */
  97079. protected _environmentIntensity: number;
  97080. /**
  97081. * Intensity of the environment in all pbr material.
  97082. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97083. * As in the majority of the scene they are the same (exception for multi room and so on),
  97084. * this is easier to reference from here than from all the materials.
  97085. */
  97086. /**
  97087. * Intensity of the environment in all pbr material.
  97088. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97089. * As in the majority of the scene they are the same (exception for multi room and so on),
  97090. * this is easier to set here than in all the materials.
  97091. */
  97092. environmentIntensity: number;
  97093. /** @hidden */
  97094. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97095. /**
  97096. * Default image processing configuration used either in the rendering
  97097. * Forward main pass or through the imageProcessingPostProcess if present.
  97098. * As in the majority of the scene they are the same (exception for multi camera),
  97099. * this is easier to reference from here than from all the materials and post process.
  97100. *
  97101. * No setter as we it is a shared configuration, you can set the values instead.
  97102. */
  97103. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  97104. private _forceWireframe;
  97105. /**
  97106. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  97107. */
  97108. forceWireframe: boolean;
  97109. private _forcePointsCloud;
  97110. /**
  97111. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  97112. */
  97113. forcePointsCloud: boolean;
  97114. /**
  97115. * Gets or sets the active clipplane 1
  97116. */
  97117. clipPlane: Nullable<Plane>;
  97118. /**
  97119. * Gets or sets the active clipplane 2
  97120. */
  97121. clipPlane2: Nullable<Plane>;
  97122. /**
  97123. * Gets or sets the active clipplane 3
  97124. */
  97125. clipPlane3: Nullable<Plane>;
  97126. /**
  97127. * Gets or sets the active clipplane 4
  97128. */
  97129. clipPlane4: Nullable<Plane>;
  97130. /**
  97131. * Gets or sets a boolean indicating if animations are enabled
  97132. */
  97133. animationsEnabled: boolean;
  97134. private _animationPropertiesOverride;
  97135. /**
  97136. * Gets or sets the animation properties override
  97137. */
  97138. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97139. /**
  97140. * Gets or sets a boolean indicating if a constant deltatime has to be used
  97141. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  97142. */
  97143. useConstantAnimationDeltaTime: boolean;
  97144. /**
  97145. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  97146. * Please note that it requires to run a ray cast through the scene on every frame
  97147. */
  97148. constantlyUpdateMeshUnderPointer: boolean;
  97149. /**
  97150. * Defines the HTML cursor to use when hovering over interactive elements
  97151. */
  97152. hoverCursor: string;
  97153. /**
  97154. * Defines the HTML default cursor to use (empty by default)
  97155. */
  97156. defaultCursor: string;
  97157. /**
  97158. * This is used to call preventDefault() on pointer down
  97159. * in order to block unwanted artifacts like system double clicks
  97160. */
  97161. preventDefaultOnPointerDown: boolean;
  97162. /**
  97163. * This is used to call preventDefault() on pointer up
  97164. * in order to block unwanted artifacts like system double clicks
  97165. */
  97166. preventDefaultOnPointerUp: boolean;
  97167. /**
  97168. * Gets or sets user defined metadata
  97169. */
  97170. metadata: any;
  97171. /**
  97172. * For internal use only. Please do not use.
  97173. */
  97174. reservedDataStore: any;
  97175. /**
  97176. * Gets the name of the plugin used to load this scene (null by default)
  97177. */
  97178. loadingPluginName: string;
  97179. /**
  97180. * Use this array to add regular expressions used to disable offline support for specific urls
  97181. */
  97182. disableOfflineSupportExceptionRules: RegExp[];
  97183. /**
  97184. * An event triggered when the scene is disposed.
  97185. */
  97186. onDisposeObservable: Observable<Scene>;
  97187. private _onDisposeObserver;
  97188. /** Sets a function to be executed when this scene is disposed. */
  97189. onDispose: () => void;
  97190. /**
  97191. * An event triggered before rendering the scene (right after animations and physics)
  97192. */
  97193. onBeforeRenderObservable: Observable<Scene>;
  97194. private _onBeforeRenderObserver;
  97195. /** Sets a function to be executed before rendering this scene */
  97196. beforeRender: Nullable<() => void>;
  97197. /**
  97198. * An event triggered after rendering the scene
  97199. */
  97200. onAfterRenderObservable: Observable<Scene>;
  97201. /**
  97202. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  97203. */
  97204. onAfterRenderCameraObservable: Observable<Camera>;
  97205. private _onAfterRenderObserver;
  97206. /** Sets a function to be executed after rendering this scene */
  97207. afterRender: Nullable<() => void>;
  97208. /**
  97209. * An event triggered before animating the scene
  97210. */
  97211. onBeforeAnimationsObservable: Observable<Scene>;
  97212. /**
  97213. * An event triggered after animations processing
  97214. */
  97215. onAfterAnimationsObservable: Observable<Scene>;
  97216. /**
  97217. * An event triggered before draw calls are ready to be sent
  97218. */
  97219. onBeforeDrawPhaseObservable: Observable<Scene>;
  97220. /**
  97221. * An event triggered after draw calls have been sent
  97222. */
  97223. onAfterDrawPhaseObservable: Observable<Scene>;
  97224. /**
  97225. * An event triggered when the scene is ready
  97226. */
  97227. onReadyObservable: Observable<Scene>;
  97228. /**
  97229. * An event triggered before rendering a camera
  97230. */
  97231. onBeforeCameraRenderObservable: Observable<Camera>;
  97232. private _onBeforeCameraRenderObserver;
  97233. /** Sets a function to be executed before rendering a camera*/
  97234. beforeCameraRender: () => void;
  97235. /**
  97236. * An event triggered after rendering a camera
  97237. */
  97238. onAfterCameraRenderObservable: Observable<Camera>;
  97239. private _onAfterCameraRenderObserver;
  97240. /** Sets a function to be executed after rendering a camera*/
  97241. afterCameraRender: () => void;
  97242. /**
  97243. * An event triggered when active meshes evaluation is about to start
  97244. */
  97245. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  97246. /**
  97247. * An event triggered when active meshes evaluation is done
  97248. */
  97249. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  97250. /**
  97251. * An event triggered when particles rendering is about to start
  97252. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97253. */
  97254. onBeforeParticlesRenderingObservable: Observable<Scene>;
  97255. /**
  97256. * An event triggered when particles rendering is done
  97257. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97258. */
  97259. onAfterParticlesRenderingObservable: Observable<Scene>;
  97260. /**
  97261. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  97262. */
  97263. onDataLoadedObservable: Observable<Scene>;
  97264. /**
  97265. * An event triggered when a camera is created
  97266. */
  97267. onNewCameraAddedObservable: Observable<Camera>;
  97268. /**
  97269. * An event triggered when a camera is removed
  97270. */
  97271. onCameraRemovedObservable: Observable<Camera>;
  97272. /**
  97273. * An event triggered when a light is created
  97274. */
  97275. onNewLightAddedObservable: Observable<Light>;
  97276. /**
  97277. * An event triggered when a light is removed
  97278. */
  97279. onLightRemovedObservable: Observable<Light>;
  97280. /**
  97281. * An event triggered when a geometry is created
  97282. */
  97283. onNewGeometryAddedObservable: Observable<Geometry>;
  97284. /**
  97285. * An event triggered when a geometry is removed
  97286. */
  97287. onGeometryRemovedObservable: Observable<Geometry>;
  97288. /**
  97289. * An event triggered when a transform node is created
  97290. */
  97291. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  97292. /**
  97293. * An event triggered when a transform node is removed
  97294. */
  97295. onTransformNodeRemovedObservable: Observable<TransformNode>;
  97296. /**
  97297. * An event triggered when a mesh is created
  97298. */
  97299. onNewMeshAddedObservable: Observable<AbstractMesh>;
  97300. /**
  97301. * An event triggered when a mesh is removed
  97302. */
  97303. onMeshRemovedObservable: Observable<AbstractMesh>;
  97304. /**
  97305. * An event triggered when a skeleton is created
  97306. */
  97307. onNewSkeletonAddedObservable: Observable<Skeleton>;
  97308. /**
  97309. * An event triggered when a skeleton is removed
  97310. */
  97311. onSkeletonRemovedObservable: Observable<Skeleton>;
  97312. /**
  97313. * An event triggered when a material is created
  97314. */
  97315. onNewMaterialAddedObservable: Observable<Material>;
  97316. /**
  97317. * An event triggered when a material is removed
  97318. */
  97319. onMaterialRemovedObservable: Observable<Material>;
  97320. /**
  97321. * An event triggered when a texture is created
  97322. */
  97323. onNewTextureAddedObservable: Observable<BaseTexture>;
  97324. /**
  97325. * An event triggered when a texture is removed
  97326. */
  97327. onTextureRemovedObservable: Observable<BaseTexture>;
  97328. /**
  97329. * An event triggered when render targets are about to be rendered
  97330. * Can happen multiple times per frame.
  97331. */
  97332. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  97333. /**
  97334. * An event triggered when render targets were rendered.
  97335. * Can happen multiple times per frame.
  97336. */
  97337. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  97338. /**
  97339. * An event triggered before calculating deterministic simulation step
  97340. */
  97341. onBeforeStepObservable: Observable<Scene>;
  97342. /**
  97343. * An event triggered after calculating deterministic simulation step
  97344. */
  97345. onAfterStepObservable: Observable<Scene>;
  97346. /**
  97347. * An event triggered when the activeCamera property is updated
  97348. */
  97349. onActiveCameraChanged: Observable<Scene>;
  97350. /**
  97351. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  97352. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97353. * 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)
  97354. */
  97355. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97356. /**
  97357. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  97358. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97359. * 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)
  97360. */
  97361. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97362. /**
  97363. * This Observable will when a mesh has been imported into the scene.
  97364. */
  97365. onMeshImportedObservable: Observable<AbstractMesh>;
  97366. /**
  97367. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  97368. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  97369. */
  97370. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  97371. /** @hidden */
  97372. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  97373. /**
  97374. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  97375. */
  97376. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  97377. /**
  97378. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  97379. */
  97380. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  97381. /**
  97382. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  97383. */
  97384. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  97385. /** Callback called when a pointer move is detected */
  97386. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97387. /** Callback called when a pointer down is detected */
  97388. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97389. /** Callback called when a pointer up is detected */
  97390. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  97391. /** Callback called when a pointer pick is detected */
  97392. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  97393. /**
  97394. * 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).
  97395. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  97396. */
  97397. onPrePointerObservable: Observable<PointerInfoPre>;
  97398. /**
  97399. * Observable event triggered each time an input event is received from the rendering canvas
  97400. */
  97401. onPointerObservable: Observable<PointerInfo>;
  97402. /**
  97403. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  97404. */
  97405. readonly unTranslatedPointer: Vector2;
  97406. /**
  97407. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  97408. */
  97409. static DragMovementThreshold: number;
  97410. /**
  97411. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  97412. */
  97413. static LongPressDelay: number;
  97414. /**
  97415. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  97416. */
  97417. static DoubleClickDelay: number;
  97418. /** If you need to check double click without raising a single click at first click, enable this flag */
  97419. static ExclusiveDoubleClickMode: boolean;
  97420. /** @hidden */
  97421. _mirroredCameraPosition: Nullable<Vector3>;
  97422. /**
  97423. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  97424. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  97425. */
  97426. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  97427. /**
  97428. * Observable event triggered each time an keyboard event is received from the hosting window
  97429. */
  97430. onKeyboardObservable: Observable<KeyboardInfo>;
  97431. private _useRightHandedSystem;
  97432. /**
  97433. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  97434. */
  97435. useRightHandedSystem: boolean;
  97436. private _timeAccumulator;
  97437. private _currentStepId;
  97438. private _currentInternalStep;
  97439. /**
  97440. * Sets the step Id used by deterministic lock step
  97441. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97442. * @param newStepId defines the step Id
  97443. */
  97444. setStepId(newStepId: number): void;
  97445. /**
  97446. * Gets the step Id used by deterministic lock step
  97447. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97448. * @returns the step Id
  97449. */
  97450. getStepId(): number;
  97451. /**
  97452. * Gets the internal step used by deterministic lock step
  97453. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97454. * @returns the internal step
  97455. */
  97456. getInternalStep(): number;
  97457. private _fogEnabled;
  97458. /**
  97459. * Gets or sets a boolean indicating if fog is enabled on this scene
  97460. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97461. * (Default is true)
  97462. */
  97463. fogEnabled: boolean;
  97464. private _fogMode;
  97465. /**
  97466. * Gets or sets the fog mode to use
  97467. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97468. * | mode | value |
  97469. * | --- | --- |
  97470. * | FOGMODE_NONE | 0 |
  97471. * | FOGMODE_EXP | 1 |
  97472. * | FOGMODE_EXP2 | 2 |
  97473. * | FOGMODE_LINEAR | 3 |
  97474. */
  97475. fogMode: number;
  97476. /**
  97477. * Gets or sets the fog color to use
  97478. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97479. * (Default is Color3(0.2, 0.2, 0.3))
  97480. */
  97481. fogColor: Color3;
  97482. /**
  97483. * Gets or sets the fog density to use
  97484. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97485. * (Default is 0.1)
  97486. */
  97487. fogDensity: number;
  97488. /**
  97489. * Gets or sets the fog start distance to use
  97490. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97491. * (Default is 0)
  97492. */
  97493. fogStart: number;
  97494. /**
  97495. * Gets or sets the fog end distance to use
  97496. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97497. * (Default is 1000)
  97498. */
  97499. fogEnd: number;
  97500. private _shadowsEnabled;
  97501. /**
  97502. * Gets or sets a boolean indicating if shadows are enabled on this scene
  97503. */
  97504. shadowsEnabled: boolean;
  97505. private _lightsEnabled;
  97506. /**
  97507. * Gets or sets a boolean indicating if lights are enabled on this scene
  97508. */
  97509. lightsEnabled: boolean;
  97510. /** All of the active cameras added to this scene. */
  97511. activeCameras: Camera[];
  97512. /** @hidden */
  97513. _activeCamera: Nullable<Camera>;
  97514. /** Gets or sets the current active camera */
  97515. activeCamera: Nullable<Camera>;
  97516. private _defaultMaterial;
  97517. /** The default material used on meshes when no material is affected */
  97518. /** The default material used on meshes when no material is affected */
  97519. defaultMaterial: Material;
  97520. private _texturesEnabled;
  97521. /**
  97522. * Gets or sets a boolean indicating if textures are enabled on this scene
  97523. */
  97524. texturesEnabled: boolean;
  97525. /**
  97526. * Gets or sets a boolean indicating if particles are enabled on this scene
  97527. */
  97528. particlesEnabled: boolean;
  97529. /**
  97530. * Gets or sets a boolean indicating if sprites are enabled on this scene
  97531. */
  97532. spritesEnabled: boolean;
  97533. private _skeletonsEnabled;
  97534. /**
  97535. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  97536. */
  97537. skeletonsEnabled: boolean;
  97538. /**
  97539. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  97540. */
  97541. lensFlaresEnabled: boolean;
  97542. /**
  97543. * Gets or sets a boolean indicating if collisions are enabled on this scene
  97544. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97545. */
  97546. collisionsEnabled: boolean;
  97547. private _collisionCoordinator;
  97548. /** @hidden */
  97549. readonly collisionCoordinator: ICollisionCoordinator;
  97550. /**
  97551. * Defines the gravity applied to this scene (used only for collisions)
  97552. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97553. */
  97554. gravity: Vector3;
  97555. /**
  97556. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  97557. */
  97558. postProcessesEnabled: boolean;
  97559. /**
  97560. * The list of postprocesses added to the scene
  97561. */
  97562. postProcesses: PostProcess[];
  97563. /**
  97564. * Gets the current postprocess manager
  97565. */
  97566. postProcessManager: PostProcessManager;
  97567. /**
  97568. * Gets or sets a boolean indicating if render targets are enabled on this scene
  97569. */
  97570. renderTargetsEnabled: boolean;
  97571. /**
  97572. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  97573. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  97574. */
  97575. dumpNextRenderTargets: boolean;
  97576. /**
  97577. * The list of user defined render targets added to the scene
  97578. */
  97579. customRenderTargets: RenderTargetTexture[];
  97580. /**
  97581. * Defines if texture loading must be delayed
  97582. * If true, textures will only be loaded when they need to be rendered
  97583. */
  97584. useDelayedTextureLoading: boolean;
  97585. /**
  97586. * Gets the list of meshes imported to the scene through SceneLoader
  97587. */
  97588. importedMeshesFiles: String[];
  97589. /**
  97590. * Gets or sets a boolean indicating if probes are enabled on this scene
  97591. */
  97592. probesEnabled: boolean;
  97593. /**
  97594. * Gets or sets the current offline provider to use to store scene data
  97595. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  97596. */
  97597. offlineProvider: IOfflineProvider;
  97598. /**
  97599. * Gets or sets the action manager associated with the scene
  97600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97601. */
  97602. actionManager: AbstractActionManager;
  97603. private _meshesForIntersections;
  97604. /**
  97605. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  97606. */
  97607. proceduralTexturesEnabled: boolean;
  97608. private _engine;
  97609. private _totalVertices;
  97610. /** @hidden */
  97611. _activeIndices: PerfCounter;
  97612. /** @hidden */
  97613. _activeParticles: PerfCounter;
  97614. /** @hidden */
  97615. _activeBones: PerfCounter;
  97616. private _animationRatio;
  97617. /** @hidden */
  97618. _animationTimeLast: number;
  97619. /** @hidden */
  97620. _animationTime: number;
  97621. /**
  97622. * Gets or sets a general scale for animation speed
  97623. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  97624. */
  97625. animationTimeScale: number;
  97626. /** @hidden */
  97627. _cachedMaterial: Nullable<Material>;
  97628. /** @hidden */
  97629. _cachedEffect: Nullable<Effect>;
  97630. /** @hidden */
  97631. _cachedVisibility: Nullable<number>;
  97632. private _renderId;
  97633. private _frameId;
  97634. private _executeWhenReadyTimeoutId;
  97635. private _intermediateRendering;
  97636. private _viewUpdateFlag;
  97637. private _projectionUpdateFlag;
  97638. /** @hidden */
  97639. _toBeDisposed: Nullable<IDisposable>[];
  97640. private _activeRequests;
  97641. /** @hidden */
  97642. _pendingData: any[];
  97643. private _isDisposed;
  97644. /**
  97645. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  97646. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  97647. */
  97648. dispatchAllSubMeshesOfActiveMeshes: boolean;
  97649. private _activeMeshes;
  97650. private _processedMaterials;
  97651. private _renderTargets;
  97652. /** @hidden */
  97653. _activeParticleSystems: SmartArray<IParticleSystem>;
  97654. private _activeSkeletons;
  97655. private _softwareSkinnedMeshes;
  97656. private _renderingManager;
  97657. /** @hidden */
  97658. _activeAnimatables: Animatable[];
  97659. private _transformMatrix;
  97660. private _sceneUbo;
  97661. /** @hidden */
  97662. _viewMatrix: Matrix;
  97663. private _projectionMatrix;
  97664. /** @hidden */
  97665. _forcedViewPosition: Nullable<Vector3>;
  97666. /** @hidden */
  97667. _frustumPlanes: Plane[];
  97668. /**
  97669. * Gets the list of frustum planes (built from the active camera)
  97670. */
  97671. readonly frustumPlanes: Plane[];
  97672. /**
  97673. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  97674. * This is useful if there are more lights that the maximum simulteanous authorized
  97675. */
  97676. requireLightSorting: boolean;
  97677. /** @hidden */
  97678. readonly useMaterialMeshMap: boolean;
  97679. /** @hidden */
  97680. readonly useClonedMeshhMap: boolean;
  97681. private _externalData;
  97682. private _uid;
  97683. /**
  97684. * @hidden
  97685. * Backing store of defined scene components.
  97686. */
  97687. _components: ISceneComponent[];
  97688. /**
  97689. * @hidden
  97690. * Backing store of defined scene components.
  97691. */
  97692. _serializableComponents: ISceneSerializableComponent[];
  97693. /**
  97694. * List of components to register on the next registration step.
  97695. */
  97696. private _transientComponents;
  97697. /**
  97698. * Registers the transient components if needed.
  97699. */
  97700. private _registerTransientComponents;
  97701. /**
  97702. * @hidden
  97703. * Add a component to the scene.
  97704. * Note that the ccomponent could be registered on th next frame if this is called after
  97705. * the register component stage.
  97706. * @param component Defines the component to add to the scene
  97707. */
  97708. _addComponent(component: ISceneComponent): void;
  97709. /**
  97710. * @hidden
  97711. * Gets a component from the scene.
  97712. * @param name defines the name of the component to retrieve
  97713. * @returns the component or null if not present
  97714. */
  97715. _getComponent(name: string): Nullable<ISceneComponent>;
  97716. /**
  97717. * @hidden
  97718. * Defines the actions happening before camera updates.
  97719. */
  97720. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  97721. /**
  97722. * @hidden
  97723. * Defines the actions happening before clear the canvas.
  97724. */
  97725. _beforeClearStage: Stage<SimpleStageAction>;
  97726. /**
  97727. * @hidden
  97728. * Defines the actions when collecting render targets for the frame.
  97729. */
  97730. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97731. /**
  97732. * @hidden
  97733. * Defines the actions happening for one camera in the frame.
  97734. */
  97735. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97736. /**
  97737. * @hidden
  97738. * Defines the actions happening during the per mesh ready checks.
  97739. */
  97740. _isReadyForMeshStage: Stage<MeshStageAction>;
  97741. /**
  97742. * @hidden
  97743. * Defines the actions happening before evaluate active mesh checks.
  97744. */
  97745. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  97746. /**
  97747. * @hidden
  97748. * Defines the actions happening during the evaluate sub mesh checks.
  97749. */
  97750. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  97751. /**
  97752. * @hidden
  97753. * Defines the actions happening during the active mesh stage.
  97754. */
  97755. _activeMeshStage: Stage<ActiveMeshStageAction>;
  97756. /**
  97757. * @hidden
  97758. * Defines the actions happening during the per camera render target step.
  97759. */
  97760. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  97761. /**
  97762. * @hidden
  97763. * Defines the actions happening just before the active camera is drawing.
  97764. */
  97765. _beforeCameraDrawStage: Stage<CameraStageAction>;
  97766. /**
  97767. * @hidden
  97768. * Defines the actions happening just before a render target is drawing.
  97769. */
  97770. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97771. /**
  97772. * @hidden
  97773. * Defines the actions happening just before a rendering group is drawing.
  97774. */
  97775. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97776. /**
  97777. * @hidden
  97778. * Defines the actions happening just before a mesh is drawing.
  97779. */
  97780. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97781. /**
  97782. * @hidden
  97783. * Defines the actions happening just after a mesh has been drawn.
  97784. */
  97785. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97786. /**
  97787. * @hidden
  97788. * Defines the actions happening just after a rendering group has been drawn.
  97789. */
  97790. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97791. /**
  97792. * @hidden
  97793. * Defines the actions happening just after the active camera has been drawn.
  97794. */
  97795. _afterCameraDrawStage: Stage<CameraStageAction>;
  97796. /**
  97797. * @hidden
  97798. * Defines the actions happening just after a render target has been drawn.
  97799. */
  97800. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97801. /**
  97802. * @hidden
  97803. * Defines the actions happening just after rendering all cameras and computing intersections.
  97804. */
  97805. _afterRenderStage: Stage<SimpleStageAction>;
  97806. /**
  97807. * @hidden
  97808. * Defines the actions happening when a pointer move event happens.
  97809. */
  97810. _pointerMoveStage: Stage<PointerMoveStageAction>;
  97811. /**
  97812. * @hidden
  97813. * Defines the actions happening when a pointer down event happens.
  97814. */
  97815. _pointerDownStage: Stage<PointerUpDownStageAction>;
  97816. /**
  97817. * @hidden
  97818. * Defines the actions happening when a pointer up event happens.
  97819. */
  97820. _pointerUpStage: Stage<PointerUpDownStageAction>;
  97821. /**
  97822. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  97823. */
  97824. private geometriesByUniqueId;
  97825. /**
  97826. * Creates a new Scene
  97827. * @param engine defines the engine to use to render this scene
  97828. * @param options defines the scene options
  97829. */
  97830. constructor(engine: Engine, options?: SceneOptions);
  97831. /**
  97832. * Gets a string idenfifying the name of the class
  97833. * @returns "Scene" string
  97834. */
  97835. getClassName(): string;
  97836. private _defaultMeshCandidates;
  97837. /**
  97838. * @hidden
  97839. */
  97840. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97841. private _defaultSubMeshCandidates;
  97842. /**
  97843. * @hidden
  97844. */
  97845. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97846. /**
  97847. * Sets the default candidate providers for the scene.
  97848. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  97849. * and getCollidingSubMeshCandidates to their default function
  97850. */
  97851. setDefaultCandidateProviders(): void;
  97852. /**
  97853. * Gets the mesh that is currently under the pointer
  97854. */
  97855. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97856. /**
  97857. * Gets or sets the current on-screen X position of the pointer
  97858. */
  97859. pointerX: number;
  97860. /**
  97861. * Gets or sets the current on-screen Y position of the pointer
  97862. */
  97863. pointerY: number;
  97864. /**
  97865. * Gets the cached material (ie. the latest rendered one)
  97866. * @returns the cached material
  97867. */
  97868. getCachedMaterial(): Nullable<Material>;
  97869. /**
  97870. * Gets the cached effect (ie. the latest rendered one)
  97871. * @returns the cached effect
  97872. */
  97873. getCachedEffect(): Nullable<Effect>;
  97874. /**
  97875. * Gets the cached visibility state (ie. the latest rendered one)
  97876. * @returns the cached visibility state
  97877. */
  97878. getCachedVisibility(): Nullable<number>;
  97879. /**
  97880. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  97881. * @param material defines the current material
  97882. * @param effect defines the current effect
  97883. * @param visibility defines the current visibility state
  97884. * @returns true if one parameter is not cached
  97885. */
  97886. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  97887. /**
  97888. * Gets the engine associated with the scene
  97889. * @returns an Engine
  97890. */
  97891. getEngine(): Engine;
  97892. /**
  97893. * Gets the total number of vertices rendered per frame
  97894. * @returns the total number of vertices rendered per frame
  97895. */
  97896. getTotalVertices(): number;
  97897. /**
  97898. * Gets the performance counter for total vertices
  97899. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97900. */
  97901. readonly totalVerticesPerfCounter: PerfCounter;
  97902. /**
  97903. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  97904. * @returns the total number of active indices rendered per frame
  97905. */
  97906. getActiveIndices(): number;
  97907. /**
  97908. * Gets the performance counter for active indices
  97909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97910. */
  97911. readonly totalActiveIndicesPerfCounter: PerfCounter;
  97912. /**
  97913. * Gets the total number of active particles rendered per frame
  97914. * @returns the total number of active particles rendered per frame
  97915. */
  97916. getActiveParticles(): number;
  97917. /**
  97918. * Gets the performance counter for active particles
  97919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97920. */
  97921. readonly activeParticlesPerfCounter: PerfCounter;
  97922. /**
  97923. * Gets the total number of active bones rendered per frame
  97924. * @returns the total number of active bones rendered per frame
  97925. */
  97926. getActiveBones(): number;
  97927. /**
  97928. * Gets the performance counter for active bones
  97929. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97930. */
  97931. readonly activeBonesPerfCounter: PerfCounter;
  97932. /**
  97933. * Gets the array of active meshes
  97934. * @returns an array of AbstractMesh
  97935. */
  97936. getActiveMeshes(): SmartArray<AbstractMesh>;
  97937. /**
  97938. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  97939. * @returns a number
  97940. */
  97941. getAnimationRatio(): number;
  97942. /**
  97943. * Gets an unique Id for the current render phase
  97944. * @returns a number
  97945. */
  97946. getRenderId(): number;
  97947. /**
  97948. * Gets an unique Id for the current frame
  97949. * @returns a number
  97950. */
  97951. getFrameId(): number;
  97952. /** Call this function if you want to manually increment the render Id*/
  97953. incrementRenderId(): void;
  97954. private _createUbo;
  97955. /**
  97956. * Use this method to simulate a pointer move on a mesh
  97957. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97958. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97959. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97960. * @returns the current scene
  97961. */
  97962. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97963. /**
  97964. * Use this method to simulate a pointer down on a mesh
  97965. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97966. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97967. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97968. * @returns the current scene
  97969. */
  97970. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97971. /**
  97972. * Use this method to simulate a pointer up on a mesh
  97973. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97974. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97975. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97976. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97977. * @returns the current scene
  97978. */
  97979. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  97980. /**
  97981. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97982. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97983. * @returns true if the pointer was captured
  97984. */
  97985. isPointerCaptured(pointerId?: number): boolean;
  97986. /**
  97987. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97988. * @param attachUp defines if you want to attach events to pointerup
  97989. * @param attachDown defines if you want to attach events to pointerdown
  97990. * @param attachMove defines if you want to attach events to pointermove
  97991. */
  97992. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97993. /** Detaches all event handlers*/
  97994. detachControl(): void;
  97995. /**
  97996. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  97997. * Delay loaded resources are not taking in account
  97998. * @return true if all required resources are ready
  97999. */
  98000. isReady(): boolean;
  98001. /** Resets all cached information relative to material (including effect and visibility) */
  98002. resetCachedMaterial(): void;
  98003. /**
  98004. * Registers a function to be called before every frame render
  98005. * @param func defines the function to register
  98006. */
  98007. registerBeforeRender(func: () => void): void;
  98008. /**
  98009. * Unregisters a function called before every frame render
  98010. * @param func defines the function to unregister
  98011. */
  98012. unregisterBeforeRender(func: () => void): void;
  98013. /**
  98014. * Registers a function to be called after every frame render
  98015. * @param func defines the function to register
  98016. */
  98017. registerAfterRender(func: () => void): void;
  98018. /**
  98019. * Unregisters a function called after every frame render
  98020. * @param func defines the function to unregister
  98021. */
  98022. unregisterAfterRender(func: () => void): void;
  98023. private _executeOnceBeforeRender;
  98024. /**
  98025. * The provided function will run before render once and will be disposed afterwards.
  98026. * A timeout delay can be provided so that the function will be executed in N ms.
  98027. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  98028. * @param func The function to be executed.
  98029. * @param timeout optional delay in ms
  98030. */
  98031. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  98032. /** @hidden */
  98033. _addPendingData(data: any): void;
  98034. /** @hidden */
  98035. _removePendingData(data: any): void;
  98036. /**
  98037. * Returns the number of items waiting to be loaded
  98038. * @returns the number of items waiting to be loaded
  98039. */
  98040. getWaitingItemsCount(): number;
  98041. /**
  98042. * Returns a boolean indicating if the scene is still loading data
  98043. */
  98044. readonly isLoading: boolean;
  98045. /**
  98046. * Registers a function to be executed when the scene is ready
  98047. * @param {Function} func - the function to be executed
  98048. */
  98049. executeWhenReady(func: () => void): void;
  98050. /**
  98051. * Returns a promise that resolves when the scene is ready
  98052. * @returns A promise that resolves when the scene is ready
  98053. */
  98054. whenReadyAsync(): Promise<void>;
  98055. /** @hidden */
  98056. _checkIsReady(): void;
  98057. /**
  98058. * Gets all animatable attached to the scene
  98059. */
  98060. readonly animatables: Animatable[];
  98061. /**
  98062. * Resets the last animation time frame.
  98063. * Useful to override when animations start running when loading a scene for the first time.
  98064. */
  98065. resetLastAnimationTimeFrame(): void;
  98066. /**
  98067. * Gets the current view matrix
  98068. * @returns a Matrix
  98069. */
  98070. getViewMatrix(): Matrix;
  98071. /**
  98072. * Gets the current projection matrix
  98073. * @returns a Matrix
  98074. */
  98075. getProjectionMatrix(): Matrix;
  98076. /**
  98077. * Gets the current transform matrix
  98078. * @returns a Matrix made of View * Projection
  98079. */
  98080. getTransformMatrix(): Matrix;
  98081. /**
  98082. * Sets the current transform matrix
  98083. * @param viewL defines the View matrix to use
  98084. * @param projectionL defines the Projection matrix to use
  98085. * @param viewR defines the right View matrix to use (if provided)
  98086. * @param projectionR defines the right Projection matrix to use (if provided)
  98087. */
  98088. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  98089. /**
  98090. * Gets the uniform buffer used to store scene data
  98091. * @returns a UniformBuffer
  98092. */
  98093. getSceneUniformBuffer(): UniformBuffer;
  98094. /**
  98095. * Gets an unique (relatively to the current scene) Id
  98096. * @returns an unique number for the scene
  98097. */
  98098. getUniqueId(): number;
  98099. /**
  98100. * Add a mesh to the list of scene's meshes
  98101. * @param newMesh defines the mesh to add
  98102. * @param recursive if all child meshes should also be added to the scene
  98103. */
  98104. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  98105. /**
  98106. * Remove a mesh for the list of scene's meshes
  98107. * @param toRemove defines the mesh to remove
  98108. * @param recursive if all child meshes should also be removed from the scene
  98109. * @returns the index where the mesh was in the mesh list
  98110. */
  98111. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  98112. /**
  98113. * Add a transform node to the list of scene's transform nodes
  98114. * @param newTransformNode defines the transform node to add
  98115. */
  98116. addTransformNode(newTransformNode: TransformNode): void;
  98117. /**
  98118. * Remove a transform node for the list of scene's transform nodes
  98119. * @param toRemove defines the transform node to remove
  98120. * @returns the index where the transform node was in the transform node list
  98121. */
  98122. removeTransformNode(toRemove: TransformNode): number;
  98123. /**
  98124. * Remove a skeleton for the list of scene's skeletons
  98125. * @param toRemove defines the skeleton to remove
  98126. * @returns the index where the skeleton was in the skeleton list
  98127. */
  98128. removeSkeleton(toRemove: Skeleton): number;
  98129. /**
  98130. * Remove a morph target for the list of scene's morph targets
  98131. * @param toRemove defines the morph target to remove
  98132. * @returns the index where the morph target was in the morph target list
  98133. */
  98134. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  98135. /**
  98136. * Remove a light for the list of scene's lights
  98137. * @param toRemove defines the light to remove
  98138. * @returns the index where the light was in the light list
  98139. */
  98140. removeLight(toRemove: Light): number;
  98141. /**
  98142. * Remove a camera for the list of scene's cameras
  98143. * @param toRemove defines the camera to remove
  98144. * @returns the index where the camera was in the camera list
  98145. */
  98146. removeCamera(toRemove: Camera): number;
  98147. /**
  98148. * Remove a particle system for the list of scene's particle systems
  98149. * @param toRemove defines the particle system to remove
  98150. * @returns the index where the particle system was in the particle system list
  98151. */
  98152. removeParticleSystem(toRemove: IParticleSystem): number;
  98153. /**
  98154. * Remove a animation for the list of scene's animations
  98155. * @param toRemove defines the animation to remove
  98156. * @returns the index where the animation was in the animation list
  98157. */
  98158. removeAnimation(toRemove: Animation): number;
  98159. /**
  98160. * Will stop the animation of the given target
  98161. * @param target - the target
  98162. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  98163. * @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)
  98164. */
  98165. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  98166. /**
  98167. * Removes the given animation group from this scene.
  98168. * @param toRemove The animation group to remove
  98169. * @returns The index of the removed animation group
  98170. */
  98171. removeAnimationGroup(toRemove: AnimationGroup): number;
  98172. /**
  98173. * Removes the given multi-material from this scene.
  98174. * @param toRemove The multi-material to remove
  98175. * @returns The index of the removed multi-material
  98176. */
  98177. removeMultiMaterial(toRemove: MultiMaterial): number;
  98178. /**
  98179. * Removes the given material from this scene.
  98180. * @param toRemove The material to remove
  98181. * @returns The index of the removed material
  98182. */
  98183. removeMaterial(toRemove: Material): number;
  98184. /**
  98185. * Removes the given action manager from this scene.
  98186. * @param toRemove The action manager to remove
  98187. * @returns The index of the removed action manager
  98188. */
  98189. removeActionManager(toRemove: AbstractActionManager): number;
  98190. /**
  98191. * Removes the given texture from this scene.
  98192. * @param toRemove The texture to remove
  98193. * @returns The index of the removed texture
  98194. */
  98195. removeTexture(toRemove: BaseTexture): number;
  98196. /**
  98197. * Adds the given light to this scene
  98198. * @param newLight The light to add
  98199. */
  98200. addLight(newLight: Light): void;
  98201. /**
  98202. * Sorts the list list based on light priorities
  98203. */
  98204. sortLightsByPriority(): void;
  98205. /**
  98206. * Adds the given camera to this scene
  98207. * @param newCamera The camera to add
  98208. */
  98209. addCamera(newCamera: Camera): void;
  98210. /**
  98211. * Adds the given skeleton to this scene
  98212. * @param newSkeleton The skeleton to add
  98213. */
  98214. addSkeleton(newSkeleton: Skeleton): void;
  98215. /**
  98216. * Adds the given particle system to this scene
  98217. * @param newParticleSystem The particle system to add
  98218. */
  98219. addParticleSystem(newParticleSystem: IParticleSystem): void;
  98220. /**
  98221. * Adds the given animation to this scene
  98222. * @param newAnimation The animation to add
  98223. */
  98224. addAnimation(newAnimation: Animation): void;
  98225. /**
  98226. * Adds the given animation group to this scene.
  98227. * @param newAnimationGroup The animation group to add
  98228. */
  98229. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  98230. /**
  98231. * Adds the given multi-material to this scene
  98232. * @param newMultiMaterial The multi-material to add
  98233. */
  98234. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  98235. /**
  98236. * Adds the given material to this scene
  98237. * @param newMaterial The material to add
  98238. */
  98239. addMaterial(newMaterial: Material): void;
  98240. /**
  98241. * Adds the given morph target to this scene
  98242. * @param newMorphTargetManager The morph target to add
  98243. */
  98244. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  98245. /**
  98246. * Adds the given geometry to this scene
  98247. * @param newGeometry The geometry to add
  98248. */
  98249. addGeometry(newGeometry: Geometry): void;
  98250. /**
  98251. * Adds the given action manager to this scene
  98252. * @param newActionManager The action manager to add
  98253. */
  98254. addActionManager(newActionManager: AbstractActionManager): void;
  98255. /**
  98256. * Adds the given texture to this scene.
  98257. * @param newTexture The texture to add
  98258. */
  98259. addTexture(newTexture: BaseTexture): void;
  98260. /**
  98261. * Switch active camera
  98262. * @param newCamera defines the new active camera
  98263. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  98264. */
  98265. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  98266. /**
  98267. * sets the active camera of the scene using its ID
  98268. * @param id defines the camera's ID
  98269. * @return the new active camera or null if none found.
  98270. */
  98271. setActiveCameraByID(id: string): Nullable<Camera>;
  98272. /**
  98273. * sets the active camera of the scene using its name
  98274. * @param name defines the camera's name
  98275. * @returns the new active camera or null if none found.
  98276. */
  98277. setActiveCameraByName(name: string): Nullable<Camera>;
  98278. /**
  98279. * get an animation group using its name
  98280. * @param name defines the material's name
  98281. * @return the animation group or null if none found.
  98282. */
  98283. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  98284. /**
  98285. * Get a material using its unique id
  98286. * @param uniqueId defines the material's unique id
  98287. * @return the material or null if none found.
  98288. */
  98289. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  98290. /**
  98291. * get a material using its id
  98292. * @param id defines the material's ID
  98293. * @return the material or null if none found.
  98294. */
  98295. getMaterialByID(id: string): Nullable<Material>;
  98296. /**
  98297. * Gets a the last added material using a given id
  98298. * @param id defines the material's ID
  98299. * @return the last material with the given id or null if none found.
  98300. */
  98301. getLastMaterialByID(id: string): Nullable<Material>;
  98302. /**
  98303. * Gets a material using its name
  98304. * @param name defines the material's name
  98305. * @return the material or null if none found.
  98306. */
  98307. getMaterialByName(name: string): Nullable<Material>;
  98308. /**
  98309. * Get a texture using its unique id
  98310. * @param uniqueId defines the texture's unique id
  98311. * @return the texture or null if none found.
  98312. */
  98313. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  98314. /**
  98315. * Gets a camera using its id
  98316. * @param id defines the id to look for
  98317. * @returns the camera or null if not found
  98318. */
  98319. getCameraByID(id: string): Nullable<Camera>;
  98320. /**
  98321. * Gets a camera using its unique id
  98322. * @param uniqueId defines the unique id to look for
  98323. * @returns the camera or null if not found
  98324. */
  98325. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  98326. /**
  98327. * Gets a camera using its name
  98328. * @param name defines the camera's name
  98329. * @return the camera or null if none found.
  98330. */
  98331. getCameraByName(name: string): Nullable<Camera>;
  98332. /**
  98333. * Gets a bone using its id
  98334. * @param id defines the bone's id
  98335. * @return the bone or null if not found
  98336. */
  98337. getBoneByID(id: string): Nullable<Bone>;
  98338. /**
  98339. * Gets a bone using its id
  98340. * @param name defines the bone's name
  98341. * @return the bone or null if not found
  98342. */
  98343. getBoneByName(name: string): Nullable<Bone>;
  98344. /**
  98345. * Gets a light node using its name
  98346. * @param name defines the the light's name
  98347. * @return the light or null if none found.
  98348. */
  98349. getLightByName(name: string): Nullable<Light>;
  98350. /**
  98351. * Gets a light node using its id
  98352. * @param id defines the light's id
  98353. * @return the light or null if none found.
  98354. */
  98355. getLightByID(id: string): Nullable<Light>;
  98356. /**
  98357. * Gets a light node using its scene-generated unique ID
  98358. * @param uniqueId defines the light's unique id
  98359. * @return the light or null if none found.
  98360. */
  98361. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  98362. /**
  98363. * Gets a particle system by id
  98364. * @param id defines the particle system id
  98365. * @return the corresponding system or null if none found
  98366. */
  98367. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  98368. /**
  98369. * Gets a geometry using its ID
  98370. * @param id defines the geometry's id
  98371. * @return the geometry or null if none found.
  98372. */
  98373. getGeometryByID(id: string): Nullable<Geometry>;
  98374. private _getGeometryByUniqueID;
  98375. /**
  98376. * Add a new geometry to this scene
  98377. * @param geometry defines the geometry to be added to the scene.
  98378. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  98379. * @return a boolean defining if the geometry was added or not
  98380. */
  98381. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  98382. /**
  98383. * Removes an existing geometry
  98384. * @param geometry defines the geometry to be removed from the scene
  98385. * @return a boolean defining if the geometry was removed or not
  98386. */
  98387. removeGeometry(geometry: Geometry): boolean;
  98388. /**
  98389. * Gets the list of geometries attached to the scene
  98390. * @returns an array of Geometry
  98391. */
  98392. getGeometries(): Geometry[];
  98393. /**
  98394. * Gets the first added mesh found of a given ID
  98395. * @param id defines the id to search for
  98396. * @return the mesh found or null if not found at all
  98397. */
  98398. getMeshByID(id: string): Nullable<AbstractMesh>;
  98399. /**
  98400. * Gets a list of meshes using their id
  98401. * @param id defines the id to search for
  98402. * @returns a list of meshes
  98403. */
  98404. getMeshesByID(id: string): Array<AbstractMesh>;
  98405. /**
  98406. * Gets the first added transform node found of a given ID
  98407. * @param id defines the id to search for
  98408. * @return the found transform node or null if not found at all.
  98409. */
  98410. getTransformNodeByID(id: string): Nullable<TransformNode>;
  98411. /**
  98412. * Gets a transform node with its auto-generated unique id
  98413. * @param uniqueId efines the unique id to search for
  98414. * @return the found transform node or null if not found at all.
  98415. */
  98416. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  98417. /**
  98418. * Gets a list of transform nodes using their id
  98419. * @param id defines the id to search for
  98420. * @returns a list of transform nodes
  98421. */
  98422. getTransformNodesByID(id: string): Array<TransformNode>;
  98423. /**
  98424. * Gets a mesh with its auto-generated unique id
  98425. * @param uniqueId defines the unique id to search for
  98426. * @return the found mesh or null if not found at all.
  98427. */
  98428. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  98429. /**
  98430. * Gets a the last added mesh using a given id
  98431. * @param id defines the id to search for
  98432. * @return the found mesh or null if not found at all.
  98433. */
  98434. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  98435. /**
  98436. * Gets a the last added node (Mesh, Camera, Light) using a given id
  98437. * @param id defines the id to search for
  98438. * @return the found node or null if not found at all
  98439. */
  98440. getLastEntryByID(id: string): Nullable<Node>;
  98441. /**
  98442. * Gets a node (Mesh, Camera, Light) using a given id
  98443. * @param id defines the id to search for
  98444. * @return the found node or null if not found at all
  98445. */
  98446. getNodeByID(id: string): Nullable<Node>;
  98447. /**
  98448. * Gets a node (Mesh, Camera, Light) using a given name
  98449. * @param name defines the name to search for
  98450. * @return the found node or null if not found at all.
  98451. */
  98452. getNodeByName(name: string): Nullable<Node>;
  98453. /**
  98454. * Gets a mesh using a given name
  98455. * @param name defines the name to search for
  98456. * @return the found mesh or null if not found at all.
  98457. */
  98458. getMeshByName(name: string): Nullable<AbstractMesh>;
  98459. /**
  98460. * Gets a transform node using a given name
  98461. * @param name defines the name to search for
  98462. * @return the found transform node or null if not found at all.
  98463. */
  98464. getTransformNodeByName(name: string): Nullable<TransformNode>;
  98465. /**
  98466. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  98467. * @param id defines the id to search for
  98468. * @return the found skeleton or null if not found at all.
  98469. */
  98470. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  98471. /**
  98472. * Gets a skeleton using a given auto generated unique id
  98473. * @param uniqueId defines the unique id to search for
  98474. * @return the found skeleton or null if not found at all.
  98475. */
  98476. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  98477. /**
  98478. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  98479. * @param id defines the id to search for
  98480. * @return the found skeleton or null if not found at all.
  98481. */
  98482. getSkeletonById(id: string): Nullable<Skeleton>;
  98483. /**
  98484. * Gets a skeleton using a given name
  98485. * @param name defines the name to search for
  98486. * @return the found skeleton or null if not found at all.
  98487. */
  98488. getSkeletonByName(name: string): Nullable<Skeleton>;
  98489. /**
  98490. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  98491. * @param id defines the id to search for
  98492. * @return the found morph target manager or null if not found at all.
  98493. */
  98494. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  98495. /**
  98496. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  98497. * @param id defines the id to search for
  98498. * @return the found morph target or null if not found at all.
  98499. */
  98500. getMorphTargetById(id: string): Nullable<MorphTarget>;
  98501. /**
  98502. * Gets a boolean indicating if the given mesh is active
  98503. * @param mesh defines the mesh to look for
  98504. * @returns true if the mesh is in the active list
  98505. */
  98506. isActiveMesh(mesh: AbstractMesh): boolean;
  98507. /**
  98508. * Return a unique id as a string which can serve as an identifier for the scene
  98509. */
  98510. readonly uid: string;
  98511. /**
  98512. * Add an externaly attached data from its key.
  98513. * This method call will fail and return false, if such key already exists.
  98514. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  98515. * @param key the unique key that identifies the data
  98516. * @param data the data object to associate to the key for this Engine instance
  98517. * @return true if no such key were already present and the data was added successfully, false otherwise
  98518. */
  98519. addExternalData<T>(key: string, data: T): boolean;
  98520. /**
  98521. * Get an externaly attached data from its key
  98522. * @param key the unique key that identifies the data
  98523. * @return the associated data, if present (can be null), or undefined if not present
  98524. */
  98525. getExternalData<T>(key: string): Nullable<T>;
  98526. /**
  98527. * Get an externaly attached data from its key, create it using a factory if it's not already present
  98528. * @param key the unique key that identifies the data
  98529. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  98530. * @return the associated data, can be null if the factory returned null.
  98531. */
  98532. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  98533. /**
  98534. * Remove an externaly attached data from the Engine instance
  98535. * @param key the unique key that identifies the data
  98536. * @return true if the data was successfully removed, false if it doesn't exist
  98537. */
  98538. removeExternalData(key: string): boolean;
  98539. private _evaluateSubMesh;
  98540. /**
  98541. * Clear the processed materials smart array preventing retention point in material dispose.
  98542. */
  98543. freeProcessedMaterials(): void;
  98544. private _preventFreeActiveMeshesAndRenderingGroups;
  98545. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  98546. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  98547. * when disposing several meshes in a row or a hierarchy of meshes.
  98548. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  98549. */
  98550. blockfreeActiveMeshesAndRenderingGroups: boolean;
  98551. /**
  98552. * Clear the active meshes smart array preventing retention point in mesh dispose.
  98553. */
  98554. freeActiveMeshes(): void;
  98555. /**
  98556. * Clear the info related to rendering groups preventing retention points during dispose.
  98557. */
  98558. freeRenderingGroups(): void;
  98559. /** @hidden */
  98560. _isInIntermediateRendering(): boolean;
  98561. /**
  98562. * Lambda returning the list of potentially active meshes.
  98563. */
  98564. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  98565. /**
  98566. * Lambda returning the list of potentially active sub meshes.
  98567. */
  98568. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  98569. /**
  98570. * Lambda returning the list of potentially intersecting sub meshes.
  98571. */
  98572. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  98573. /**
  98574. * Lambda returning the list of potentially colliding sub meshes.
  98575. */
  98576. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  98577. private _activeMeshesFrozen;
  98578. /**
  98579. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  98580. * @returns the current scene
  98581. */
  98582. freezeActiveMeshes(): Scene;
  98583. /**
  98584. * Use this function to restart evaluating active meshes on every frame
  98585. * @returns the current scene
  98586. */
  98587. unfreezeActiveMeshes(): Scene;
  98588. private _evaluateActiveMeshes;
  98589. private _activeMesh;
  98590. /**
  98591. * Update the transform matrix to update from the current active camera
  98592. * @param force defines a boolean used to force the update even if cache is up to date
  98593. */
  98594. updateTransformMatrix(force?: boolean): void;
  98595. private _bindFrameBuffer;
  98596. /** @hidden */
  98597. _allowPostProcessClearColor: boolean;
  98598. /** @hidden */
  98599. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  98600. private _processSubCameras;
  98601. private _checkIntersections;
  98602. /** @hidden */
  98603. _advancePhysicsEngineStep(step: number): void;
  98604. /**
  98605. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  98606. */
  98607. getDeterministicFrameTime: () => number;
  98608. /** @hidden */
  98609. _animate(): void;
  98610. /** Execute all animations (for a frame) */
  98611. animate(): void;
  98612. /**
  98613. * Render the scene
  98614. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  98615. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  98616. */
  98617. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  98618. /**
  98619. * Freeze all materials
  98620. * A frozen material will not be updatable but should be faster to render
  98621. */
  98622. freezeMaterials(): void;
  98623. /**
  98624. * Unfreeze all materials
  98625. * A frozen material will not be updatable but should be faster to render
  98626. */
  98627. unfreezeMaterials(): void;
  98628. /**
  98629. * Releases all held ressources
  98630. */
  98631. dispose(): void;
  98632. /**
  98633. * Gets if the scene is already disposed
  98634. */
  98635. readonly isDisposed: boolean;
  98636. /**
  98637. * Call this function to reduce memory footprint of the scene.
  98638. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  98639. */
  98640. clearCachedVertexData(): void;
  98641. /**
  98642. * This function will remove the local cached buffer data from texture.
  98643. * It will save memory but will prevent the texture from being rebuilt
  98644. */
  98645. cleanCachedTextureBuffer(): void;
  98646. /**
  98647. * Get the world extend vectors with an optional filter
  98648. *
  98649. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  98650. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  98651. */
  98652. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  98653. min: Vector3;
  98654. max: Vector3;
  98655. };
  98656. /**
  98657. * Creates a ray that can be used to pick in the scene
  98658. * @param x defines the x coordinate of the origin (on-screen)
  98659. * @param y defines the y coordinate of the origin (on-screen)
  98660. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98661. * @param camera defines the camera to use for the picking
  98662. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98663. * @returns a Ray
  98664. */
  98665. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  98666. /**
  98667. * Creates a ray that can be used to pick in the scene
  98668. * @param x defines the x coordinate of the origin (on-screen)
  98669. * @param y defines the y coordinate of the origin (on-screen)
  98670. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98671. * @param result defines the ray where to store the picking ray
  98672. * @param camera defines the camera to use for the picking
  98673. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98674. * @returns the current scene
  98675. */
  98676. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  98677. /**
  98678. * Creates a ray that can be used to pick in the scene
  98679. * @param x defines the x coordinate of the origin (on-screen)
  98680. * @param y defines the y coordinate of the origin (on-screen)
  98681. * @param camera defines the camera to use for the picking
  98682. * @returns a Ray
  98683. */
  98684. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  98685. /**
  98686. * Creates a ray that can be used to pick in the scene
  98687. * @param x defines the x coordinate of the origin (on-screen)
  98688. * @param y defines the y coordinate of the origin (on-screen)
  98689. * @param result defines the ray where to store the picking ray
  98690. * @param camera defines the camera to use for the picking
  98691. * @returns the current scene
  98692. */
  98693. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  98694. /** Launch a ray to try to pick a mesh in the scene
  98695. * @param x position on screen
  98696. * @param y position on screen
  98697. * @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
  98698. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  98699. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98700. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98701. * @returns a PickingInfo
  98702. */
  98703. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98704. /** Use the given ray to pick a mesh in the scene
  98705. * @param ray The ray to use to pick meshes
  98706. * @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
  98707. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  98708. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98709. * @returns a PickingInfo
  98710. */
  98711. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98712. /**
  98713. * Launch a ray to try to pick a mesh in the scene
  98714. * @param x X position on screen
  98715. * @param y Y position on screen
  98716. * @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
  98717. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98718. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98719. * @returns an array of PickingInfo
  98720. */
  98721. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98722. /**
  98723. * Launch a ray to try to pick a mesh in the scene
  98724. * @param ray Ray to use
  98725. * @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
  98726. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98727. * @returns an array of PickingInfo
  98728. */
  98729. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98730. /**
  98731. * Force the value of meshUnderPointer
  98732. * @param mesh defines the mesh to use
  98733. */
  98734. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98735. /**
  98736. * Gets the mesh under the pointer
  98737. * @returns a Mesh or null if no mesh is under the pointer
  98738. */
  98739. getPointerOverMesh(): Nullable<AbstractMesh>;
  98740. /** @hidden */
  98741. _rebuildGeometries(): void;
  98742. /** @hidden */
  98743. _rebuildTextures(): void;
  98744. private _getByTags;
  98745. /**
  98746. * Get a list of meshes by tags
  98747. * @param tagsQuery defines the tags query to use
  98748. * @param forEach defines a predicate used to filter results
  98749. * @returns an array of Mesh
  98750. */
  98751. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  98752. /**
  98753. * Get a list of cameras by tags
  98754. * @param tagsQuery defines the tags query to use
  98755. * @param forEach defines a predicate used to filter results
  98756. * @returns an array of Camera
  98757. */
  98758. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  98759. /**
  98760. * Get a list of lights by tags
  98761. * @param tagsQuery defines the tags query to use
  98762. * @param forEach defines a predicate used to filter results
  98763. * @returns an array of Light
  98764. */
  98765. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  98766. /**
  98767. * Get a list of materials by tags
  98768. * @param tagsQuery defines the tags query to use
  98769. * @param forEach defines a predicate used to filter results
  98770. * @returns an array of Material
  98771. */
  98772. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  98773. /**
  98774. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98775. * This allowed control for front to back rendering or reversly depending of the special needs.
  98776. *
  98777. * @param renderingGroupId The rendering group id corresponding to its index
  98778. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98779. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98780. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98781. */
  98782. 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;
  98783. /**
  98784. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98785. *
  98786. * @param renderingGroupId The rendering group id corresponding to its index
  98787. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98788. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98789. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98790. */
  98791. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98792. /**
  98793. * Gets the current auto clear configuration for one rendering group of the rendering
  98794. * manager.
  98795. * @param index the rendering group index to get the information for
  98796. * @returns The auto clear setup for the requested rendering group
  98797. */
  98798. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98799. private _blockMaterialDirtyMechanism;
  98800. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  98801. blockMaterialDirtyMechanism: boolean;
  98802. /**
  98803. * Will flag all materials as dirty to trigger new shader compilation
  98804. * @param flag defines the flag used to specify which material part must be marked as dirty
  98805. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  98806. */
  98807. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98808. /** @hidden */
  98809. _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;
  98810. /** @hidden */
  98811. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98812. }
  98813. }
  98814. declare module BABYLON {
  98815. /**
  98816. * Set of assets to keep when moving a scene into an asset container.
  98817. */
  98818. export class KeepAssets extends AbstractScene {
  98819. }
  98820. /**
  98821. * Container with a set of assets that can be added or removed from a scene.
  98822. */
  98823. export class AssetContainer extends AbstractScene {
  98824. /**
  98825. * The scene the AssetContainer belongs to.
  98826. */
  98827. scene: Scene;
  98828. /**
  98829. * Instantiates an AssetContainer.
  98830. * @param scene The scene the AssetContainer belongs to.
  98831. */
  98832. constructor(scene: Scene);
  98833. /**
  98834. * Adds all the assets from the container to the scene.
  98835. */
  98836. addAllToScene(): void;
  98837. /**
  98838. * Removes all the assets in the container from the scene
  98839. */
  98840. removeAllFromScene(): void;
  98841. /**
  98842. * Disposes all the assets in the container
  98843. */
  98844. dispose(): void;
  98845. private _moveAssets;
  98846. /**
  98847. * Removes all the assets contained in the scene and adds them to the container.
  98848. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  98849. */
  98850. moveAllFromScene(keepAssets?: KeepAssets): void;
  98851. /**
  98852. * 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.
  98853. * @returns the root mesh
  98854. */
  98855. createRootMesh(): Mesh;
  98856. }
  98857. }
  98858. declare module BABYLON {
  98859. /**
  98860. * Defines how the parser contract is defined.
  98861. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  98862. */
  98863. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  98864. /**
  98865. * Defines how the individual parser contract is defined.
  98866. * These parser can parse an individual asset
  98867. */
  98868. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  98869. /**
  98870. * Base class of the scene acting as a container for the different elements composing a scene.
  98871. * This class is dynamically extended by the different components of the scene increasing
  98872. * flexibility and reducing coupling
  98873. */
  98874. export abstract class AbstractScene {
  98875. /**
  98876. * Stores the list of available parsers in the application.
  98877. */
  98878. private static _BabylonFileParsers;
  98879. /**
  98880. * Stores the list of available individual parsers in the application.
  98881. */
  98882. private static _IndividualBabylonFileParsers;
  98883. /**
  98884. * Adds a parser in the list of available ones
  98885. * @param name Defines the name of the parser
  98886. * @param parser Defines the parser to add
  98887. */
  98888. static AddParser(name: string, parser: BabylonFileParser): void;
  98889. /**
  98890. * Gets a general parser from the list of avaialble ones
  98891. * @param name Defines the name of the parser
  98892. * @returns the requested parser or null
  98893. */
  98894. static GetParser(name: string): Nullable<BabylonFileParser>;
  98895. /**
  98896. * Adds n individual parser in the list of available ones
  98897. * @param name Defines the name of the parser
  98898. * @param parser Defines the parser to add
  98899. */
  98900. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  98901. /**
  98902. * Gets an individual parser from the list of avaialble ones
  98903. * @param name Defines the name of the parser
  98904. * @returns the requested parser or null
  98905. */
  98906. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  98907. /**
  98908. * Parser json data and populate both a scene and its associated container object
  98909. * @param jsonData Defines the data to parse
  98910. * @param scene Defines the scene to parse the data for
  98911. * @param container Defines the container attached to the parsing sequence
  98912. * @param rootUrl Defines the root url of the data
  98913. */
  98914. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  98915. /**
  98916. * Gets the list of root nodes (ie. nodes with no parent)
  98917. */
  98918. rootNodes: Node[];
  98919. /** All of the cameras added to this scene
  98920. * @see http://doc.babylonjs.com/babylon101/cameras
  98921. */
  98922. cameras: Camera[];
  98923. /**
  98924. * All of the lights added to this scene
  98925. * @see http://doc.babylonjs.com/babylon101/lights
  98926. */
  98927. lights: Light[];
  98928. /**
  98929. * All of the (abstract) meshes added to this scene
  98930. */
  98931. meshes: AbstractMesh[];
  98932. /**
  98933. * The list of skeletons added to the scene
  98934. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98935. */
  98936. skeletons: Skeleton[];
  98937. /**
  98938. * All of the particle systems added to this scene
  98939. * @see http://doc.babylonjs.com/babylon101/particles
  98940. */
  98941. particleSystems: IParticleSystem[];
  98942. /**
  98943. * Gets a list of Animations associated with the scene
  98944. */
  98945. animations: Animation[];
  98946. /**
  98947. * All of the animation groups added to this scene
  98948. * @see http://doc.babylonjs.com/how_to/group
  98949. */
  98950. animationGroups: AnimationGroup[];
  98951. /**
  98952. * All of the multi-materials added to this scene
  98953. * @see http://doc.babylonjs.com/how_to/multi_materials
  98954. */
  98955. multiMaterials: MultiMaterial[];
  98956. /**
  98957. * All of the materials added to this scene
  98958. * In the context of a Scene, it is not supposed to be modified manually.
  98959. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  98960. * Note also that the order of the Material wihin the array is not significant and might change.
  98961. * @see http://doc.babylonjs.com/babylon101/materials
  98962. */
  98963. materials: Material[];
  98964. /**
  98965. * The list of morph target managers added to the scene
  98966. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  98967. */
  98968. morphTargetManagers: MorphTargetManager[];
  98969. /**
  98970. * The list of geometries used in the scene.
  98971. */
  98972. geometries: Geometry[];
  98973. /**
  98974. * All of the tranform nodes added to this scene
  98975. * In the context of a Scene, it is not supposed to be modified manually.
  98976. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  98977. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  98978. * @see http://doc.babylonjs.com/how_to/transformnode
  98979. */
  98980. transformNodes: TransformNode[];
  98981. /**
  98982. * ActionManagers available on the scene.
  98983. */
  98984. actionManagers: AbstractActionManager[];
  98985. /**
  98986. * Textures to keep.
  98987. */
  98988. textures: BaseTexture[];
  98989. /**
  98990. * Environment texture for the scene
  98991. */
  98992. environmentTexture: Nullable<BaseTexture>;
  98993. }
  98994. }
  98995. declare module BABYLON {
  98996. /**
  98997. * Interface used to define options for Sound class
  98998. */
  98999. export interface ISoundOptions {
  99000. /**
  99001. * Does the sound autoplay once loaded.
  99002. */
  99003. autoplay?: boolean;
  99004. /**
  99005. * Does the sound loop after it finishes playing once.
  99006. */
  99007. loop?: boolean;
  99008. /**
  99009. * Sound's volume
  99010. */
  99011. volume?: number;
  99012. /**
  99013. * Is it a spatial sound?
  99014. */
  99015. spatialSound?: boolean;
  99016. /**
  99017. * Maximum distance to hear that sound
  99018. */
  99019. maxDistance?: number;
  99020. /**
  99021. * Uses user defined attenuation function
  99022. */
  99023. useCustomAttenuation?: boolean;
  99024. /**
  99025. * Define the roll off factor of spatial sounds.
  99026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99027. */
  99028. rolloffFactor?: number;
  99029. /**
  99030. * Define the reference distance the sound should be heard perfectly.
  99031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99032. */
  99033. refDistance?: number;
  99034. /**
  99035. * Define the distance attenuation model the sound will follow.
  99036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99037. */
  99038. distanceModel?: string;
  99039. /**
  99040. * Defines the playback speed (1 by default)
  99041. */
  99042. playbackRate?: number;
  99043. /**
  99044. * Defines if the sound is from a streaming source
  99045. */
  99046. streaming?: boolean;
  99047. /**
  99048. * Defines an optional length (in seconds) inside the sound file
  99049. */
  99050. length?: number;
  99051. /**
  99052. * Defines an optional offset (in seconds) inside the sound file
  99053. */
  99054. offset?: number;
  99055. /**
  99056. * If true, URLs will not be required to state the audio file codec to use.
  99057. */
  99058. skipCodecCheck?: boolean;
  99059. }
  99060. /**
  99061. * Defines a sound that can be played in the application.
  99062. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  99063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99064. */
  99065. export class Sound {
  99066. /**
  99067. * The name of the sound in the scene.
  99068. */
  99069. name: string;
  99070. /**
  99071. * Does the sound autoplay once loaded.
  99072. */
  99073. autoplay: boolean;
  99074. /**
  99075. * Does the sound loop after it finishes playing once.
  99076. */
  99077. loop: boolean;
  99078. /**
  99079. * Does the sound use a custom attenuation curve to simulate the falloff
  99080. * happening when the source gets further away from the camera.
  99081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99082. */
  99083. useCustomAttenuation: boolean;
  99084. /**
  99085. * The sound track id this sound belongs to.
  99086. */
  99087. soundTrackId: number;
  99088. /**
  99089. * Is this sound currently played.
  99090. */
  99091. isPlaying: boolean;
  99092. /**
  99093. * Is this sound currently paused.
  99094. */
  99095. isPaused: boolean;
  99096. /**
  99097. * Does this sound enables spatial sound.
  99098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99099. */
  99100. spatialSound: boolean;
  99101. /**
  99102. * Define the reference distance the sound should be heard perfectly.
  99103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99104. */
  99105. refDistance: number;
  99106. /**
  99107. * Define the roll off factor of spatial sounds.
  99108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99109. */
  99110. rolloffFactor: number;
  99111. /**
  99112. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  99113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99114. */
  99115. maxDistance: number;
  99116. /**
  99117. * Define the distance attenuation model the sound will follow.
  99118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99119. */
  99120. distanceModel: string;
  99121. /**
  99122. * @hidden
  99123. * Back Compat
  99124. **/
  99125. onended: () => any;
  99126. /**
  99127. * Observable event when the current playing sound finishes.
  99128. */
  99129. onEndedObservable: Observable<Sound>;
  99130. private _panningModel;
  99131. private _playbackRate;
  99132. private _streaming;
  99133. private _startTime;
  99134. private _startOffset;
  99135. private _position;
  99136. /** @hidden */
  99137. _positionInEmitterSpace: boolean;
  99138. private _localDirection;
  99139. private _volume;
  99140. private _isReadyToPlay;
  99141. private _isDirectional;
  99142. private _readyToPlayCallback;
  99143. private _audioBuffer;
  99144. private _soundSource;
  99145. private _streamingSource;
  99146. private _soundPanner;
  99147. private _soundGain;
  99148. private _inputAudioNode;
  99149. private _outputAudioNode;
  99150. private _coneInnerAngle;
  99151. private _coneOuterAngle;
  99152. private _coneOuterGain;
  99153. private _scene;
  99154. private _connectedTransformNode;
  99155. private _customAttenuationFunction;
  99156. private _registerFunc;
  99157. private _isOutputConnected;
  99158. private _htmlAudioElement;
  99159. private _urlType;
  99160. private _length?;
  99161. private _offset?;
  99162. /** @hidden */
  99163. static _SceneComponentInitialization: (scene: Scene) => void;
  99164. /**
  99165. * Create a sound and attach it to a scene
  99166. * @param name Name of your sound
  99167. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  99168. * @param scene defines the scene the sound belongs to
  99169. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  99170. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  99171. */
  99172. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  99173. /**
  99174. * Release the sound and its associated resources
  99175. */
  99176. dispose(): void;
  99177. /**
  99178. * Gets if the sounds is ready to be played or not.
  99179. * @returns true if ready, otherwise false
  99180. */
  99181. isReady(): boolean;
  99182. private _soundLoaded;
  99183. /**
  99184. * Sets the data of the sound from an audiobuffer
  99185. * @param audioBuffer The audioBuffer containing the data
  99186. */
  99187. setAudioBuffer(audioBuffer: AudioBuffer): void;
  99188. /**
  99189. * Updates the current sounds options such as maxdistance, loop...
  99190. * @param options A JSON object containing values named as the object properties
  99191. */
  99192. updateOptions(options: ISoundOptions): void;
  99193. private _createSpatialParameters;
  99194. private _updateSpatialParameters;
  99195. /**
  99196. * Switch the panning model to HRTF:
  99197. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99199. */
  99200. switchPanningModelToHRTF(): void;
  99201. /**
  99202. * Switch the panning model to Equal Power:
  99203. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99205. */
  99206. switchPanningModelToEqualPower(): void;
  99207. private _switchPanningModel;
  99208. /**
  99209. * Connect this sound to a sound track audio node like gain...
  99210. * @param soundTrackAudioNode the sound track audio node to connect to
  99211. */
  99212. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  99213. /**
  99214. * Transform this sound into a directional source
  99215. * @param coneInnerAngle Size of the inner cone in degree
  99216. * @param coneOuterAngle Size of the outer cone in degree
  99217. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  99218. */
  99219. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  99220. /**
  99221. * Gets or sets the inner angle for the directional cone.
  99222. */
  99223. /**
  99224. * Gets or sets the inner angle for the directional cone.
  99225. */
  99226. directionalConeInnerAngle: number;
  99227. /**
  99228. * Gets or sets the outer angle for the directional cone.
  99229. */
  99230. /**
  99231. * Gets or sets the outer angle for the directional cone.
  99232. */
  99233. directionalConeOuterAngle: number;
  99234. /**
  99235. * Sets the position of the emitter if spatial sound is enabled
  99236. * @param newPosition Defines the new posisiton
  99237. */
  99238. setPosition(newPosition: Vector3): void;
  99239. /**
  99240. * Sets the local direction of the emitter if spatial sound is enabled
  99241. * @param newLocalDirection Defines the new local direction
  99242. */
  99243. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  99244. private _updateDirection;
  99245. /** @hidden */
  99246. updateDistanceFromListener(): void;
  99247. /**
  99248. * Sets a new custom attenuation function for the sound.
  99249. * @param callback Defines the function used for the attenuation
  99250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99251. */
  99252. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  99253. /**
  99254. * Play the sound
  99255. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  99256. * @param offset (optional) Start the sound at a specific time in seconds
  99257. * @param length (optional) Sound duration (in seconds)
  99258. */
  99259. play(time?: number, offset?: number, length?: number): void;
  99260. private _onended;
  99261. /**
  99262. * Stop the sound
  99263. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  99264. */
  99265. stop(time?: number): void;
  99266. /**
  99267. * Put the sound in pause
  99268. */
  99269. pause(): void;
  99270. /**
  99271. * Sets a dedicated volume for this sounds
  99272. * @param newVolume Define the new volume of the sound
  99273. * @param time Define time for gradual change to new volume
  99274. */
  99275. setVolume(newVolume: number, time?: number): void;
  99276. /**
  99277. * Set the sound play back rate
  99278. * @param newPlaybackRate Define the playback rate the sound should be played at
  99279. */
  99280. setPlaybackRate(newPlaybackRate: number): void;
  99281. /**
  99282. * Gets the volume of the sound.
  99283. * @returns the volume of the sound
  99284. */
  99285. getVolume(): number;
  99286. /**
  99287. * Attach the sound to a dedicated mesh
  99288. * @param transformNode The transform node to connect the sound with
  99289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99290. */
  99291. attachToMesh(transformNode: TransformNode): void;
  99292. /**
  99293. * Detach the sound from the previously attached mesh
  99294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99295. */
  99296. detachFromMesh(): void;
  99297. private _onRegisterAfterWorldMatrixUpdate;
  99298. /**
  99299. * Clone the current sound in the scene.
  99300. * @returns the new sound clone
  99301. */
  99302. clone(): Nullable<Sound>;
  99303. /**
  99304. * Gets the current underlying audio buffer containing the data
  99305. * @returns the audio buffer
  99306. */
  99307. getAudioBuffer(): Nullable<AudioBuffer>;
  99308. /**
  99309. * Serializes the Sound in a JSON representation
  99310. * @returns the JSON representation of the sound
  99311. */
  99312. serialize(): any;
  99313. /**
  99314. * Parse a JSON representation of a sound to innstantiate in a given scene
  99315. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  99316. * @param scene Define the scene the new parsed sound should be created in
  99317. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  99318. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  99319. * @returns the newly parsed sound
  99320. */
  99321. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  99322. }
  99323. }
  99324. declare module BABYLON {
  99325. /**
  99326. * This defines an action helpful to play a defined sound on a triggered action.
  99327. */
  99328. export class PlaySoundAction extends Action {
  99329. private _sound;
  99330. /**
  99331. * Instantiate the action
  99332. * @param triggerOptions defines the trigger options
  99333. * @param sound defines the sound to play
  99334. * @param condition defines the trigger related conditions
  99335. */
  99336. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99337. /** @hidden */
  99338. _prepare(): void;
  99339. /**
  99340. * Execute the action and play the sound.
  99341. */
  99342. execute(): void;
  99343. /**
  99344. * Serializes the actions and its related information.
  99345. * @param parent defines the object to serialize in
  99346. * @returns the serialized object
  99347. */
  99348. serialize(parent: any): any;
  99349. }
  99350. /**
  99351. * This defines an action helpful to stop a defined sound on a triggered action.
  99352. */
  99353. export class StopSoundAction extends Action {
  99354. private _sound;
  99355. /**
  99356. * Instantiate the action
  99357. * @param triggerOptions defines the trigger options
  99358. * @param sound defines the sound to stop
  99359. * @param condition defines the trigger related conditions
  99360. */
  99361. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99362. /** @hidden */
  99363. _prepare(): void;
  99364. /**
  99365. * Execute the action and stop the sound.
  99366. */
  99367. execute(): void;
  99368. /**
  99369. * Serializes the actions and its related information.
  99370. * @param parent defines the object to serialize in
  99371. * @returns the serialized object
  99372. */
  99373. serialize(parent: any): any;
  99374. }
  99375. }
  99376. declare module BABYLON {
  99377. /**
  99378. * This defines an action responsible to change the value of a property
  99379. * by interpolating between its current value and the newly set one once triggered.
  99380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99381. */
  99382. export class InterpolateValueAction extends Action {
  99383. /**
  99384. * Defines the path of the property where the value should be interpolated
  99385. */
  99386. propertyPath: string;
  99387. /**
  99388. * Defines the target value at the end of the interpolation.
  99389. */
  99390. value: any;
  99391. /**
  99392. * Defines the time it will take for the property to interpolate to the value.
  99393. */
  99394. duration: number;
  99395. /**
  99396. * Defines if the other scene animations should be stopped when the action has been triggered
  99397. */
  99398. stopOtherAnimations?: boolean;
  99399. /**
  99400. * Defines a callback raised once the interpolation animation has been done.
  99401. */
  99402. onInterpolationDone?: () => void;
  99403. /**
  99404. * Observable triggered once the interpolation animation has been done.
  99405. */
  99406. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  99407. private _target;
  99408. private _effectiveTarget;
  99409. private _property;
  99410. /**
  99411. * Instantiate the action
  99412. * @param triggerOptions defines the trigger options
  99413. * @param target defines the object containing the value to interpolate
  99414. * @param propertyPath defines the path to the property in the target object
  99415. * @param value defines the target value at the end of the interpolation
  99416. * @param duration deines the time it will take for the property to interpolate to the value.
  99417. * @param condition defines the trigger related conditions
  99418. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  99419. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  99420. */
  99421. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  99422. /** @hidden */
  99423. _prepare(): void;
  99424. /**
  99425. * Execute the action starts the value interpolation.
  99426. */
  99427. execute(): void;
  99428. /**
  99429. * Serializes the actions and its related information.
  99430. * @param parent defines the object to serialize in
  99431. * @returns the serialized object
  99432. */
  99433. serialize(parent: any): any;
  99434. }
  99435. }
  99436. declare module BABYLON {
  99437. /**
  99438. * Options allowed during the creation of a sound track.
  99439. */
  99440. export interface ISoundTrackOptions {
  99441. /**
  99442. * The volume the sound track should take during creation
  99443. */
  99444. volume?: number;
  99445. /**
  99446. * Define if the sound track is the main sound track of the scene
  99447. */
  99448. mainTrack?: boolean;
  99449. }
  99450. /**
  99451. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  99452. * It will be also used in a future release to apply effects on a specific track.
  99453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99454. */
  99455. export class SoundTrack {
  99456. /**
  99457. * The unique identifier of the sound track in the scene.
  99458. */
  99459. id: number;
  99460. /**
  99461. * The list of sounds included in the sound track.
  99462. */
  99463. soundCollection: Array<Sound>;
  99464. private _outputAudioNode;
  99465. private _scene;
  99466. private _isMainTrack;
  99467. private _connectedAnalyser;
  99468. private _options;
  99469. private _isInitialized;
  99470. /**
  99471. * Creates a new sound track.
  99472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99473. * @param scene Define the scene the sound track belongs to
  99474. * @param options
  99475. */
  99476. constructor(scene: Scene, options?: ISoundTrackOptions);
  99477. private _initializeSoundTrackAudioGraph;
  99478. /**
  99479. * Release the sound track and its associated resources
  99480. */
  99481. dispose(): void;
  99482. /**
  99483. * Adds a sound to this sound track
  99484. * @param sound define the cound to add
  99485. * @ignoreNaming
  99486. */
  99487. AddSound(sound: Sound): void;
  99488. /**
  99489. * Removes a sound to this sound track
  99490. * @param sound define the cound to remove
  99491. * @ignoreNaming
  99492. */
  99493. RemoveSound(sound: Sound): void;
  99494. /**
  99495. * Set a global volume for the full sound track.
  99496. * @param newVolume Define the new volume of the sound track
  99497. */
  99498. setVolume(newVolume: number): void;
  99499. /**
  99500. * Switch the panning model to HRTF:
  99501. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99503. */
  99504. switchPanningModelToHRTF(): void;
  99505. /**
  99506. * Switch the panning model to Equal Power:
  99507. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99509. */
  99510. switchPanningModelToEqualPower(): void;
  99511. /**
  99512. * Connect the sound track to an audio analyser allowing some amazing
  99513. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99515. * @param analyser The analyser to connect to the engine
  99516. */
  99517. connectToAnalyser(analyser: Analyser): void;
  99518. }
  99519. }
  99520. declare module BABYLON {
  99521. interface AbstractScene {
  99522. /**
  99523. * The list of sounds used in the scene.
  99524. */
  99525. sounds: Nullable<Array<Sound>>;
  99526. }
  99527. interface Scene {
  99528. /**
  99529. * @hidden
  99530. * Backing field
  99531. */
  99532. _mainSoundTrack: SoundTrack;
  99533. /**
  99534. * The main sound track played by the scene.
  99535. * It cotains your primary collection of sounds.
  99536. */
  99537. mainSoundTrack: SoundTrack;
  99538. /**
  99539. * The list of sound tracks added to the scene
  99540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99541. */
  99542. soundTracks: Nullable<Array<SoundTrack>>;
  99543. /**
  99544. * Gets a sound using a given name
  99545. * @param name defines the name to search for
  99546. * @return the found sound or null if not found at all.
  99547. */
  99548. getSoundByName(name: string): Nullable<Sound>;
  99549. /**
  99550. * Gets or sets if audio support is enabled
  99551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99552. */
  99553. audioEnabled: boolean;
  99554. /**
  99555. * Gets or sets if audio will be output to headphones
  99556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99557. */
  99558. headphone: boolean;
  99559. }
  99560. /**
  99561. * Defines the sound scene component responsible to manage any sounds
  99562. * in a given scene.
  99563. */
  99564. export class AudioSceneComponent implements ISceneSerializableComponent {
  99565. /**
  99566. * The component name helpfull to identify the component in the list of scene components.
  99567. */
  99568. readonly name: string;
  99569. /**
  99570. * The scene the component belongs to.
  99571. */
  99572. scene: Scene;
  99573. private _audioEnabled;
  99574. /**
  99575. * Gets whether audio is enabled or not.
  99576. * Please use related enable/disable method to switch state.
  99577. */
  99578. readonly audioEnabled: boolean;
  99579. private _headphone;
  99580. /**
  99581. * Gets whether audio is outputing to headphone or not.
  99582. * Please use the according Switch methods to change output.
  99583. */
  99584. readonly headphone: boolean;
  99585. /**
  99586. * Creates a new instance of the component for the given scene
  99587. * @param scene Defines the scene to register the component in
  99588. */
  99589. constructor(scene: Scene);
  99590. /**
  99591. * Registers the component in a given scene
  99592. */
  99593. register(): void;
  99594. /**
  99595. * Rebuilds the elements related to this component in case of
  99596. * context lost for instance.
  99597. */
  99598. rebuild(): void;
  99599. /**
  99600. * Serializes the component data to the specified json object
  99601. * @param serializationObject The object to serialize to
  99602. */
  99603. serialize(serializationObject: any): void;
  99604. /**
  99605. * Adds all the elements from the container to the scene
  99606. * @param container the container holding the elements
  99607. */
  99608. addFromContainer(container: AbstractScene): void;
  99609. /**
  99610. * Removes all the elements in the container from the scene
  99611. * @param container contains the elements to remove
  99612. * @param dispose if the removed element should be disposed (default: false)
  99613. */
  99614. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  99615. /**
  99616. * Disposes the component and the associated ressources.
  99617. */
  99618. dispose(): void;
  99619. /**
  99620. * Disables audio in the associated scene.
  99621. */
  99622. disableAudio(): void;
  99623. /**
  99624. * Enables audio in the associated scene.
  99625. */
  99626. enableAudio(): void;
  99627. /**
  99628. * Switch audio to headphone output.
  99629. */
  99630. switchAudioModeForHeadphones(): void;
  99631. /**
  99632. * Switch audio to normal speakers.
  99633. */
  99634. switchAudioModeForNormalSpeakers(): void;
  99635. private _afterRender;
  99636. }
  99637. }
  99638. declare module BABYLON {
  99639. /**
  99640. * Wraps one or more Sound objects and selects one with random weight for playback.
  99641. */
  99642. export class WeightedSound {
  99643. /** When true a Sound will be selected and played when the current playing Sound completes. */
  99644. loop: boolean;
  99645. private _coneInnerAngle;
  99646. private _coneOuterAngle;
  99647. private _volume;
  99648. /** A Sound is currently playing. */
  99649. isPlaying: boolean;
  99650. /** A Sound is currently paused. */
  99651. isPaused: boolean;
  99652. private _sounds;
  99653. private _weights;
  99654. private _currentIndex?;
  99655. /**
  99656. * Creates a new WeightedSound from the list of sounds given.
  99657. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  99658. * @param sounds Array of Sounds that will be selected from.
  99659. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  99660. */
  99661. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  99662. /**
  99663. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  99664. */
  99665. /**
  99666. * The size of cone in degress for a directional sound in which there will be no attenuation.
  99667. */
  99668. directionalConeInnerAngle: number;
  99669. /**
  99670. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99671. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99672. */
  99673. /**
  99674. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99675. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99676. */
  99677. directionalConeOuterAngle: number;
  99678. /**
  99679. * Playback volume.
  99680. */
  99681. /**
  99682. * Playback volume.
  99683. */
  99684. volume: number;
  99685. private _onended;
  99686. /**
  99687. * Suspend playback
  99688. */
  99689. pause(): void;
  99690. /**
  99691. * Stop playback
  99692. */
  99693. stop(): void;
  99694. /**
  99695. * Start playback.
  99696. * @param startOffset Position the clip head at a specific time in seconds.
  99697. */
  99698. play(startOffset?: number): void;
  99699. }
  99700. }
  99701. declare module BABYLON {
  99702. /**
  99703. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  99704. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99705. */
  99706. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  99707. /**
  99708. * Gets the name of the behavior.
  99709. */
  99710. readonly name: string;
  99711. /**
  99712. * The easing function used by animations
  99713. */
  99714. static EasingFunction: BackEase;
  99715. /**
  99716. * The easing mode used by animations
  99717. */
  99718. static EasingMode: number;
  99719. /**
  99720. * The duration of the animation, in milliseconds
  99721. */
  99722. transitionDuration: number;
  99723. /**
  99724. * Length of the distance animated by the transition when lower radius is reached
  99725. */
  99726. lowerRadiusTransitionRange: number;
  99727. /**
  99728. * Length of the distance animated by the transition when upper radius is reached
  99729. */
  99730. upperRadiusTransitionRange: number;
  99731. private _autoTransitionRange;
  99732. /**
  99733. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99734. */
  99735. /**
  99736. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99737. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  99738. */
  99739. autoTransitionRange: boolean;
  99740. private _attachedCamera;
  99741. private _onAfterCheckInputsObserver;
  99742. private _onMeshTargetChangedObserver;
  99743. /**
  99744. * Initializes the behavior.
  99745. */
  99746. init(): void;
  99747. /**
  99748. * Attaches the behavior to its arc rotate camera.
  99749. * @param camera Defines the camera to attach the behavior to
  99750. */
  99751. attach(camera: ArcRotateCamera): void;
  99752. /**
  99753. * Detaches the behavior from its current arc rotate camera.
  99754. */
  99755. detach(): void;
  99756. private _radiusIsAnimating;
  99757. private _radiusBounceTransition;
  99758. private _animatables;
  99759. private _cachedWheelPrecision;
  99760. /**
  99761. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  99762. * @param radiusLimit The limit to check against.
  99763. * @return Bool to indicate if at limit.
  99764. */
  99765. private _isRadiusAtLimit;
  99766. /**
  99767. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  99768. * @param radiusDelta The delta by which to animate to. Can be negative.
  99769. */
  99770. private _applyBoundRadiusAnimation;
  99771. /**
  99772. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  99773. */
  99774. protected _clearAnimationLocks(): void;
  99775. /**
  99776. * Stops and removes all animations that have been applied to the camera
  99777. */
  99778. stopAllAnimations(): void;
  99779. }
  99780. }
  99781. declare module BABYLON {
  99782. /**
  99783. * 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.
  99784. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99785. */
  99786. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  99787. /**
  99788. * Gets the name of the behavior.
  99789. */
  99790. readonly name: string;
  99791. private _mode;
  99792. private _radiusScale;
  99793. private _positionScale;
  99794. private _defaultElevation;
  99795. private _elevationReturnTime;
  99796. private _elevationReturnWaitTime;
  99797. private _zoomStopsAnimation;
  99798. private _framingTime;
  99799. /**
  99800. * The easing function used by animations
  99801. */
  99802. static EasingFunction: ExponentialEase;
  99803. /**
  99804. * The easing mode used by animations
  99805. */
  99806. static EasingMode: number;
  99807. /**
  99808. * Sets the current mode used by the behavior
  99809. */
  99810. /**
  99811. * Gets current mode used by the behavior.
  99812. */
  99813. mode: number;
  99814. /**
  99815. * Sets the scale applied to the radius (1 by default)
  99816. */
  99817. /**
  99818. * Gets the scale applied to the radius
  99819. */
  99820. radiusScale: number;
  99821. /**
  99822. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99823. */
  99824. /**
  99825. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99826. */
  99827. positionScale: number;
  99828. /**
  99829. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99830. * behaviour is triggered, in radians.
  99831. */
  99832. /**
  99833. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99834. * behaviour is triggered, in radians.
  99835. */
  99836. defaultElevation: number;
  99837. /**
  99838. * Sets the time (in milliseconds) taken to return to the default beta position.
  99839. * Negative value indicates camera should not return to default.
  99840. */
  99841. /**
  99842. * Gets the time (in milliseconds) taken to return to the default beta position.
  99843. * Negative value indicates camera should not return to default.
  99844. */
  99845. elevationReturnTime: number;
  99846. /**
  99847. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99848. */
  99849. /**
  99850. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99851. */
  99852. elevationReturnWaitTime: number;
  99853. /**
  99854. * Sets the flag that indicates if user zooming should stop animation.
  99855. */
  99856. /**
  99857. * Gets the flag that indicates if user zooming should stop animation.
  99858. */
  99859. zoomStopsAnimation: boolean;
  99860. /**
  99861. * Sets the transition time when framing the mesh, in milliseconds
  99862. */
  99863. /**
  99864. * Gets the transition time when framing the mesh, in milliseconds
  99865. */
  99866. framingTime: number;
  99867. /**
  99868. * Define if the behavior should automatically change the configured
  99869. * camera limits and sensibilities.
  99870. */
  99871. autoCorrectCameraLimitsAndSensibility: boolean;
  99872. private _onPrePointerObservableObserver;
  99873. private _onAfterCheckInputsObserver;
  99874. private _onMeshTargetChangedObserver;
  99875. private _attachedCamera;
  99876. private _isPointerDown;
  99877. private _lastInteractionTime;
  99878. /**
  99879. * Initializes the behavior.
  99880. */
  99881. init(): void;
  99882. /**
  99883. * Attaches the behavior to its arc rotate camera.
  99884. * @param camera Defines the camera to attach the behavior to
  99885. */
  99886. attach(camera: ArcRotateCamera): void;
  99887. /**
  99888. * Detaches the behavior from its current arc rotate camera.
  99889. */
  99890. detach(): void;
  99891. private _animatables;
  99892. private _betaIsAnimating;
  99893. private _betaTransition;
  99894. private _radiusTransition;
  99895. private _vectorTransition;
  99896. /**
  99897. * Targets the given mesh and updates zoom level accordingly.
  99898. * @param mesh The mesh to target.
  99899. * @param radius Optional. If a cached radius position already exists, overrides default.
  99900. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99901. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99902. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99903. */
  99904. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99905. /**
  99906. * Targets the given mesh with its children and updates zoom level accordingly.
  99907. * @param mesh The mesh to target.
  99908. * @param radius Optional. If a cached radius position already exists, overrides default.
  99909. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99910. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99911. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99912. */
  99913. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99914. /**
  99915. * Targets the given meshes with their children and updates zoom level accordingly.
  99916. * @param meshes The mesh to target.
  99917. * @param radius Optional. If a cached radius position already exists, overrides default.
  99918. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99919. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99920. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99921. */
  99922. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99923. /**
  99924. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  99925. * @param minimumWorld Determines the smaller position of the bounding box extend
  99926. * @param maximumWorld Determines the bigger position of the bounding box extend
  99927. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99928. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99929. */
  99930. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99931. /**
  99932. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  99933. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  99934. * frustum width.
  99935. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  99936. * to fully enclose the mesh in the viewing frustum.
  99937. */
  99938. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  99939. /**
  99940. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  99941. * is automatically returned to its default position (expected to be above ground plane).
  99942. */
  99943. private _maintainCameraAboveGround;
  99944. /**
  99945. * Returns the frustum slope based on the canvas ratio and camera FOV
  99946. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  99947. */
  99948. private _getFrustumSlope;
  99949. /**
  99950. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  99951. */
  99952. private _clearAnimationLocks;
  99953. /**
  99954. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99955. */
  99956. private _applyUserInteraction;
  99957. /**
  99958. * Stops and removes all animations that have been applied to the camera
  99959. */
  99960. stopAllAnimations(): void;
  99961. /**
  99962. * Gets a value indicating if the user is moving the camera
  99963. */
  99964. readonly isUserIsMoving: boolean;
  99965. /**
  99966. * The camera can move all the way towards the mesh.
  99967. */
  99968. static IgnoreBoundsSizeMode: number;
  99969. /**
  99970. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  99971. */
  99972. static FitFrustumSidesMode: number;
  99973. }
  99974. }
  99975. declare module BABYLON {
  99976. /**
  99977. * Base class for Camera Pointer Inputs.
  99978. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  99979. * for example usage.
  99980. */
  99981. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  99982. /**
  99983. * Defines the camera the input is attached to.
  99984. */
  99985. abstract camera: Camera;
  99986. /**
  99987. * Whether keyboard modifier keys are pressed at time of last mouse event.
  99988. */
  99989. protected _altKey: boolean;
  99990. protected _ctrlKey: boolean;
  99991. protected _metaKey: boolean;
  99992. protected _shiftKey: boolean;
  99993. /**
  99994. * Which mouse buttons were pressed at time of last mouse event.
  99995. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  99996. */
  99997. protected _buttonsPressed: number;
  99998. /**
  99999. * Defines the buttons associated with the input to handle camera move.
  100000. */
  100001. buttons: number[];
  100002. /**
  100003. * Attach the input controls to a specific dom element to get the input from.
  100004. * @param element Defines the element the controls should be listened from
  100005. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100006. */
  100007. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100008. /**
  100009. * Detach the current controls from the specified dom element.
  100010. * @param element Defines the element to stop listening the inputs from
  100011. */
  100012. detachControl(element: Nullable<HTMLElement>): void;
  100013. /**
  100014. * Gets the class name of the current input.
  100015. * @returns the class name
  100016. */
  100017. getClassName(): string;
  100018. /**
  100019. * Get the friendly name associated with the input class.
  100020. * @returns the input friendly name
  100021. */
  100022. getSimpleName(): string;
  100023. /**
  100024. * Called on pointer POINTERDOUBLETAP event.
  100025. * Override this method to provide functionality on POINTERDOUBLETAP event.
  100026. */
  100027. protected onDoubleTap(type: string): void;
  100028. /**
  100029. * Called on pointer POINTERMOVE event if only a single touch is active.
  100030. * Override this method to provide functionality.
  100031. */
  100032. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100033. /**
  100034. * Called on pointer POINTERMOVE event if multiple touches are active.
  100035. * Override this method to provide functionality.
  100036. */
  100037. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100038. /**
  100039. * Called on JS contextmenu event.
  100040. * Override this method to provide functionality.
  100041. */
  100042. protected onContextMenu(evt: PointerEvent): void;
  100043. /**
  100044. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100045. * press.
  100046. * Override this method to provide functionality.
  100047. */
  100048. protected onButtonDown(evt: PointerEvent): void;
  100049. /**
  100050. * Called each time a new POINTERUP event occurs. Ie, for each button
  100051. * release.
  100052. * Override this method to provide functionality.
  100053. */
  100054. protected onButtonUp(evt: PointerEvent): void;
  100055. /**
  100056. * Called when window becomes inactive.
  100057. * Override this method to provide functionality.
  100058. */
  100059. protected onLostFocus(): void;
  100060. private _pointerInput;
  100061. private _observer;
  100062. private _onLostFocus;
  100063. private pointA;
  100064. private pointB;
  100065. }
  100066. }
  100067. declare module BABYLON {
  100068. /**
  100069. * Manage the pointers inputs to control an arc rotate camera.
  100070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100071. */
  100072. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  100073. /**
  100074. * Defines the camera the input is attached to.
  100075. */
  100076. camera: ArcRotateCamera;
  100077. /**
  100078. * Gets the class name of the current input.
  100079. * @returns the class name
  100080. */
  100081. getClassName(): string;
  100082. /**
  100083. * Defines the buttons associated with the input to handle camera move.
  100084. */
  100085. buttons: number[];
  100086. /**
  100087. * Defines the pointer angular sensibility along the X axis or how fast is
  100088. * the camera rotating.
  100089. */
  100090. angularSensibilityX: number;
  100091. /**
  100092. * Defines the pointer angular sensibility along the Y axis or how fast is
  100093. * the camera rotating.
  100094. */
  100095. angularSensibilityY: number;
  100096. /**
  100097. * Defines the pointer pinch precision or how fast is the camera zooming.
  100098. */
  100099. pinchPrecision: number;
  100100. /**
  100101. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100102. * from 0.
  100103. * It defines the percentage of current camera.radius to use as delta when
  100104. * pinch zoom is used.
  100105. */
  100106. pinchDeltaPercentage: number;
  100107. /**
  100108. * Defines the pointer panning sensibility or how fast is the camera moving.
  100109. */
  100110. panningSensibility: number;
  100111. /**
  100112. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  100113. */
  100114. multiTouchPanning: boolean;
  100115. /**
  100116. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  100117. * zoom (pinch) through multitouch.
  100118. */
  100119. multiTouchPanAndZoom: boolean;
  100120. /**
  100121. * Revers pinch action direction.
  100122. */
  100123. pinchInwards: boolean;
  100124. private _isPanClick;
  100125. private _twoFingerActivityCount;
  100126. private _isPinching;
  100127. /**
  100128. * Called on pointer POINTERMOVE event if only a single touch is active.
  100129. */
  100130. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100131. /**
  100132. * Called on pointer POINTERDOUBLETAP event.
  100133. */
  100134. protected onDoubleTap(type: string): void;
  100135. /**
  100136. * Called on pointer POINTERMOVE event if multiple touches are active.
  100137. */
  100138. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100139. /**
  100140. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100141. * press.
  100142. */
  100143. protected onButtonDown(evt: PointerEvent): void;
  100144. /**
  100145. * Called each time a new POINTERUP event occurs. Ie, for each button
  100146. * release.
  100147. */
  100148. protected onButtonUp(evt: PointerEvent): void;
  100149. /**
  100150. * Called when window becomes inactive.
  100151. */
  100152. protected onLostFocus(): void;
  100153. }
  100154. }
  100155. declare module BABYLON {
  100156. /**
  100157. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  100158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100159. */
  100160. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  100161. /**
  100162. * Defines the camera the input is attached to.
  100163. */
  100164. camera: ArcRotateCamera;
  100165. /**
  100166. * Defines the list of key codes associated with the up action (increase alpha)
  100167. */
  100168. keysUp: number[];
  100169. /**
  100170. * Defines the list of key codes associated with the down action (decrease alpha)
  100171. */
  100172. keysDown: number[];
  100173. /**
  100174. * Defines the list of key codes associated with the left action (increase beta)
  100175. */
  100176. keysLeft: number[];
  100177. /**
  100178. * Defines the list of key codes associated with the right action (decrease beta)
  100179. */
  100180. keysRight: number[];
  100181. /**
  100182. * Defines the list of key codes associated with the reset action.
  100183. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  100184. */
  100185. keysReset: number[];
  100186. /**
  100187. * Defines the panning sensibility of the inputs.
  100188. * (How fast is the camera paning)
  100189. */
  100190. panningSensibility: number;
  100191. /**
  100192. * Defines the zooming sensibility of the inputs.
  100193. * (How fast is the camera zooming)
  100194. */
  100195. zoomingSensibility: number;
  100196. /**
  100197. * Defines wether maintaining the alt key down switch the movement mode from
  100198. * orientation to zoom.
  100199. */
  100200. useAltToZoom: boolean;
  100201. /**
  100202. * Rotation speed of the camera
  100203. */
  100204. angularSpeed: number;
  100205. private _keys;
  100206. private _ctrlPressed;
  100207. private _altPressed;
  100208. private _onCanvasBlurObserver;
  100209. private _onKeyboardObserver;
  100210. private _engine;
  100211. private _scene;
  100212. /**
  100213. * Attach the input controls to a specific dom element to get the input from.
  100214. * @param element Defines the element the controls should be listened from
  100215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100216. */
  100217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100218. /**
  100219. * Detach the current controls from the specified dom element.
  100220. * @param element Defines the element to stop listening the inputs from
  100221. */
  100222. detachControl(element: Nullable<HTMLElement>): void;
  100223. /**
  100224. * Update the current camera state depending on the inputs that have been used this frame.
  100225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100226. */
  100227. checkInputs(): void;
  100228. /**
  100229. * Gets the class name of the current intput.
  100230. * @returns the class name
  100231. */
  100232. getClassName(): string;
  100233. /**
  100234. * Get the friendly name associated with the input class.
  100235. * @returns the input friendly name
  100236. */
  100237. getSimpleName(): string;
  100238. }
  100239. }
  100240. declare module BABYLON {
  100241. /**
  100242. * Manage the mouse wheel inputs to control an arc rotate camera.
  100243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100244. */
  100245. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  100246. /**
  100247. * Defines the camera the input is attached to.
  100248. */
  100249. camera: ArcRotateCamera;
  100250. /**
  100251. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100252. */
  100253. wheelPrecision: number;
  100254. /**
  100255. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100256. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100257. */
  100258. wheelDeltaPercentage: number;
  100259. private _wheel;
  100260. private _observer;
  100261. private computeDeltaFromMouseWheelLegacyEvent;
  100262. /**
  100263. * Attach the input controls to a specific dom element to get the input from.
  100264. * @param element Defines the element the controls should be listened from
  100265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100266. */
  100267. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100268. /**
  100269. * Detach the current controls from the specified dom element.
  100270. * @param element Defines the element to stop listening the inputs from
  100271. */
  100272. detachControl(element: Nullable<HTMLElement>): void;
  100273. /**
  100274. * Gets the class name of the current intput.
  100275. * @returns the class name
  100276. */
  100277. getClassName(): string;
  100278. /**
  100279. * Get the friendly name associated with the input class.
  100280. * @returns the input friendly name
  100281. */
  100282. getSimpleName(): string;
  100283. }
  100284. }
  100285. declare module BABYLON {
  100286. /**
  100287. * Default Inputs manager for the ArcRotateCamera.
  100288. * It groups all the default supported inputs for ease of use.
  100289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100290. */
  100291. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  100292. /**
  100293. * Instantiates a new ArcRotateCameraInputsManager.
  100294. * @param camera Defines the camera the inputs belong to
  100295. */
  100296. constructor(camera: ArcRotateCamera);
  100297. /**
  100298. * Add mouse wheel input support to the input manager.
  100299. * @returns the current input manager
  100300. */
  100301. addMouseWheel(): ArcRotateCameraInputsManager;
  100302. /**
  100303. * Add pointers input support to the input manager.
  100304. * @returns the current input manager
  100305. */
  100306. addPointers(): ArcRotateCameraInputsManager;
  100307. /**
  100308. * Add keyboard input support to the input manager.
  100309. * @returns the current input manager
  100310. */
  100311. addKeyboard(): ArcRotateCameraInputsManager;
  100312. }
  100313. }
  100314. declare module BABYLON {
  100315. /**
  100316. * This represents an orbital type of camera.
  100317. *
  100318. * 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.
  100319. * 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.
  100320. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  100321. */
  100322. export class ArcRotateCamera extends TargetCamera {
  100323. /**
  100324. * Defines the rotation angle of the camera along the longitudinal axis.
  100325. */
  100326. alpha: number;
  100327. /**
  100328. * Defines the rotation angle of the camera along the latitudinal axis.
  100329. */
  100330. beta: number;
  100331. /**
  100332. * Defines the radius of the camera from it s target point.
  100333. */
  100334. radius: number;
  100335. protected _target: Vector3;
  100336. protected _targetHost: Nullable<AbstractMesh>;
  100337. /**
  100338. * Defines the target point of the camera.
  100339. * The camera looks towards it form the radius distance.
  100340. */
  100341. target: Vector3;
  100342. /**
  100343. * Define the current local position of the camera in the scene
  100344. */
  100345. position: Vector3;
  100346. protected _upVector: Vector3;
  100347. protected _upToYMatrix: Matrix;
  100348. protected _YToUpMatrix: Matrix;
  100349. /**
  100350. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  100351. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  100352. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  100353. */
  100354. upVector: Vector3;
  100355. /**
  100356. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  100357. */
  100358. setMatUp(): void;
  100359. /**
  100360. * Current inertia value on the longitudinal axis.
  100361. * The bigger this number the longer it will take for the camera to stop.
  100362. */
  100363. inertialAlphaOffset: number;
  100364. /**
  100365. * Current inertia value on the latitudinal axis.
  100366. * The bigger this number the longer it will take for the camera to stop.
  100367. */
  100368. inertialBetaOffset: number;
  100369. /**
  100370. * Current inertia value on the radius axis.
  100371. * The bigger this number the longer it will take for the camera to stop.
  100372. */
  100373. inertialRadiusOffset: number;
  100374. /**
  100375. * Minimum allowed angle on the longitudinal axis.
  100376. * This can help limiting how the Camera is able to move in the scene.
  100377. */
  100378. lowerAlphaLimit: Nullable<number>;
  100379. /**
  100380. * Maximum allowed angle on the longitudinal axis.
  100381. * This can help limiting how the Camera is able to move in the scene.
  100382. */
  100383. upperAlphaLimit: Nullable<number>;
  100384. /**
  100385. * Minimum allowed angle on the latitudinal axis.
  100386. * This can help limiting how the Camera is able to move in the scene.
  100387. */
  100388. lowerBetaLimit: number;
  100389. /**
  100390. * Maximum allowed angle on the latitudinal axis.
  100391. * This can help limiting how the Camera is able to move in the scene.
  100392. */
  100393. upperBetaLimit: number;
  100394. /**
  100395. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  100396. * This can help limiting how the Camera is able to move in the scene.
  100397. */
  100398. lowerRadiusLimit: Nullable<number>;
  100399. /**
  100400. * Maximum allowed distance of the camera to the target (The camera can not get further).
  100401. * This can help limiting how the Camera is able to move in the scene.
  100402. */
  100403. upperRadiusLimit: Nullable<number>;
  100404. /**
  100405. * Defines the current inertia value used during panning of the camera along the X axis.
  100406. */
  100407. inertialPanningX: number;
  100408. /**
  100409. * Defines the current inertia value used during panning of the camera along the Y axis.
  100410. */
  100411. inertialPanningY: number;
  100412. /**
  100413. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  100414. * Basically if your fingers moves away from more than this distance you will be considered
  100415. * in pinch mode.
  100416. */
  100417. pinchToPanMaxDistance: number;
  100418. /**
  100419. * Defines the maximum distance the camera can pan.
  100420. * This could help keeping the cammera always in your scene.
  100421. */
  100422. panningDistanceLimit: Nullable<number>;
  100423. /**
  100424. * Defines the target of the camera before paning.
  100425. */
  100426. panningOriginTarget: Vector3;
  100427. /**
  100428. * Defines the value of the inertia used during panning.
  100429. * 0 would mean stop inertia and one would mean no decelleration at all.
  100430. */
  100431. panningInertia: number;
  100432. /**
  100433. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  100434. */
  100435. angularSensibilityX: number;
  100436. /**
  100437. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  100438. */
  100439. angularSensibilityY: number;
  100440. /**
  100441. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  100442. */
  100443. pinchPrecision: number;
  100444. /**
  100445. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  100446. * It will be used instead of pinchDeltaPrecision if different from 0.
  100447. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100448. */
  100449. pinchDeltaPercentage: number;
  100450. /**
  100451. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  100452. */
  100453. panningSensibility: number;
  100454. /**
  100455. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  100456. */
  100457. keysUp: number[];
  100458. /**
  100459. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  100460. */
  100461. keysDown: number[];
  100462. /**
  100463. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  100464. */
  100465. keysLeft: number[];
  100466. /**
  100467. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  100468. */
  100469. keysRight: number[];
  100470. /**
  100471. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100472. */
  100473. wheelPrecision: number;
  100474. /**
  100475. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  100476. * It will be used instead of pinchDeltaPrecision if different from 0.
  100477. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100478. */
  100479. wheelDeltaPercentage: number;
  100480. /**
  100481. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  100482. */
  100483. zoomOnFactor: number;
  100484. /**
  100485. * Defines a screen offset for the camera position.
  100486. */
  100487. targetScreenOffset: Vector2;
  100488. /**
  100489. * Allows the camera to be completely reversed.
  100490. * If false the camera can not arrive upside down.
  100491. */
  100492. allowUpsideDown: boolean;
  100493. /**
  100494. * Define if double tap/click is used to restore the previously saved state of the camera.
  100495. */
  100496. useInputToRestoreState: boolean;
  100497. /** @hidden */
  100498. _viewMatrix: Matrix;
  100499. /** @hidden */
  100500. _useCtrlForPanning: boolean;
  100501. /** @hidden */
  100502. _panningMouseButton: number;
  100503. /**
  100504. * Defines the input associated to the camera.
  100505. */
  100506. inputs: ArcRotateCameraInputsManager;
  100507. /** @hidden */
  100508. _reset: () => void;
  100509. /**
  100510. * Defines the allowed panning axis.
  100511. */
  100512. panningAxis: Vector3;
  100513. protected _localDirection: Vector3;
  100514. protected _transformedDirection: Vector3;
  100515. private _bouncingBehavior;
  100516. /**
  100517. * Gets the bouncing behavior of the camera if it has been enabled.
  100518. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100519. */
  100520. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  100521. /**
  100522. * Defines if the bouncing behavior of the camera is enabled on the camera.
  100523. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100524. */
  100525. useBouncingBehavior: boolean;
  100526. private _framingBehavior;
  100527. /**
  100528. * Gets the framing behavior of the camera if it has been enabled.
  100529. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100530. */
  100531. readonly framingBehavior: Nullable<FramingBehavior>;
  100532. /**
  100533. * Defines if the framing behavior of the camera is enabled on the camera.
  100534. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100535. */
  100536. useFramingBehavior: boolean;
  100537. private _autoRotationBehavior;
  100538. /**
  100539. * Gets the auto rotation behavior of the camera if it has been enabled.
  100540. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100541. */
  100542. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  100543. /**
  100544. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  100545. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100546. */
  100547. useAutoRotationBehavior: boolean;
  100548. /**
  100549. * Observable triggered when the mesh target has been changed on the camera.
  100550. */
  100551. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  100552. /**
  100553. * Event raised when the camera is colliding with a mesh.
  100554. */
  100555. onCollide: (collidedMesh: AbstractMesh) => void;
  100556. /**
  100557. * Defines whether the camera should check collision with the objects oh the scene.
  100558. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  100559. */
  100560. checkCollisions: boolean;
  100561. /**
  100562. * Defines the collision radius of the camera.
  100563. * This simulates a sphere around the camera.
  100564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100565. */
  100566. collisionRadius: Vector3;
  100567. protected _collider: Collider;
  100568. protected _previousPosition: Vector3;
  100569. protected _collisionVelocity: Vector3;
  100570. protected _newPosition: Vector3;
  100571. protected _previousAlpha: number;
  100572. protected _previousBeta: number;
  100573. protected _previousRadius: number;
  100574. protected _collisionTriggered: boolean;
  100575. protected _targetBoundingCenter: Nullable<Vector3>;
  100576. private _computationVector;
  100577. /**
  100578. * Instantiates a new ArcRotateCamera in a given scene
  100579. * @param name Defines the name of the camera
  100580. * @param alpha Defines the camera rotation along the logitudinal axis
  100581. * @param beta Defines the camera rotation along the latitudinal axis
  100582. * @param radius Defines the camera distance from its target
  100583. * @param target Defines the camera target
  100584. * @param scene Defines the scene the camera belongs to
  100585. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100586. */
  100587. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100588. /** @hidden */
  100589. _initCache(): void;
  100590. /** @hidden */
  100591. _updateCache(ignoreParentClass?: boolean): void;
  100592. protected _getTargetPosition(): Vector3;
  100593. private _storedAlpha;
  100594. private _storedBeta;
  100595. private _storedRadius;
  100596. private _storedTarget;
  100597. /**
  100598. * Stores the current state of the camera (alpha, beta, radius and target)
  100599. * @returns the camera itself
  100600. */
  100601. storeState(): Camera;
  100602. /**
  100603. * @hidden
  100604. * Restored camera state. You must call storeState() first
  100605. */
  100606. _restoreStateValues(): boolean;
  100607. /** @hidden */
  100608. _isSynchronizedViewMatrix(): boolean;
  100609. /**
  100610. * Attached controls to the current camera.
  100611. * @param element Defines the element the controls should be listened from
  100612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100613. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  100614. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  100615. */
  100616. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  100617. /**
  100618. * Detach the current controls from the camera.
  100619. * The camera will stop reacting to inputs.
  100620. * @param element Defines the element to stop listening the inputs from
  100621. */
  100622. detachControl(element: HTMLElement): void;
  100623. /** @hidden */
  100624. _checkInputs(): void;
  100625. protected _checkLimits(): void;
  100626. /**
  100627. * Rebuilds angles (alpha, beta) and radius from the give position and target
  100628. */
  100629. rebuildAnglesAndRadius(): void;
  100630. /**
  100631. * Use a position to define the current camera related information like aplha, beta and radius
  100632. * @param position Defines the position to set the camera at
  100633. */
  100634. setPosition(position: Vector3): void;
  100635. /**
  100636. * Defines the target the camera should look at.
  100637. * This will automatically adapt alpha beta and radius to fit within the new target.
  100638. * @param target Defines the new target as a Vector or a mesh
  100639. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  100640. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  100641. */
  100642. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  100643. /** @hidden */
  100644. _getViewMatrix(): Matrix;
  100645. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  100646. /**
  100647. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  100648. * @param meshes Defines the mesh to zoom on
  100649. * @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)
  100650. */
  100651. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  100652. /**
  100653. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  100654. * The target will be changed but the radius
  100655. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  100656. * @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)
  100657. */
  100658. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  100659. min: Vector3;
  100660. max: Vector3;
  100661. distance: number;
  100662. }, doNotUpdateMaxZ?: boolean): void;
  100663. /**
  100664. * @override
  100665. * Override Camera.createRigCamera
  100666. */
  100667. createRigCamera(name: string, cameraIndex: number): Camera;
  100668. /**
  100669. * @hidden
  100670. * @override
  100671. * Override Camera._updateRigCameras
  100672. */
  100673. _updateRigCameras(): void;
  100674. /**
  100675. * Destroy the camera and release the current resources hold by it.
  100676. */
  100677. dispose(): void;
  100678. /**
  100679. * Gets the current object class name.
  100680. * @return the class name
  100681. */
  100682. getClassName(): string;
  100683. }
  100684. }
  100685. declare module BABYLON {
  100686. /**
  100687. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  100688. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100689. */
  100690. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  100691. /**
  100692. * Gets the name of the behavior.
  100693. */
  100694. readonly name: string;
  100695. private _zoomStopsAnimation;
  100696. private _idleRotationSpeed;
  100697. private _idleRotationWaitTime;
  100698. private _idleRotationSpinupTime;
  100699. /**
  100700. * Sets the flag that indicates if user zooming should stop animation.
  100701. */
  100702. /**
  100703. * Gets the flag that indicates if user zooming should stop animation.
  100704. */
  100705. zoomStopsAnimation: boolean;
  100706. /**
  100707. * Sets the default speed at which the camera rotates around the model.
  100708. */
  100709. /**
  100710. * Gets the default speed at which the camera rotates around the model.
  100711. */
  100712. idleRotationSpeed: number;
  100713. /**
  100714. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  100715. */
  100716. /**
  100717. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  100718. */
  100719. idleRotationWaitTime: number;
  100720. /**
  100721. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100722. */
  100723. /**
  100724. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100725. */
  100726. idleRotationSpinupTime: number;
  100727. /**
  100728. * Gets a value indicating if the camera is currently rotating because of this behavior
  100729. */
  100730. readonly rotationInProgress: boolean;
  100731. private _onPrePointerObservableObserver;
  100732. private _onAfterCheckInputsObserver;
  100733. private _attachedCamera;
  100734. private _isPointerDown;
  100735. private _lastFrameTime;
  100736. private _lastInteractionTime;
  100737. private _cameraRotationSpeed;
  100738. /**
  100739. * Initializes the behavior.
  100740. */
  100741. init(): void;
  100742. /**
  100743. * Attaches the behavior to its arc rotate camera.
  100744. * @param camera Defines the camera to attach the behavior to
  100745. */
  100746. attach(camera: ArcRotateCamera): void;
  100747. /**
  100748. * Detaches the behavior from its current arc rotate camera.
  100749. */
  100750. detach(): void;
  100751. /**
  100752. * Returns true if user is scrolling.
  100753. * @return true if user is scrolling.
  100754. */
  100755. private _userIsZooming;
  100756. private _lastFrameRadius;
  100757. private _shouldAnimationStopForInteraction;
  100758. /**
  100759. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100760. */
  100761. private _applyUserInteraction;
  100762. private _userIsMoving;
  100763. }
  100764. }
  100765. declare module BABYLON {
  100766. /**
  100767. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  100768. */
  100769. export class AttachToBoxBehavior implements Behavior<Mesh> {
  100770. private ui;
  100771. /**
  100772. * The name of the behavior
  100773. */
  100774. name: string;
  100775. /**
  100776. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  100777. */
  100778. distanceAwayFromFace: number;
  100779. /**
  100780. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  100781. */
  100782. distanceAwayFromBottomOfFace: number;
  100783. private _faceVectors;
  100784. private _target;
  100785. private _scene;
  100786. private _onRenderObserver;
  100787. private _tmpMatrix;
  100788. private _tmpVector;
  100789. /**
  100790. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  100791. * @param ui The transform node that should be attched to the mesh
  100792. */
  100793. constructor(ui: TransformNode);
  100794. /**
  100795. * Initializes the behavior
  100796. */
  100797. init(): void;
  100798. private _closestFace;
  100799. private _zeroVector;
  100800. private _lookAtTmpMatrix;
  100801. private _lookAtToRef;
  100802. /**
  100803. * Attaches the AttachToBoxBehavior to the passed in mesh
  100804. * @param target The mesh that the specified node will be attached to
  100805. */
  100806. attach(target: Mesh): void;
  100807. /**
  100808. * Detaches the behavior from the mesh
  100809. */
  100810. detach(): void;
  100811. }
  100812. }
  100813. declare module BABYLON {
  100814. /**
  100815. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  100816. */
  100817. export class FadeInOutBehavior implements Behavior<Mesh> {
  100818. /**
  100819. * Time in milliseconds to delay before fading in (Default: 0)
  100820. */
  100821. delay: number;
  100822. /**
  100823. * Time in milliseconds for the mesh to fade in (Default: 300)
  100824. */
  100825. fadeInTime: number;
  100826. private _millisecondsPerFrame;
  100827. private _hovered;
  100828. private _hoverValue;
  100829. private _ownerNode;
  100830. /**
  100831. * Instatiates the FadeInOutBehavior
  100832. */
  100833. constructor();
  100834. /**
  100835. * The name of the behavior
  100836. */
  100837. readonly name: string;
  100838. /**
  100839. * Initializes the behavior
  100840. */
  100841. init(): void;
  100842. /**
  100843. * Attaches the fade behavior on the passed in mesh
  100844. * @param ownerNode The mesh that will be faded in/out once attached
  100845. */
  100846. attach(ownerNode: Mesh): void;
  100847. /**
  100848. * Detaches the behavior from the mesh
  100849. */
  100850. detach(): void;
  100851. /**
  100852. * Triggers the mesh to begin fading in or out
  100853. * @param value if the object should fade in or out (true to fade in)
  100854. */
  100855. fadeIn(value: boolean): void;
  100856. private _update;
  100857. private _setAllVisibility;
  100858. }
  100859. }
  100860. declare module BABYLON {
  100861. /**
  100862. * Class containing a set of static utilities functions for managing Pivots
  100863. * @hidden
  100864. */
  100865. export class PivotTools {
  100866. private static _PivotCached;
  100867. private static _OldPivotPoint;
  100868. private static _PivotTranslation;
  100869. private static _PivotTmpVector;
  100870. /** @hidden */
  100871. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  100872. /** @hidden */
  100873. static _RestorePivotPoint(mesh: AbstractMesh): void;
  100874. }
  100875. }
  100876. declare module BABYLON {
  100877. /**
  100878. * Class containing static functions to help procedurally build meshes
  100879. */
  100880. export class PlaneBuilder {
  100881. /**
  100882. * Creates a plane mesh
  100883. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  100884. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  100885. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  100886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100889. * @param name defines the name of the mesh
  100890. * @param options defines the options used to create the mesh
  100891. * @param scene defines the hosting scene
  100892. * @returns the plane mesh
  100893. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  100894. */
  100895. static CreatePlane(name: string, options: {
  100896. size?: number;
  100897. width?: number;
  100898. height?: number;
  100899. sideOrientation?: number;
  100900. frontUVs?: Vector4;
  100901. backUVs?: Vector4;
  100902. updatable?: boolean;
  100903. sourcePlane?: Plane;
  100904. }, scene?: Nullable<Scene>): Mesh;
  100905. }
  100906. }
  100907. declare module BABYLON {
  100908. /**
  100909. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  100910. */
  100911. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  100912. private static _AnyMouseID;
  100913. /**
  100914. * Abstract mesh the behavior is set on
  100915. */
  100916. attachedNode: AbstractMesh;
  100917. private _dragPlane;
  100918. private _scene;
  100919. private _pointerObserver;
  100920. private _beforeRenderObserver;
  100921. private static _planeScene;
  100922. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  100923. /**
  100924. * 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)
  100925. */
  100926. maxDragAngle: number;
  100927. /**
  100928. * @hidden
  100929. */
  100930. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  100931. /**
  100932. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100933. */
  100934. currentDraggingPointerID: number;
  100935. /**
  100936. * The last position where the pointer hit the drag plane in world space
  100937. */
  100938. lastDragPosition: Vector3;
  100939. /**
  100940. * If the behavior is currently in a dragging state
  100941. */
  100942. dragging: boolean;
  100943. /**
  100944. * 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)
  100945. */
  100946. dragDeltaRatio: number;
  100947. /**
  100948. * If the drag plane orientation should be updated during the dragging (Default: true)
  100949. */
  100950. updateDragPlane: boolean;
  100951. private _debugMode;
  100952. private _moving;
  100953. /**
  100954. * Fires each time the attached mesh is dragged with the pointer
  100955. * * delta between last drag position and current drag position in world space
  100956. * * dragDistance along the drag axis
  100957. * * dragPlaneNormal normal of the current drag plane used during the drag
  100958. * * dragPlanePoint in world space where the drag intersects the drag plane
  100959. */
  100960. onDragObservable: Observable<{
  100961. delta: Vector3;
  100962. dragPlanePoint: Vector3;
  100963. dragPlaneNormal: Vector3;
  100964. dragDistance: number;
  100965. pointerId: number;
  100966. }>;
  100967. /**
  100968. * Fires each time a drag begins (eg. mouse down on mesh)
  100969. */
  100970. onDragStartObservable: Observable<{
  100971. dragPlanePoint: Vector3;
  100972. pointerId: number;
  100973. }>;
  100974. /**
  100975. * Fires each time a drag ends (eg. mouse release after drag)
  100976. */
  100977. onDragEndObservable: Observable<{
  100978. dragPlanePoint: Vector3;
  100979. pointerId: number;
  100980. }>;
  100981. /**
  100982. * If the attached mesh should be moved when dragged
  100983. */
  100984. moveAttached: boolean;
  100985. /**
  100986. * If the drag behavior will react to drag events (Default: true)
  100987. */
  100988. enabled: boolean;
  100989. /**
  100990. * If pointer events should start and release the drag (Default: true)
  100991. */
  100992. startAndReleaseDragOnPointerEvents: boolean;
  100993. /**
  100994. * If camera controls should be detached during the drag
  100995. */
  100996. detachCameraControls: boolean;
  100997. /**
  100998. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  100999. */
  101000. useObjectOrienationForDragging: boolean;
  101001. private _options;
  101002. /**
  101003. * Creates a pointer drag behavior that can be attached to a mesh
  101004. * @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)
  101005. */
  101006. constructor(options?: {
  101007. dragAxis?: Vector3;
  101008. dragPlaneNormal?: Vector3;
  101009. });
  101010. /**
  101011. * Predicate to determine if it is valid to move the object to a new position when it is moved
  101012. */
  101013. validateDrag: (targetPosition: Vector3) => boolean;
  101014. /**
  101015. * The name of the behavior
  101016. */
  101017. readonly name: string;
  101018. /**
  101019. * Initializes the behavior
  101020. */
  101021. init(): void;
  101022. private _tmpVector;
  101023. private _alternatePickedPoint;
  101024. private _worldDragAxis;
  101025. private _targetPosition;
  101026. private _attachedElement;
  101027. /**
  101028. * Attaches the drag behavior the passed in mesh
  101029. * @param ownerNode The mesh that will be dragged around once attached
  101030. */
  101031. attach(ownerNode: AbstractMesh): void;
  101032. /**
  101033. * Force relase the drag action by code.
  101034. */
  101035. releaseDrag(): void;
  101036. private _startDragRay;
  101037. private _lastPointerRay;
  101038. /**
  101039. * Simulates the start of a pointer drag event on the behavior
  101040. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  101041. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  101042. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  101043. */
  101044. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  101045. private _startDrag;
  101046. private _dragDelta;
  101047. private _moveDrag;
  101048. private _pickWithRayOnDragPlane;
  101049. private _pointA;
  101050. private _pointB;
  101051. private _pointC;
  101052. private _lineA;
  101053. private _lineB;
  101054. private _localAxis;
  101055. private _lookAt;
  101056. private _updateDragPlanePosition;
  101057. /**
  101058. * Detaches the behavior from the mesh
  101059. */
  101060. detach(): void;
  101061. }
  101062. }
  101063. declare module BABYLON {
  101064. /**
  101065. * A behavior that when attached to a mesh will allow the mesh to be scaled
  101066. */
  101067. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  101068. private _dragBehaviorA;
  101069. private _dragBehaviorB;
  101070. private _startDistance;
  101071. private _initialScale;
  101072. private _targetScale;
  101073. private _ownerNode;
  101074. private _sceneRenderObserver;
  101075. /**
  101076. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  101077. */
  101078. constructor();
  101079. /**
  101080. * The name of the behavior
  101081. */
  101082. readonly name: string;
  101083. /**
  101084. * Initializes the behavior
  101085. */
  101086. init(): void;
  101087. private _getCurrentDistance;
  101088. /**
  101089. * Attaches the scale behavior the passed in mesh
  101090. * @param ownerNode The mesh that will be scaled around once attached
  101091. */
  101092. attach(ownerNode: Mesh): void;
  101093. /**
  101094. * Detaches the behavior from the mesh
  101095. */
  101096. detach(): void;
  101097. }
  101098. }
  101099. declare module BABYLON {
  101100. /**
  101101. * 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
  101102. */
  101103. export class SixDofDragBehavior implements Behavior<Mesh> {
  101104. private static _virtualScene;
  101105. private _ownerNode;
  101106. private _sceneRenderObserver;
  101107. private _scene;
  101108. private _targetPosition;
  101109. private _virtualOriginMesh;
  101110. private _virtualDragMesh;
  101111. private _pointerObserver;
  101112. private _moving;
  101113. private _startingOrientation;
  101114. /**
  101115. * 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)
  101116. */
  101117. private zDragFactor;
  101118. /**
  101119. * If the object should rotate to face the drag origin
  101120. */
  101121. rotateDraggedObject: boolean;
  101122. /**
  101123. * If the behavior is currently in a dragging state
  101124. */
  101125. dragging: boolean;
  101126. /**
  101127. * 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)
  101128. */
  101129. dragDeltaRatio: number;
  101130. /**
  101131. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101132. */
  101133. currentDraggingPointerID: number;
  101134. /**
  101135. * If camera controls should be detached during the drag
  101136. */
  101137. detachCameraControls: boolean;
  101138. /**
  101139. * Fires each time a drag starts
  101140. */
  101141. onDragStartObservable: Observable<{}>;
  101142. /**
  101143. * Fires each time a drag ends (eg. mouse release after drag)
  101144. */
  101145. onDragEndObservable: Observable<{}>;
  101146. /**
  101147. * 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
  101148. */
  101149. constructor();
  101150. /**
  101151. * The name of the behavior
  101152. */
  101153. readonly name: string;
  101154. /**
  101155. * Initializes the behavior
  101156. */
  101157. init(): void;
  101158. /**
  101159. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  101160. */
  101161. private readonly _pointerCamera;
  101162. /**
  101163. * Attaches the scale behavior the passed in mesh
  101164. * @param ownerNode The mesh that will be scaled around once attached
  101165. */
  101166. attach(ownerNode: Mesh): void;
  101167. /**
  101168. * Detaches the behavior from the mesh
  101169. */
  101170. detach(): void;
  101171. }
  101172. }
  101173. declare module BABYLON {
  101174. /**
  101175. * Class used to apply inverse kinematics to bones
  101176. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  101177. */
  101178. export class BoneIKController {
  101179. private static _tmpVecs;
  101180. private static _tmpQuat;
  101181. private static _tmpMats;
  101182. /**
  101183. * Gets or sets the target mesh
  101184. */
  101185. targetMesh: AbstractMesh;
  101186. /** Gets or sets the mesh used as pole */
  101187. poleTargetMesh: AbstractMesh;
  101188. /**
  101189. * Gets or sets the bone used as pole
  101190. */
  101191. poleTargetBone: Nullable<Bone>;
  101192. /**
  101193. * Gets or sets the target position
  101194. */
  101195. targetPosition: Vector3;
  101196. /**
  101197. * Gets or sets the pole target position
  101198. */
  101199. poleTargetPosition: Vector3;
  101200. /**
  101201. * Gets or sets the pole target local offset
  101202. */
  101203. poleTargetLocalOffset: Vector3;
  101204. /**
  101205. * Gets or sets the pole angle
  101206. */
  101207. poleAngle: number;
  101208. /**
  101209. * Gets or sets the mesh associated with the controller
  101210. */
  101211. mesh: AbstractMesh;
  101212. /**
  101213. * 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)
  101214. */
  101215. slerpAmount: number;
  101216. private _bone1Quat;
  101217. private _bone1Mat;
  101218. private _bone2Ang;
  101219. private _bone1;
  101220. private _bone2;
  101221. private _bone1Length;
  101222. private _bone2Length;
  101223. private _maxAngle;
  101224. private _maxReach;
  101225. private _rightHandedSystem;
  101226. private _bendAxis;
  101227. private _slerping;
  101228. private _adjustRoll;
  101229. /**
  101230. * Gets or sets maximum allowed angle
  101231. */
  101232. maxAngle: number;
  101233. /**
  101234. * Creates a new BoneIKController
  101235. * @param mesh defines the mesh to control
  101236. * @param bone defines the bone to control
  101237. * @param options defines options to set up the controller
  101238. */
  101239. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  101240. targetMesh?: AbstractMesh;
  101241. poleTargetMesh?: AbstractMesh;
  101242. poleTargetBone?: Bone;
  101243. poleTargetLocalOffset?: Vector3;
  101244. poleAngle?: number;
  101245. bendAxis?: Vector3;
  101246. maxAngle?: number;
  101247. slerpAmount?: number;
  101248. });
  101249. private _setMaxAngle;
  101250. /**
  101251. * Force the controller to update the bones
  101252. */
  101253. update(): void;
  101254. }
  101255. }
  101256. declare module BABYLON {
  101257. /**
  101258. * Class used to make a bone look toward a point in space
  101259. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  101260. */
  101261. export class BoneLookController {
  101262. private static _tmpVecs;
  101263. private static _tmpQuat;
  101264. private static _tmpMats;
  101265. /**
  101266. * The target Vector3 that the bone will look at
  101267. */
  101268. target: Vector3;
  101269. /**
  101270. * The mesh that the bone is attached to
  101271. */
  101272. mesh: AbstractMesh;
  101273. /**
  101274. * The bone that will be looking to the target
  101275. */
  101276. bone: Bone;
  101277. /**
  101278. * The up axis of the coordinate system that is used when the bone is rotated
  101279. */
  101280. upAxis: Vector3;
  101281. /**
  101282. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  101283. */
  101284. upAxisSpace: Space;
  101285. /**
  101286. * Used to make an adjustment to the yaw of the bone
  101287. */
  101288. adjustYaw: number;
  101289. /**
  101290. * Used to make an adjustment to the pitch of the bone
  101291. */
  101292. adjustPitch: number;
  101293. /**
  101294. * Used to make an adjustment to the roll of the bone
  101295. */
  101296. adjustRoll: number;
  101297. /**
  101298. * 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)
  101299. */
  101300. slerpAmount: number;
  101301. private _minYaw;
  101302. private _maxYaw;
  101303. private _minPitch;
  101304. private _maxPitch;
  101305. private _minYawSin;
  101306. private _minYawCos;
  101307. private _maxYawSin;
  101308. private _maxYawCos;
  101309. private _midYawConstraint;
  101310. private _minPitchTan;
  101311. private _maxPitchTan;
  101312. private _boneQuat;
  101313. private _slerping;
  101314. private _transformYawPitch;
  101315. private _transformYawPitchInv;
  101316. private _firstFrameSkipped;
  101317. private _yawRange;
  101318. private _fowardAxis;
  101319. /**
  101320. * Gets or sets the minimum yaw angle that the bone can look to
  101321. */
  101322. minYaw: number;
  101323. /**
  101324. * Gets or sets the maximum yaw angle that the bone can look to
  101325. */
  101326. maxYaw: number;
  101327. /**
  101328. * Gets or sets the minimum pitch angle that the bone can look to
  101329. */
  101330. minPitch: number;
  101331. /**
  101332. * Gets or sets the maximum pitch angle that the bone can look to
  101333. */
  101334. maxPitch: number;
  101335. /**
  101336. * Create a BoneLookController
  101337. * @param mesh the mesh that the bone belongs to
  101338. * @param bone the bone that will be looking to the target
  101339. * @param target the target Vector3 to look at
  101340. * @param options optional settings:
  101341. * * maxYaw: the maximum angle the bone will yaw to
  101342. * * minYaw: the minimum angle the bone will yaw to
  101343. * * maxPitch: the maximum angle the bone will pitch to
  101344. * * minPitch: the minimum angle the bone will yaw to
  101345. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  101346. * * upAxis: the up axis of the coordinate system
  101347. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  101348. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  101349. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  101350. * * adjustYaw: used to make an adjustment to the yaw of the bone
  101351. * * adjustPitch: used to make an adjustment to the pitch of the bone
  101352. * * adjustRoll: used to make an adjustment to the roll of the bone
  101353. **/
  101354. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  101355. maxYaw?: number;
  101356. minYaw?: number;
  101357. maxPitch?: number;
  101358. minPitch?: number;
  101359. slerpAmount?: number;
  101360. upAxis?: Vector3;
  101361. upAxisSpace?: Space;
  101362. yawAxis?: Vector3;
  101363. pitchAxis?: Vector3;
  101364. adjustYaw?: number;
  101365. adjustPitch?: number;
  101366. adjustRoll?: number;
  101367. });
  101368. /**
  101369. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  101370. */
  101371. update(): void;
  101372. private _getAngleDiff;
  101373. private _getAngleBetween;
  101374. private _isAngleBetween;
  101375. }
  101376. }
  101377. declare module BABYLON {
  101378. /**
  101379. * Manage the gamepad inputs to control an arc rotate camera.
  101380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101381. */
  101382. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  101383. /**
  101384. * Defines the camera the input is attached to.
  101385. */
  101386. camera: ArcRotateCamera;
  101387. /**
  101388. * Defines the gamepad the input is gathering event from.
  101389. */
  101390. gamepad: Nullable<Gamepad>;
  101391. /**
  101392. * Defines the gamepad rotation sensiblity.
  101393. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101394. */
  101395. gamepadRotationSensibility: number;
  101396. /**
  101397. * Defines the gamepad move sensiblity.
  101398. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101399. */
  101400. gamepadMoveSensibility: number;
  101401. private _onGamepadConnectedObserver;
  101402. private _onGamepadDisconnectedObserver;
  101403. /**
  101404. * Attach the input controls to a specific dom element to get the input from.
  101405. * @param element Defines the element the controls should be listened from
  101406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101407. */
  101408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101409. /**
  101410. * Detach the current controls from the specified dom element.
  101411. * @param element Defines the element to stop listening the inputs from
  101412. */
  101413. detachControl(element: Nullable<HTMLElement>): void;
  101414. /**
  101415. * Update the current camera state depending on the inputs that have been used this frame.
  101416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101417. */
  101418. checkInputs(): void;
  101419. /**
  101420. * Gets the class name of the current intput.
  101421. * @returns the class name
  101422. */
  101423. getClassName(): string;
  101424. /**
  101425. * Get the friendly name associated with the input class.
  101426. * @returns the input friendly name
  101427. */
  101428. getSimpleName(): string;
  101429. }
  101430. }
  101431. declare module BABYLON {
  101432. interface ArcRotateCameraInputsManager {
  101433. /**
  101434. * Add orientation input support to the input manager.
  101435. * @returns the current input manager
  101436. */
  101437. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  101438. }
  101439. /**
  101440. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  101441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101442. */
  101443. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  101444. /**
  101445. * Defines the camera the input is attached to.
  101446. */
  101447. camera: ArcRotateCamera;
  101448. /**
  101449. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  101450. */
  101451. alphaCorrection: number;
  101452. /**
  101453. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  101454. */
  101455. gammaCorrection: number;
  101456. private _alpha;
  101457. private _gamma;
  101458. private _dirty;
  101459. private _deviceOrientationHandler;
  101460. /**
  101461. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  101462. */
  101463. constructor();
  101464. /**
  101465. * Attach the input controls to a specific dom element to get the input from.
  101466. * @param element Defines the element the controls should be listened from
  101467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101468. */
  101469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101470. /** @hidden */
  101471. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  101472. /**
  101473. * Update the current camera state depending on the inputs that have been used this frame.
  101474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101475. */
  101476. checkInputs(): void;
  101477. /**
  101478. * Detach the current controls from the specified dom element.
  101479. * @param element Defines the element to stop listening the inputs from
  101480. */
  101481. detachControl(element: Nullable<HTMLElement>): void;
  101482. /**
  101483. * Gets the class name of the current intput.
  101484. * @returns the class name
  101485. */
  101486. getClassName(): string;
  101487. /**
  101488. * Get the friendly name associated with the input class.
  101489. * @returns the input friendly name
  101490. */
  101491. getSimpleName(): string;
  101492. }
  101493. }
  101494. declare module BABYLON {
  101495. /**
  101496. * Listen to mouse events to control the camera.
  101497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101498. */
  101499. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  101500. /**
  101501. * Defines the camera the input is attached to.
  101502. */
  101503. camera: FlyCamera;
  101504. /**
  101505. * Defines if touch is enabled. (Default is true.)
  101506. */
  101507. touchEnabled: boolean;
  101508. /**
  101509. * Defines the buttons associated with the input to handle camera rotation.
  101510. */
  101511. buttons: number[];
  101512. /**
  101513. * Assign buttons for Yaw control.
  101514. */
  101515. buttonsYaw: number[];
  101516. /**
  101517. * Assign buttons for Pitch control.
  101518. */
  101519. buttonsPitch: number[];
  101520. /**
  101521. * Assign buttons for Roll control.
  101522. */
  101523. buttonsRoll: number[];
  101524. /**
  101525. * Detect if any button is being pressed while mouse is moved.
  101526. * -1 = Mouse locked.
  101527. * 0 = Left button.
  101528. * 1 = Middle Button.
  101529. * 2 = Right Button.
  101530. */
  101531. activeButton: number;
  101532. /**
  101533. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  101534. * Higher values reduce its sensitivity.
  101535. */
  101536. angularSensibility: number;
  101537. private _mousemoveCallback;
  101538. private _observer;
  101539. private _rollObserver;
  101540. private previousPosition;
  101541. private noPreventDefault;
  101542. private element;
  101543. /**
  101544. * Listen to mouse events to control the camera.
  101545. * @param touchEnabled Define if touch is enabled. (Default is true.)
  101546. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101547. */
  101548. constructor(touchEnabled?: boolean);
  101549. /**
  101550. * Attach the mouse control to the HTML DOM element.
  101551. * @param element Defines the element that listens to the input events.
  101552. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  101553. */
  101554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101555. /**
  101556. * Detach the current controls from the specified dom element.
  101557. * @param element Defines the element to stop listening the inputs from
  101558. */
  101559. detachControl(element: Nullable<HTMLElement>): void;
  101560. /**
  101561. * Gets the class name of the current input.
  101562. * @returns the class name.
  101563. */
  101564. getClassName(): string;
  101565. /**
  101566. * Get the friendly name associated with the input class.
  101567. * @returns the input's friendly name.
  101568. */
  101569. getSimpleName(): string;
  101570. private _pointerInput;
  101571. private _onMouseMove;
  101572. /**
  101573. * Rotate camera by mouse offset.
  101574. */
  101575. private rotateCamera;
  101576. }
  101577. }
  101578. declare module BABYLON {
  101579. /**
  101580. * Default Inputs manager for the FlyCamera.
  101581. * It groups all the default supported inputs for ease of use.
  101582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101583. */
  101584. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  101585. /**
  101586. * Instantiates a new FlyCameraInputsManager.
  101587. * @param camera Defines the camera the inputs belong to.
  101588. */
  101589. constructor(camera: FlyCamera);
  101590. /**
  101591. * Add keyboard input support to the input manager.
  101592. * @returns the new FlyCameraKeyboardMoveInput().
  101593. */
  101594. addKeyboard(): FlyCameraInputsManager;
  101595. /**
  101596. * Add mouse input support to the input manager.
  101597. * @param touchEnabled Enable touch screen support.
  101598. * @returns the new FlyCameraMouseInput().
  101599. */
  101600. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  101601. }
  101602. }
  101603. declare module BABYLON {
  101604. /**
  101605. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101606. * such as in a 3D Space Shooter or a Flight Simulator.
  101607. */
  101608. export class FlyCamera extends TargetCamera {
  101609. /**
  101610. * Define the collision ellipsoid of the camera.
  101611. * This is helpful for simulating a camera body, like a player's body.
  101612. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101613. */
  101614. ellipsoid: Vector3;
  101615. /**
  101616. * Define an offset for the position of the ellipsoid around the camera.
  101617. * This can be helpful if the camera is attached away from the player's body center,
  101618. * such as at its head.
  101619. */
  101620. ellipsoidOffset: Vector3;
  101621. /**
  101622. * Enable or disable collisions of the camera with the rest of the scene objects.
  101623. */
  101624. checkCollisions: boolean;
  101625. /**
  101626. * Enable or disable gravity on the camera.
  101627. */
  101628. applyGravity: boolean;
  101629. /**
  101630. * Define the current direction the camera is moving to.
  101631. */
  101632. cameraDirection: Vector3;
  101633. /**
  101634. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  101635. * This overrides and empties cameraRotation.
  101636. */
  101637. rotationQuaternion: Quaternion;
  101638. /**
  101639. * Track Roll to maintain the wanted Rolling when looking around.
  101640. */
  101641. _trackRoll: number;
  101642. /**
  101643. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  101644. */
  101645. rollCorrect: number;
  101646. /**
  101647. * Mimic a banked turn, Rolling the camera when Yawing.
  101648. * It's recommended to use rollCorrect = 10 for faster banking correction.
  101649. */
  101650. bankedTurn: boolean;
  101651. /**
  101652. * Limit in radians for how much Roll banking will add. (Default: 90°)
  101653. */
  101654. bankedTurnLimit: number;
  101655. /**
  101656. * Value of 0 disables the banked Roll.
  101657. * Value of 1 is equal to the Yaw angle in radians.
  101658. */
  101659. bankedTurnMultiplier: number;
  101660. /**
  101661. * The inputs manager loads all the input sources, such as keyboard and mouse.
  101662. */
  101663. inputs: FlyCameraInputsManager;
  101664. /**
  101665. * Gets the input sensibility for mouse input.
  101666. * Higher values reduce sensitivity.
  101667. */
  101668. /**
  101669. * Sets the input sensibility for a mouse input.
  101670. * Higher values reduce sensitivity.
  101671. */
  101672. angularSensibility: number;
  101673. /**
  101674. * Get the keys for camera movement forward.
  101675. */
  101676. /**
  101677. * Set the keys for camera movement forward.
  101678. */
  101679. keysForward: number[];
  101680. /**
  101681. * Get the keys for camera movement backward.
  101682. */
  101683. keysBackward: number[];
  101684. /**
  101685. * Get the keys for camera movement up.
  101686. */
  101687. /**
  101688. * Set the keys for camera movement up.
  101689. */
  101690. keysUp: number[];
  101691. /**
  101692. * Get the keys for camera movement down.
  101693. */
  101694. /**
  101695. * Set the keys for camera movement down.
  101696. */
  101697. keysDown: number[];
  101698. /**
  101699. * Get the keys for camera movement left.
  101700. */
  101701. /**
  101702. * Set the keys for camera movement left.
  101703. */
  101704. keysLeft: number[];
  101705. /**
  101706. * Set the keys for camera movement right.
  101707. */
  101708. /**
  101709. * Set the keys for camera movement right.
  101710. */
  101711. keysRight: number[];
  101712. /**
  101713. * Event raised when the camera collides with a mesh in the scene.
  101714. */
  101715. onCollide: (collidedMesh: AbstractMesh) => void;
  101716. private _collider;
  101717. private _needMoveForGravity;
  101718. private _oldPosition;
  101719. private _diffPosition;
  101720. private _newPosition;
  101721. /** @hidden */
  101722. _localDirection: Vector3;
  101723. /** @hidden */
  101724. _transformedDirection: Vector3;
  101725. /**
  101726. * Instantiates a FlyCamera.
  101727. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101728. * such as in a 3D Space Shooter or a Flight Simulator.
  101729. * @param name Define the name of the camera in the scene.
  101730. * @param position Define the starting position of the camera in the scene.
  101731. * @param scene Define the scene the camera belongs to.
  101732. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  101733. */
  101734. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101735. /**
  101736. * Attach a control to the HTML DOM element.
  101737. * @param element Defines the element that listens to the input events.
  101738. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  101739. */
  101740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101741. /**
  101742. * Detach a control from the HTML DOM element.
  101743. * The camera will stop reacting to that input.
  101744. * @param element Defines the element that listens to the input events.
  101745. */
  101746. detachControl(element: HTMLElement): void;
  101747. private _collisionMask;
  101748. /**
  101749. * Get the mask that the camera ignores in collision events.
  101750. */
  101751. /**
  101752. * Set the mask that the camera ignores in collision events.
  101753. */
  101754. collisionMask: number;
  101755. /** @hidden */
  101756. _collideWithWorld(displacement: Vector3): void;
  101757. /** @hidden */
  101758. private _onCollisionPositionChange;
  101759. /** @hidden */
  101760. _checkInputs(): void;
  101761. /** @hidden */
  101762. _decideIfNeedsToMove(): boolean;
  101763. /** @hidden */
  101764. _updatePosition(): void;
  101765. /**
  101766. * Restore the Roll to its target value at the rate specified.
  101767. * @param rate - Higher means slower restoring.
  101768. * @hidden
  101769. */
  101770. restoreRoll(rate: number): void;
  101771. /**
  101772. * Destroy the camera and release the current resources held by it.
  101773. */
  101774. dispose(): void;
  101775. /**
  101776. * Get the current object class name.
  101777. * @returns the class name.
  101778. */
  101779. getClassName(): string;
  101780. }
  101781. }
  101782. declare module BABYLON {
  101783. /**
  101784. * Listen to keyboard events to control the camera.
  101785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101786. */
  101787. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  101788. /**
  101789. * Defines the camera the input is attached to.
  101790. */
  101791. camera: FlyCamera;
  101792. /**
  101793. * The list of keyboard keys used to control the forward move of the camera.
  101794. */
  101795. keysForward: number[];
  101796. /**
  101797. * The list of keyboard keys used to control the backward move of the camera.
  101798. */
  101799. keysBackward: number[];
  101800. /**
  101801. * The list of keyboard keys used to control the forward move of the camera.
  101802. */
  101803. keysUp: number[];
  101804. /**
  101805. * The list of keyboard keys used to control the backward move of the camera.
  101806. */
  101807. keysDown: number[];
  101808. /**
  101809. * The list of keyboard keys used to control the right strafe move of the camera.
  101810. */
  101811. keysRight: number[];
  101812. /**
  101813. * The list of keyboard keys used to control the left strafe move of the camera.
  101814. */
  101815. keysLeft: number[];
  101816. private _keys;
  101817. private _onCanvasBlurObserver;
  101818. private _onKeyboardObserver;
  101819. private _engine;
  101820. private _scene;
  101821. /**
  101822. * Attach the input controls to a specific dom element to get the input from.
  101823. * @param element Defines the element the controls should be listened from
  101824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101825. */
  101826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101827. /**
  101828. * Detach the current controls from the specified dom element.
  101829. * @param element Defines the element to stop listening the inputs from
  101830. */
  101831. detachControl(element: Nullable<HTMLElement>): void;
  101832. /**
  101833. * Gets the class name of the current intput.
  101834. * @returns the class name
  101835. */
  101836. getClassName(): string;
  101837. /** @hidden */
  101838. _onLostFocus(e: FocusEvent): void;
  101839. /**
  101840. * Get the friendly name associated with the input class.
  101841. * @returns the input friendly name
  101842. */
  101843. getSimpleName(): string;
  101844. /**
  101845. * Update the current camera state depending on the inputs that have been used this frame.
  101846. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101847. */
  101848. checkInputs(): void;
  101849. }
  101850. }
  101851. declare module BABYLON {
  101852. /**
  101853. * Manage the mouse wheel inputs to control a follow camera.
  101854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101855. */
  101856. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  101857. /**
  101858. * Defines the camera the input is attached to.
  101859. */
  101860. camera: FollowCamera;
  101861. /**
  101862. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  101863. */
  101864. axisControlRadius: boolean;
  101865. /**
  101866. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  101867. */
  101868. axisControlHeight: boolean;
  101869. /**
  101870. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  101871. */
  101872. axisControlRotation: boolean;
  101873. /**
  101874. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  101875. * relation to mouseWheel events.
  101876. */
  101877. wheelPrecision: number;
  101878. /**
  101879. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101880. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101881. */
  101882. wheelDeltaPercentage: number;
  101883. private _wheel;
  101884. private _observer;
  101885. /**
  101886. * Attach the input controls to a specific dom element to get the input from.
  101887. * @param element Defines the element the controls should be listened from
  101888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101889. */
  101890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101891. /**
  101892. * Detach the current controls from the specified dom element.
  101893. * @param element Defines the element to stop listening the inputs from
  101894. */
  101895. detachControl(element: Nullable<HTMLElement>): void;
  101896. /**
  101897. * Gets the class name of the current intput.
  101898. * @returns the class name
  101899. */
  101900. getClassName(): string;
  101901. /**
  101902. * Get the friendly name associated with the input class.
  101903. * @returns the input friendly name
  101904. */
  101905. getSimpleName(): string;
  101906. }
  101907. }
  101908. declare module BABYLON {
  101909. /**
  101910. * Manage the pointers inputs to control an follow camera.
  101911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101912. */
  101913. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  101914. /**
  101915. * Defines the camera the input is attached to.
  101916. */
  101917. camera: FollowCamera;
  101918. /**
  101919. * Gets the class name of the current input.
  101920. * @returns the class name
  101921. */
  101922. getClassName(): string;
  101923. /**
  101924. * Defines the pointer angular sensibility along the X axis or how fast is
  101925. * the camera rotating.
  101926. * A negative number will reverse the axis direction.
  101927. */
  101928. angularSensibilityX: number;
  101929. /**
  101930. * Defines the pointer angular sensibility along the Y axis or how fast is
  101931. * the camera rotating.
  101932. * A negative number will reverse the axis direction.
  101933. */
  101934. angularSensibilityY: number;
  101935. /**
  101936. * Defines the pointer pinch precision or how fast is the camera zooming.
  101937. * A negative number will reverse the axis direction.
  101938. */
  101939. pinchPrecision: number;
  101940. /**
  101941. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101942. * from 0.
  101943. * It defines the percentage of current camera.radius to use as delta when
  101944. * pinch zoom is used.
  101945. */
  101946. pinchDeltaPercentage: number;
  101947. /**
  101948. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  101949. */
  101950. axisXControlRadius: boolean;
  101951. /**
  101952. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  101953. */
  101954. axisXControlHeight: boolean;
  101955. /**
  101956. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  101957. */
  101958. axisXControlRotation: boolean;
  101959. /**
  101960. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  101961. */
  101962. axisYControlRadius: boolean;
  101963. /**
  101964. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  101965. */
  101966. axisYControlHeight: boolean;
  101967. /**
  101968. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  101969. */
  101970. axisYControlRotation: boolean;
  101971. /**
  101972. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  101973. */
  101974. axisPinchControlRadius: boolean;
  101975. /**
  101976. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  101977. */
  101978. axisPinchControlHeight: boolean;
  101979. /**
  101980. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  101981. */
  101982. axisPinchControlRotation: boolean;
  101983. /**
  101984. * Log error messages if basic misconfiguration has occurred.
  101985. */
  101986. warningEnable: boolean;
  101987. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101988. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101989. private _warningCounter;
  101990. private _warning;
  101991. }
  101992. }
  101993. declare module BABYLON {
  101994. /**
  101995. * Default Inputs manager for the FollowCamera.
  101996. * It groups all the default supported inputs for ease of use.
  101997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101998. */
  101999. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  102000. /**
  102001. * Instantiates a new FollowCameraInputsManager.
  102002. * @param camera Defines the camera the inputs belong to
  102003. */
  102004. constructor(camera: FollowCamera);
  102005. /**
  102006. * Add keyboard input support to the input manager.
  102007. * @returns the current input manager
  102008. */
  102009. addKeyboard(): FollowCameraInputsManager;
  102010. /**
  102011. * Add mouse wheel input support to the input manager.
  102012. * @returns the current input manager
  102013. */
  102014. addMouseWheel(): FollowCameraInputsManager;
  102015. /**
  102016. * Add pointers input support to the input manager.
  102017. * @returns the current input manager
  102018. */
  102019. addPointers(): FollowCameraInputsManager;
  102020. /**
  102021. * Add orientation input support to the input manager.
  102022. * @returns the current input manager
  102023. */
  102024. addVRDeviceOrientation(): FollowCameraInputsManager;
  102025. }
  102026. }
  102027. declare module BABYLON {
  102028. /**
  102029. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  102030. * an arc rotate version arcFollowCamera are available.
  102031. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102032. */
  102033. export class FollowCamera extends TargetCamera {
  102034. /**
  102035. * Distance the follow camera should follow an object at
  102036. */
  102037. radius: number;
  102038. /**
  102039. * Minimum allowed distance of the camera to the axis of rotation
  102040. * (The camera can not get closer).
  102041. * This can help limiting how the Camera is able to move in the scene.
  102042. */
  102043. lowerRadiusLimit: Nullable<number>;
  102044. /**
  102045. * Maximum allowed distance of the camera to the axis of rotation
  102046. * (The camera can not get further).
  102047. * This can help limiting how the Camera is able to move in the scene.
  102048. */
  102049. upperRadiusLimit: Nullable<number>;
  102050. /**
  102051. * Define a rotation offset between the camera and the object it follows
  102052. */
  102053. rotationOffset: number;
  102054. /**
  102055. * Minimum allowed angle to camera position relative to target object.
  102056. * This can help limiting how the Camera is able to move in the scene.
  102057. */
  102058. lowerRotationOffsetLimit: Nullable<number>;
  102059. /**
  102060. * Maximum allowed angle to camera position relative to target object.
  102061. * This can help limiting how the Camera is able to move in the scene.
  102062. */
  102063. upperRotationOffsetLimit: Nullable<number>;
  102064. /**
  102065. * Define a height offset between the camera and the object it follows.
  102066. * It can help following an object from the top (like a car chaing a plane)
  102067. */
  102068. heightOffset: number;
  102069. /**
  102070. * Minimum allowed height of camera position relative to target object.
  102071. * This can help limiting how the Camera is able to move in the scene.
  102072. */
  102073. lowerHeightOffsetLimit: Nullable<number>;
  102074. /**
  102075. * Maximum allowed height of camera position relative to target object.
  102076. * This can help limiting how the Camera is able to move in the scene.
  102077. */
  102078. upperHeightOffsetLimit: Nullable<number>;
  102079. /**
  102080. * Define how fast the camera can accelerate to follow it s target.
  102081. */
  102082. cameraAcceleration: number;
  102083. /**
  102084. * Define the speed limit of the camera following an object.
  102085. */
  102086. maxCameraSpeed: number;
  102087. /**
  102088. * Define the target of the camera.
  102089. */
  102090. lockedTarget: Nullable<AbstractMesh>;
  102091. /**
  102092. * Defines the input associated with the camera.
  102093. */
  102094. inputs: FollowCameraInputsManager;
  102095. /**
  102096. * Instantiates the follow camera.
  102097. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102098. * @param name Define the name of the camera in the scene
  102099. * @param position Define the position of the camera
  102100. * @param scene Define the scene the camera belong to
  102101. * @param lockedTarget Define the target of the camera
  102102. */
  102103. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  102104. private _follow;
  102105. /**
  102106. * Attached controls to the current camera.
  102107. * @param element Defines the element the controls should be listened from
  102108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102109. */
  102110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102111. /**
  102112. * Detach the current controls from the camera.
  102113. * The camera will stop reacting to inputs.
  102114. * @param element Defines the element to stop listening the inputs from
  102115. */
  102116. detachControl(element: HTMLElement): void;
  102117. /** @hidden */
  102118. _checkInputs(): void;
  102119. private _checkLimits;
  102120. /**
  102121. * Gets the camera class name.
  102122. * @returns the class name
  102123. */
  102124. getClassName(): string;
  102125. }
  102126. /**
  102127. * Arc Rotate version of the follow camera.
  102128. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  102129. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102130. */
  102131. export class ArcFollowCamera extends TargetCamera {
  102132. /** The longitudinal angle of the camera */
  102133. alpha: number;
  102134. /** The latitudinal angle of the camera */
  102135. beta: number;
  102136. /** The radius of the camera from its target */
  102137. radius: number;
  102138. /** Define the camera target (the messh it should follow) */
  102139. target: Nullable<AbstractMesh>;
  102140. private _cartesianCoordinates;
  102141. /**
  102142. * Instantiates a new ArcFollowCamera
  102143. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102144. * @param name Define the name of the camera
  102145. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  102146. * @param beta Define the rotation angle of the camera around the elevation axis
  102147. * @param radius Define the radius of the camera from its target point
  102148. * @param target Define the target of the camera
  102149. * @param scene Define the scene the camera belongs to
  102150. */
  102151. constructor(name: string,
  102152. /** The longitudinal angle of the camera */
  102153. alpha: number,
  102154. /** The latitudinal angle of the camera */
  102155. beta: number,
  102156. /** The radius of the camera from its target */
  102157. radius: number,
  102158. /** Define the camera target (the messh it should follow) */
  102159. target: Nullable<AbstractMesh>, scene: Scene);
  102160. private _follow;
  102161. /** @hidden */
  102162. _checkInputs(): void;
  102163. /**
  102164. * Returns the class name of the object.
  102165. * It is mostly used internally for serialization purposes.
  102166. */
  102167. getClassName(): string;
  102168. }
  102169. }
  102170. declare module BABYLON {
  102171. /**
  102172. * Manage the keyboard inputs to control the movement of a follow camera.
  102173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102174. */
  102175. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  102176. /**
  102177. * Defines the camera the input is attached to.
  102178. */
  102179. camera: FollowCamera;
  102180. /**
  102181. * Defines the list of key codes associated with the up action (increase heightOffset)
  102182. */
  102183. keysHeightOffsetIncr: number[];
  102184. /**
  102185. * Defines the list of key codes associated with the down action (decrease heightOffset)
  102186. */
  102187. keysHeightOffsetDecr: number[];
  102188. /**
  102189. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  102190. */
  102191. keysHeightOffsetModifierAlt: boolean;
  102192. /**
  102193. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  102194. */
  102195. keysHeightOffsetModifierCtrl: boolean;
  102196. /**
  102197. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  102198. */
  102199. keysHeightOffsetModifierShift: boolean;
  102200. /**
  102201. * Defines the list of key codes associated with the left action (increase rotationOffset)
  102202. */
  102203. keysRotationOffsetIncr: number[];
  102204. /**
  102205. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  102206. */
  102207. keysRotationOffsetDecr: number[];
  102208. /**
  102209. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  102210. */
  102211. keysRotationOffsetModifierAlt: boolean;
  102212. /**
  102213. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  102214. */
  102215. keysRotationOffsetModifierCtrl: boolean;
  102216. /**
  102217. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  102218. */
  102219. keysRotationOffsetModifierShift: boolean;
  102220. /**
  102221. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  102222. */
  102223. keysRadiusIncr: number[];
  102224. /**
  102225. * Defines the list of key codes associated with the zoom-out action (increase radius)
  102226. */
  102227. keysRadiusDecr: number[];
  102228. /**
  102229. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  102230. */
  102231. keysRadiusModifierAlt: boolean;
  102232. /**
  102233. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  102234. */
  102235. keysRadiusModifierCtrl: boolean;
  102236. /**
  102237. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  102238. */
  102239. keysRadiusModifierShift: boolean;
  102240. /**
  102241. * Defines the rate of change of heightOffset.
  102242. */
  102243. heightSensibility: number;
  102244. /**
  102245. * Defines the rate of change of rotationOffset.
  102246. */
  102247. rotationSensibility: number;
  102248. /**
  102249. * Defines the rate of change of radius.
  102250. */
  102251. radiusSensibility: number;
  102252. private _keys;
  102253. private _ctrlPressed;
  102254. private _altPressed;
  102255. private _shiftPressed;
  102256. private _onCanvasBlurObserver;
  102257. private _onKeyboardObserver;
  102258. private _engine;
  102259. private _scene;
  102260. /**
  102261. * Attach the input controls to a specific dom element to get the input from.
  102262. * @param element Defines the element the controls should be listened from
  102263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102264. */
  102265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102266. /**
  102267. * Detach the current controls from the specified dom element.
  102268. * @param element Defines the element to stop listening the inputs from
  102269. */
  102270. detachControl(element: Nullable<HTMLElement>): void;
  102271. /**
  102272. * Update the current camera state depending on the inputs that have been used this frame.
  102273. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102274. */
  102275. checkInputs(): void;
  102276. /**
  102277. * Gets the class name of the current input.
  102278. * @returns the class name
  102279. */
  102280. getClassName(): string;
  102281. /**
  102282. * Get the friendly name associated with the input class.
  102283. * @returns the input friendly name
  102284. */
  102285. getSimpleName(): string;
  102286. /**
  102287. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102288. * allow modification of the heightOffset value.
  102289. */
  102290. private _modifierHeightOffset;
  102291. /**
  102292. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102293. * allow modification of the rotationOffset value.
  102294. */
  102295. private _modifierRotationOffset;
  102296. /**
  102297. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102298. * allow modification of the radius value.
  102299. */
  102300. private _modifierRadius;
  102301. }
  102302. }
  102303. declare module BABYLON {
  102304. interface FreeCameraInputsManager {
  102305. /**
  102306. * @hidden
  102307. */
  102308. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  102309. /**
  102310. * Add orientation input support to the input manager.
  102311. * @returns the current input manager
  102312. */
  102313. addDeviceOrientation(): FreeCameraInputsManager;
  102314. }
  102315. /**
  102316. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  102317. * Screen rotation is taken into account.
  102318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102319. */
  102320. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  102321. private _camera;
  102322. private _screenOrientationAngle;
  102323. private _constantTranform;
  102324. private _screenQuaternion;
  102325. private _alpha;
  102326. private _beta;
  102327. private _gamma;
  102328. /**
  102329. * Can be used to detect if a device orientation sensor is availible on a device
  102330. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  102331. * @returns a promise that will resolve on orientation change
  102332. */
  102333. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  102334. /**
  102335. * @hidden
  102336. */
  102337. _onDeviceOrientationChangedObservable: Observable<void>;
  102338. /**
  102339. * Instantiates a new input
  102340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102341. */
  102342. constructor();
  102343. /**
  102344. * Define the camera controlled by the input.
  102345. */
  102346. camera: FreeCamera;
  102347. /**
  102348. * Attach the input controls to a specific dom element to get the input from.
  102349. * @param element Defines the element the controls should be listened from
  102350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102351. */
  102352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102353. private _orientationChanged;
  102354. private _deviceOrientation;
  102355. /**
  102356. * Detach the current controls from the specified dom element.
  102357. * @param element Defines the element to stop listening the inputs from
  102358. */
  102359. detachControl(element: Nullable<HTMLElement>): void;
  102360. /**
  102361. * Update the current camera state depending on the inputs that have been used this frame.
  102362. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102363. */
  102364. checkInputs(): void;
  102365. /**
  102366. * Gets the class name of the current intput.
  102367. * @returns the class name
  102368. */
  102369. getClassName(): string;
  102370. /**
  102371. * Get the friendly name associated with the input class.
  102372. * @returns the input friendly name
  102373. */
  102374. getSimpleName(): string;
  102375. }
  102376. }
  102377. declare module BABYLON {
  102378. /**
  102379. * Manage the gamepad inputs to control a free camera.
  102380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102381. */
  102382. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  102383. /**
  102384. * Define the camera the input is attached to.
  102385. */
  102386. camera: FreeCamera;
  102387. /**
  102388. * Define the Gamepad controlling the input
  102389. */
  102390. gamepad: Nullable<Gamepad>;
  102391. /**
  102392. * Defines the gamepad rotation sensiblity.
  102393. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102394. */
  102395. gamepadAngularSensibility: number;
  102396. /**
  102397. * Defines the gamepad move sensiblity.
  102398. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102399. */
  102400. gamepadMoveSensibility: number;
  102401. private _onGamepadConnectedObserver;
  102402. private _onGamepadDisconnectedObserver;
  102403. private _cameraTransform;
  102404. private _deltaTransform;
  102405. private _vector3;
  102406. private _vector2;
  102407. /**
  102408. * Attach the input controls to a specific dom element to get the input from.
  102409. * @param element Defines the element the controls should be listened from
  102410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102411. */
  102412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102413. /**
  102414. * Detach the current controls from the specified dom element.
  102415. * @param element Defines the element to stop listening the inputs from
  102416. */
  102417. detachControl(element: Nullable<HTMLElement>): void;
  102418. /**
  102419. * Update the current camera state depending on the inputs that have been used this frame.
  102420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102421. */
  102422. checkInputs(): void;
  102423. /**
  102424. * Gets the class name of the current intput.
  102425. * @returns the class name
  102426. */
  102427. getClassName(): string;
  102428. /**
  102429. * Get the friendly name associated with the input class.
  102430. * @returns the input friendly name
  102431. */
  102432. getSimpleName(): string;
  102433. }
  102434. }
  102435. declare module BABYLON {
  102436. /**
  102437. * Defines the potential axis of a Joystick
  102438. */
  102439. export enum JoystickAxis {
  102440. /** X axis */
  102441. X = 0,
  102442. /** Y axis */
  102443. Y = 1,
  102444. /** Z axis */
  102445. Z = 2
  102446. }
  102447. /**
  102448. * Class used to define virtual joystick (used in touch mode)
  102449. */
  102450. export class VirtualJoystick {
  102451. /**
  102452. * Gets or sets a boolean indicating that left and right values must be inverted
  102453. */
  102454. reverseLeftRight: boolean;
  102455. /**
  102456. * Gets or sets a boolean indicating that up and down values must be inverted
  102457. */
  102458. reverseUpDown: boolean;
  102459. /**
  102460. * Gets the offset value for the position (ie. the change of the position value)
  102461. */
  102462. deltaPosition: Vector3;
  102463. /**
  102464. * Gets a boolean indicating if the virtual joystick was pressed
  102465. */
  102466. pressed: boolean;
  102467. /**
  102468. * Canvas the virtual joystick will render onto, default z-index of this is 5
  102469. */
  102470. static Canvas: Nullable<HTMLCanvasElement>;
  102471. private static _globalJoystickIndex;
  102472. private static vjCanvasContext;
  102473. private static vjCanvasWidth;
  102474. private static vjCanvasHeight;
  102475. private static halfWidth;
  102476. private _action;
  102477. private _axisTargetedByLeftAndRight;
  102478. private _axisTargetedByUpAndDown;
  102479. private _joystickSensibility;
  102480. private _inversedSensibility;
  102481. private _joystickPointerID;
  102482. private _joystickColor;
  102483. private _joystickPointerPos;
  102484. private _joystickPreviousPointerPos;
  102485. private _joystickPointerStartPos;
  102486. private _deltaJoystickVector;
  102487. private _leftJoystick;
  102488. private _touches;
  102489. private _onPointerDownHandlerRef;
  102490. private _onPointerMoveHandlerRef;
  102491. private _onPointerUpHandlerRef;
  102492. private _onResize;
  102493. /**
  102494. * Creates a new virtual joystick
  102495. * @param leftJoystick defines that the joystick is for left hand (false by default)
  102496. */
  102497. constructor(leftJoystick?: boolean);
  102498. /**
  102499. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  102500. * @param newJoystickSensibility defines the new sensibility
  102501. */
  102502. setJoystickSensibility(newJoystickSensibility: number): void;
  102503. private _onPointerDown;
  102504. private _onPointerMove;
  102505. private _onPointerUp;
  102506. /**
  102507. * Change the color of the virtual joystick
  102508. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  102509. */
  102510. setJoystickColor(newColor: string): void;
  102511. /**
  102512. * Defines a callback to call when the joystick is touched
  102513. * @param action defines the callback
  102514. */
  102515. setActionOnTouch(action: () => any): void;
  102516. /**
  102517. * Defines which axis you'd like to control for left & right
  102518. * @param axis defines the axis to use
  102519. */
  102520. setAxisForLeftRight(axis: JoystickAxis): void;
  102521. /**
  102522. * Defines which axis you'd like to control for up & down
  102523. * @param axis defines the axis to use
  102524. */
  102525. setAxisForUpDown(axis: JoystickAxis): void;
  102526. private _drawVirtualJoystick;
  102527. /**
  102528. * Release internal HTML canvas
  102529. */
  102530. releaseCanvas(): void;
  102531. }
  102532. }
  102533. declare module BABYLON {
  102534. interface FreeCameraInputsManager {
  102535. /**
  102536. * Add virtual joystick input support to the input manager.
  102537. * @returns the current input manager
  102538. */
  102539. addVirtualJoystick(): FreeCameraInputsManager;
  102540. }
  102541. /**
  102542. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  102543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102544. */
  102545. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  102546. /**
  102547. * Defines the camera the input is attached to.
  102548. */
  102549. camera: FreeCamera;
  102550. private _leftjoystick;
  102551. private _rightjoystick;
  102552. /**
  102553. * Gets the left stick of the virtual joystick.
  102554. * @returns The virtual Joystick
  102555. */
  102556. getLeftJoystick(): VirtualJoystick;
  102557. /**
  102558. * Gets the right stick of the virtual joystick.
  102559. * @returns The virtual Joystick
  102560. */
  102561. getRightJoystick(): VirtualJoystick;
  102562. /**
  102563. * Update the current camera state depending on the inputs that have been used this frame.
  102564. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102565. */
  102566. checkInputs(): void;
  102567. /**
  102568. * Attach the input controls to a specific dom element to get the input from.
  102569. * @param element Defines the element the controls should be listened from
  102570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102571. */
  102572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102573. /**
  102574. * Detach the current controls from the specified dom element.
  102575. * @param element Defines the element to stop listening the inputs from
  102576. */
  102577. detachControl(element: Nullable<HTMLElement>): void;
  102578. /**
  102579. * Gets the class name of the current intput.
  102580. * @returns the class name
  102581. */
  102582. getClassName(): string;
  102583. /**
  102584. * Get the friendly name associated with the input class.
  102585. * @returns the input friendly name
  102586. */
  102587. getSimpleName(): string;
  102588. }
  102589. }
  102590. declare module BABYLON {
  102591. /**
  102592. * This represents a FPS type of camera controlled by touch.
  102593. * This is like a universal camera minus the Gamepad controls.
  102594. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102595. */
  102596. export class TouchCamera extends FreeCamera {
  102597. /**
  102598. * Defines the touch sensibility for rotation.
  102599. * The higher the faster.
  102600. */
  102601. touchAngularSensibility: number;
  102602. /**
  102603. * Defines the touch sensibility for move.
  102604. * The higher the faster.
  102605. */
  102606. touchMoveSensibility: number;
  102607. /**
  102608. * Instantiates a new touch camera.
  102609. * This represents a FPS type of camera controlled by touch.
  102610. * This is like a universal camera minus the Gamepad controls.
  102611. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102612. * @param name Define the name of the camera in the scene
  102613. * @param position Define the start position of the camera in the scene
  102614. * @param scene Define the scene the camera belongs to
  102615. */
  102616. constructor(name: string, position: Vector3, scene: Scene);
  102617. /**
  102618. * Gets the current object class name.
  102619. * @return the class name
  102620. */
  102621. getClassName(): string;
  102622. /** @hidden */
  102623. _setupInputs(): void;
  102624. }
  102625. }
  102626. declare module BABYLON {
  102627. /**
  102628. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  102629. * being tilted forward or back and left or right.
  102630. */
  102631. export class DeviceOrientationCamera extends FreeCamera {
  102632. private _initialQuaternion;
  102633. private _quaternionCache;
  102634. private _tmpDragQuaternion;
  102635. private _disablePointerInputWhenUsingDeviceOrientation;
  102636. /**
  102637. * Creates a new device orientation camera
  102638. * @param name The name of the camera
  102639. * @param position The start position camera
  102640. * @param scene The scene the camera belongs to
  102641. */
  102642. constructor(name: string, position: Vector3, scene: Scene);
  102643. /**
  102644. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  102645. */
  102646. disablePointerInputWhenUsingDeviceOrientation: boolean;
  102647. private _dragFactor;
  102648. /**
  102649. * Enabled turning on the y axis when the orientation sensor is active
  102650. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  102651. */
  102652. enableHorizontalDragging(dragFactor?: number): void;
  102653. /**
  102654. * Gets the current instance class name ("DeviceOrientationCamera").
  102655. * This helps avoiding instanceof at run time.
  102656. * @returns the class name
  102657. */
  102658. getClassName(): string;
  102659. /**
  102660. * @hidden
  102661. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  102662. */
  102663. _checkInputs(): void;
  102664. /**
  102665. * Reset the camera to its default orientation on the specified axis only.
  102666. * @param axis The axis to reset
  102667. */
  102668. resetToCurrentRotation(axis?: Axis): void;
  102669. }
  102670. }
  102671. declare module BABYLON {
  102672. /**
  102673. * Defines supported buttons for XBox360 compatible gamepads
  102674. */
  102675. export enum Xbox360Button {
  102676. /** A */
  102677. A = 0,
  102678. /** B */
  102679. B = 1,
  102680. /** X */
  102681. X = 2,
  102682. /** Y */
  102683. Y = 3,
  102684. /** Start */
  102685. Start = 4,
  102686. /** Back */
  102687. Back = 5,
  102688. /** Left button */
  102689. LB = 6,
  102690. /** Right button */
  102691. RB = 7,
  102692. /** Left stick */
  102693. LeftStick = 8,
  102694. /** Right stick */
  102695. RightStick = 9
  102696. }
  102697. /** Defines values for XBox360 DPad */
  102698. export enum Xbox360Dpad {
  102699. /** Up */
  102700. Up = 0,
  102701. /** Down */
  102702. Down = 1,
  102703. /** Left */
  102704. Left = 2,
  102705. /** Right */
  102706. Right = 3
  102707. }
  102708. /**
  102709. * Defines a XBox360 gamepad
  102710. */
  102711. export class Xbox360Pad extends Gamepad {
  102712. private _leftTrigger;
  102713. private _rightTrigger;
  102714. private _onlefttriggerchanged;
  102715. private _onrighttriggerchanged;
  102716. private _onbuttondown;
  102717. private _onbuttonup;
  102718. private _ondpaddown;
  102719. private _ondpadup;
  102720. /** Observable raised when a button is pressed */
  102721. onButtonDownObservable: Observable<Xbox360Button>;
  102722. /** Observable raised when a button is released */
  102723. onButtonUpObservable: Observable<Xbox360Button>;
  102724. /** Observable raised when a pad is pressed */
  102725. onPadDownObservable: Observable<Xbox360Dpad>;
  102726. /** Observable raised when a pad is released */
  102727. onPadUpObservable: Observable<Xbox360Dpad>;
  102728. private _buttonA;
  102729. private _buttonB;
  102730. private _buttonX;
  102731. private _buttonY;
  102732. private _buttonBack;
  102733. private _buttonStart;
  102734. private _buttonLB;
  102735. private _buttonRB;
  102736. private _buttonLeftStick;
  102737. private _buttonRightStick;
  102738. private _dPadUp;
  102739. private _dPadDown;
  102740. private _dPadLeft;
  102741. private _dPadRight;
  102742. private _isXboxOnePad;
  102743. /**
  102744. * Creates a new XBox360 gamepad object
  102745. * @param id defines the id of this gamepad
  102746. * @param index defines its index
  102747. * @param gamepad defines the internal HTML gamepad object
  102748. * @param xboxOne defines if it is a XBox One gamepad
  102749. */
  102750. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  102751. /**
  102752. * Defines the callback to call when left trigger is pressed
  102753. * @param callback defines the callback to use
  102754. */
  102755. onlefttriggerchanged(callback: (value: number) => void): void;
  102756. /**
  102757. * Defines the callback to call when right trigger is pressed
  102758. * @param callback defines the callback to use
  102759. */
  102760. onrighttriggerchanged(callback: (value: number) => void): void;
  102761. /**
  102762. * Gets the left trigger value
  102763. */
  102764. /**
  102765. * Sets the left trigger value
  102766. */
  102767. leftTrigger: number;
  102768. /**
  102769. * Gets the right trigger value
  102770. */
  102771. /**
  102772. * Sets the right trigger value
  102773. */
  102774. rightTrigger: number;
  102775. /**
  102776. * Defines the callback to call when a button is pressed
  102777. * @param callback defines the callback to use
  102778. */
  102779. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  102780. /**
  102781. * Defines the callback to call when a button is released
  102782. * @param callback defines the callback to use
  102783. */
  102784. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  102785. /**
  102786. * Defines the callback to call when a pad is pressed
  102787. * @param callback defines the callback to use
  102788. */
  102789. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  102790. /**
  102791. * Defines the callback to call when a pad is released
  102792. * @param callback defines the callback to use
  102793. */
  102794. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  102795. private _setButtonValue;
  102796. private _setDPadValue;
  102797. /**
  102798. * Gets the value of the `A` button
  102799. */
  102800. /**
  102801. * Sets the value of the `A` button
  102802. */
  102803. buttonA: number;
  102804. /**
  102805. * Gets the value of the `B` button
  102806. */
  102807. /**
  102808. * Sets the value of the `B` button
  102809. */
  102810. buttonB: number;
  102811. /**
  102812. * Gets the value of the `X` button
  102813. */
  102814. /**
  102815. * Sets the value of the `X` button
  102816. */
  102817. buttonX: number;
  102818. /**
  102819. * Gets the value of the `Y` button
  102820. */
  102821. /**
  102822. * Sets the value of the `Y` button
  102823. */
  102824. buttonY: number;
  102825. /**
  102826. * Gets the value of the `Start` button
  102827. */
  102828. /**
  102829. * Sets the value of the `Start` button
  102830. */
  102831. buttonStart: number;
  102832. /**
  102833. * Gets the value of the `Back` button
  102834. */
  102835. /**
  102836. * Sets the value of the `Back` button
  102837. */
  102838. buttonBack: number;
  102839. /**
  102840. * Gets the value of the `Left` button
  102841. */
  102842. /**
  102843. * Sets the value of the `Left` button
  102844. */
  102845. buttonLB: number;
  102846. /**
  102847. * Gets the value of the `Right` button
  102848. */
  102849. /**
  102850. * Sets the value of the `Right` button
  102851. */
  102852. buttonRB: number;
  102853. /**
  102854. * Gets the value of the Left joystick
  102855. */
  102856. /**
  102857. * Sets the value of the Left joystick
  102858. */
  102859. buttonLeftStick: number;
  102860. /**
  102861. * Gets the value of the Right joystick
  102862. */
  102863. /**
  102864. * Sets the value of the Right joystick
  102865. */
  102866. buttonRightStick: number;
  102867. /**
  102868. * Gets the value of D-pad up
  102869. */
  102870. /**
  102871. * Sets the value of D-pad up
  102872. */
  102873. dPadUp: number;
  102874. /**
  102875. * Gets the value of D-pad down
  102876. */
  102877. /**
  102878. * Sets the value of D-pad down
  102879. */
  102880. dPadDown: number;
  102881. /**
  102882. * Gets the value of D-pad left
  102883. */
  102884. /**
  102885. * Sets the value of D-pad left
  102886. */
  102887. dPadLeft: number;
  102888. /**
  102889. * Gets the value of D-pad right
  102890. */
  102891. /**
  102892. * Sets the value of D-pad right
  102893. */
  102894. dPadRight: number;
  102895. /**
  102896. * Force the gamepad to synchronize with device values
  102897. */
  102898. update(): void;
  102899. /**
  102900. * Disposes the gamepad
  102901. */
  102902. dispose(): void;
  102903. }
  102904. }
  102905. declare module BABYLON {
  102906. /**
  102907. * Defines supported buttons for DualShock compatible gamepads
  102908. */
  102909. export enum DualShockButton {
  102910. /** Cross */
  102911. Cross = 0,
  102912. /** Circle */
  102913. Circle = 1,
  102914. /** Square */
  102915. Square = 2,
  102916. /** Triangle */
  102917. Triangle = 3,
  102918. /** Options */
  102919. Options = 4,
  102920. /** Share */
  102921. Share = 5,
  102922. /** L1 */
  102923. L1 = 6,
  102924. /** R1 */
  102925. R1 = 7,
  102926. /** Left stick */
  102927. LeftStick = 8,
  102928. /** Right stick */
  102929. RightStick = 9
  102930. }
  102931. /** Defines values for DualShock DPad */
  102932. export enum DualShockDpad {
  102933. /** Up */
  102934. Up = 0,
  102935. /** Down */
  102936. Down = 1,
  102937. /** Left */
  102938. Left = 2,
  102939. /** Right */
  102940. Right = 3
  102941. }
  102942. /**
  102943. * Defines a DualShock gamepad
  102944. */
  102945. export class DualShockPad extends Gamepad {
  102946. private _leftTrigger;
  102947. private _rightTrigger;
  102948. private _onlefttriggerchanged;
  102949. private _onrighttriggerchanged;
  102950. private _onbuttondown;
  102951. private _onbuttonup;
  102952. private _ondpaddown;
  102953. private _ondpadup;
  102954. /** Observable raised when a button is pressed */
  102955. onButtonDownObservable: Observable<DualShockButton>;
  102956. /** Observable raised when a button is released */
  102957. onButtonUpObservable: Observable<DualShockButton>;
  102958. /** Observable raised when a pad is pressed */
  102959. onPadDownObservable: Observable<DualShockDpad>;
  102960. /** Observable raised when a pad is released */
  102961. onPadUpObservable: Observable<DualShockDpad>;
  102962. private _buttonCross;
  102963. private _buttonCircle;
  102964. private _buttonSquare;
  102965. private _buttonTriangle;
  102966. private _buttonShare;
  102967. private _buttonOptions;
  102968. private _buttonL1;
  102969. private _buttonR1;
  102970. private _buttonLeftStick;
  102971. private _buttonRightStick;
  102972. private _dPadUp;
  102973. private _dPadDown;
  102974. private _dPadLeft;
  102975. private _dPadRight;
  102976. /**
  102977. * Creates a new DualShock gamepad object
  102978. * @param id defines the id of this gamepad
  102979. * @param index defines its index
  102980. * @param gamepad defines the internal HTML gamepad object
  102981. */
  102982. constructor(id: string, index: number, gamepad: any);
  102983. /**
  102984. * Defines the callback to call when left trigger is pressed
  102985. * @param callback defines the callback to use
  102986. */
  102987. onlefttriggerchanged(callback: (value: number) => void): void;
  102988. /**
  102989. * Defines the callback to call when right trigger is pressed
  102990. * @param callback defines the callback to use
  102991. */
  102992. onrighttriggerchanged(callback: (value: number) => void): void;
  102993. /**
  102994. * Gets the left trigger value
  102995. */
  102996. /**
  102997. * Sets the left trigger value
  102998. */
  102999. leftTrigger: number;
  103000. /**
  103001. * Gets the right trigger value
  103002. */
  103003. /**
  103004. * Sets the right trigger value
  103005. */
  103006. rightTrigger: number;
  103007. /**
  103008. * Defines the callback to call when a button is pressed
  103009. * @param callback defines the callback to use
  103010. */
  103011. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  103012. /**
  103013. * Defines the callback to call when a button is released
  103014. * @param callback defines the callback to use
  103015. */
  103016. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  103017. /**
  103018. * Defines the callback to call when a pad is pressed
  103019. * @param callback defines the callback to use
  103020. */
  103021. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  103022. /**
  103023. * Defines the callback to call when a pad is released
  103024. * @param callback defines the callback to use
  103025. */
  103026. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  103027. private _setButtonValue;
  103028. private _setDPadValue;
  103029. /**
  103030. * Gets the value of the `Cross` button
  103031. */
  103032. /**
  103033. * Sets the value of the `Cross` button
  103034. */
  103035. buttonCross: number;
  103036. /**
  103037. * Gets the value of the `Circle` button
  103038. */
  103039. /**
  103040. * Sets the value of the `Circle` button
  103041. */
  103042. buttonCircle: number;
  103043. /**
  103044. * Gets the value of the `Square` button
  103045. */
  103046. /**
  103047. * Sets the value of the `Square` button
  103048. */
  103049. buttonSquare: number;
  103050. /**
  103051. * Gets the value of the `Triangle` button
  103052. */
  103053. /**
  103054. * Sets the value of the `Triangle` button
  103055. */
  103056. buttonTriangle: number;
  103057. /**
  103058. * Gets the value of the `Options` button
  103059. */
  103060. /**
  103061. * Sets the value of the `Options` button
  103062. */
  103063. buttonOptions: number;
  103064. /**
  103065. * Gets the value of the `Share` button
  103066. */
  103067. /**
  103068. * Sets the value of the `Share` button
  103069. */
  103070. buttonShare: number;
  103071. /**
  103072. * Gets the value of the `L1` button
  103073. */
  103074. /**
  103075. * Sets the value of the `L1` button
  103076. */
  103077. buttonL1: number;
  103078. /**
  103079. * Gets the value of the `R1` button
  103080. */
  103081. /**
  103082. * Sets the value of the `R1` button
  103083. */
  103084. buttonR1: number;
  103085. /**
  103086. * Gets the value of the Left joystick
  103087. */
  103088. /**
  103089. * Sets the value of the Left joystick
  103090. */
  103091. buttonLeftStick: number;
  103092. /**
  103093. * Gets the value of the Right joystick
  103094. */
  103095. /**
  103096. * Sets the value of the Right joystick
  103097. */
  103098. buttonRightStick: number;
  103099. /**
  103100. * Gets the value of D-pad up
  103101. */
  103102. /**
  103103. * Sets the value of D-pad up
  103104. */
  103105. dPadUp: number;
  103106. /**
  103107. * Gets the value of D-pad down
  103108. */
  103109. /**
  103110. * Sets the value of D-pad down
  103111. */
  103112. dPadDown: number;
  103113. /**
  103114. * Gets the value of D-pad left
  103115. */
  103116. /**
  103117. * Sets the value of D-pad left
  103118. */
  103119. dPadLeft: number;
  103120. /**
  103121. * Gets the value of D-pad right
  103122. */
  103123. /**
  103124. * Sets the value of D-pad right
  103125. */
  103126. dPadRight: number;
  103127. /**
  103128. * Force the gamepad to synchronize with device values
  103129. */
  103130. update(): void;
  103131. /**
  103132. * Disposes the gamepad
  103133. */
  103134. dispose(): void;
  103135. }
  103136. }
  103137. declare module BABYLON {
  103138. /**
  103139. * Manager for handling gamepads
  103140. */
  103141. export class GamepadManager {
  103142. private _scene?;
  103143. private _babylonGamepads;
  103144. private _oneGamepadConnected;
  103145. /** @hidden */
  103146. _isMonitoring: boolean;
  103147. private _gamepadEventSupported;
  103148. private _gamepadSupport;
  103149. /**
  103150. * observable to be triggered when the gamepad controller has been connected
  103151. */
  103152. onGamepadConnectedObservable: Observable<Gamepad>;
  103153. /**
  103154. * observable to be triggered when the gamepad controller has been disconnected
  103155. */
  103156. onGamepadDisconnectedObservable: Observable<Gamepad>;
  103157. private _onGamepadConnectedEvent;
  103158. private _onGamepadDisconnectedEvent;
  103159. /**
  103160. * Initializes the gamepad manager
  103161. * @param _scene BabylonJS scene
  103162. */
  103163. constructor(_scene?: Scene | undefined);
  103164. /**
  103165. * The gamepads in the game pad manager
  103166. */
  103167. readonly gamepads: Gamepad[];
  103168. /**
  103169. * Get the gamepad controllers based on type
  103170. * @param type The type of gamepad controller
  103171. * @returns Nullable gamepad
  103172. */
  103173. getGamepadByType(type?: number): Nullable<Gamepad>;
  103174. /**
  103175. * Disposes the gamepad manager
  103176. */
  103177. dispose(): void;
  103178. private _addNewGamepad;
  103179. private _startMonitoringGamepads;
  103180. private _stopMonitoringGamepads;
  103181. /** @hidden */
  103182. _checkGamepadsStatus(): void;
  103183. private _updateGamepadObjects;
  103184. }
  103185. }
  103186. declare module BABYLON {
  103187. interface Scene {
  103188. /** @hidden */
  103189. _gamepadManager: Nullable<GamepadManager>;
  103190. /**
  103191. * Gets the gamepad manager associated with the scene
  103192. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  103193. */
  103194. gamepadManager: GamepadManager;
  103195. }
  103196. /**
  103197. * Interface representing a free camera inputs manager
  103198. */
  103199. interface FreeCameraInputsManager {
  103200. /**
  103201. * Adds gamepad input support to the FreeCameraInputsManager.
  103202. * @returns the FreeCameraInputsManager
  103203. */
  103204. addGamepad(): FreeCameraInputsManager;
  103205. }
  103206. /**
  103207. * Interface representing an arc rotate camera inputs manager
  103208. */
  103209. interface ArcRotateCameraInputsManager {
  103210. /**
  103211. * Adds gamepad input support to the ArcRotateCamera InputManager.
  103212. * @returns the camera inputs manager
  103213. */
  103214. addGamepad(): ArcRotateCameraInputsManager;
  103215. }
  103216. /**
  103217. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  103218. */
  103219. export class GamepadSystemSceneComponent implements ISceneComponent {
  103220. /**
  103221. * The component name helpfull to identify the component in the list of scene components.
  103222. */
  103223. readonly name: string;
  103224. /**
  103225. * The scene the component belongs to.
  103226. */
  103227. scene: Scene;
  103228. /**
  103229. * Creates a new instance of the component for the given scene
  103230. * @param scene Defines the scene to register the component in
  103231. */
  103232. constructor(scene: Scene);
  103233. /**
  103234. * Registers the component in a given scene
  103235. */
  103236. register(): void;
  103237. /**
  103238. * Rebuilds the elements related to this component in case of
  103239. * context lost for instance.
  103240. */
  103241. rebuild(): void;
  103242. /**
  103243. * Disposes the component and the associated ressources
  103244. */
  103245. dispose(): void;
  103246. private _beforeCameraUpdate;
  103247. }
  103248. }
  103249. declare module BABYLON {
  103250. /**
  103251. * 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,
  103252. * which still works and will still be found in many Playgrounds.
  103253. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103254. */
  103255. export class UniversalCamera extends TouchCamera {
  103256. /**
  103257. * Defines the gamepad rotation sensiblity.
  103258. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103259. */
  103260. gamepadAngularSensibility: number;
  103261. /**
  103262. * Defines the gamepad move sensiblity.
  103263. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103264. */
  103265. gamepadMoveSensibility: number;
  103266. /**
  103267. * 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,
  103268. * which still works and will still be found in many Playgrounds.
  103269. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103270. * @param name Define the name of the camera in the scene
  103271. * @param position Define the start position of the camera in the scene
  103272. * @param scene Define the scene the camera belongs to
  103273. */
  103274. constructor(name: string, position: Vector3, scene: Scene);
  103275. /**
  103276. * Gets the current object class name.
  103277. * @return the class name
  103278. */
  103279. getClassName(): string;
  103280. }
  103281. }
  103282. declare module BABYLON {
  103283. /**
  103284. * This represents a FPS type of camera. This is only here for back compat purpose.
  103285. * Please use the UniversalCamera instead as both are identical.
  103286. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103287. */
  103288. export class GamepadCamera extends UniversalCamera {
  103289. /**
  103290. * Instantiates a new Gamepad Camera
  103291. * This represents a FPS type of camera. This is only here for back compat purpose.
  103292. * Please use the UniversalCamera instead as both are identical.
  103293. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103294. * @param name Define the name of the camera in the scene
  103295. * @param position Define the start position of the camera in the scene
  103296. * @param scene Define the scene the camera belongs to
  103297. */
  103298. constructor(name: string, position: Vector3, scene: Scene);
  103299. /**
  103300. * Gets the current object class name.
  103301. * @return the class name
  103302. */
  103303. getClassName(): string;
  103304. }
  103305. }
  103306. declare module BABYLON {
  103307. /** @hidden */
  103308. export var passPixelShader: {
  103309. name: string;
  103310. shader: string;
  103311. };
  103312. }
  103313. declare module BABYLON {
  103314. /** @hidden */
  103315. export var passCubePixelShader: {
  103316. name: string;
  103317. shader: string;
  103318. };
  103319. }
  103320. declare module BABYLON {
  103321. /**
  103322. * PassPostProcess which produces an output the same as it's input
  103323. */
  103324. export class PassPostProcess extends PostProcess {
  103325. /**
  103326. * Creates the PassPostProcess
  103327. * @param name The name of the effect.
  103328. * @param options The required width/height ratio to downsize to before computing the render pass.
  103329. * @param camera The camera to apply the render pass to.
  103330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103331. * @param engine The engine which the post process will be applied. (default: current engine)
  103332. * @param reusable If the post process can be reused on the same frame. (default: false)
  103333. * @param textureType The type of texture to be used when performing the post processing.
  103334. * @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)
  103335. */
  103336. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103337. }
  103338. /**
  103339. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  103340. */
  103341. export class PassCubePostProcess extends PostProcess {
  103342. private _face;
  103343. /**
  103344. * Gets or sets the cube face to display.
  103345. * * 0 is +X
  103346. * * 1 is -X
  103347. * * 2 is +Y
  103348. * * 3 is -Y
  103349. * * 4 is +Z
  103350. * * 5 is -Z
  103351. */
  103352. face: number;
  103353. /**
  103354. * Creates the PassCubePostProcess
  103355. * @param name The name of the effect.
  103356. * @param options The required width/height ratio to downsize to before computing the render pass.
  103357. * @param camera The camera to apply the render pass to.
  103358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103359. * @param engine The engine which the post process will be applied. (default: current engine)
  103360. * @param reusable If the post process can be reused on the same frame. (default: false)
  103361. * @param textureType The type of texture to be used when performing the post processing.
  103362. * @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)
  103363. */
  103364. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103365. }
  103366. }
  103367. declare module BABYLON {
  103368. /** @hidden */
  103369. export var anaglyphPixelShader: {
  103370. name: string;
  103371. shader: string;
  103372. };
  103373. }
  103374. declare module BABYLON {
  103375. /**
  103376. * Postprocess used to generate anaglyphic rendering
  103377. */
  103378. export class AnaglyphPostProcess extends PostProcess {
  103379. private _passedProcess;
  103380. /**
  103381. * Creates a new AnaglyphPostProcess
  103382. * @param name defines postprocess name
  103383. * @param options defines creation options or target ratio scale
  103384. * @param rigCameras defines cameras using this postprocess
  103385. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  103386. * @param engine defines hosting engine
  103387. * @param reusable defines if the postprocess will be reused multiple times per frame
  103388. */
  103389. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  103390. }
  103391. }
  103392. declare module BABYLON {
  103393. /**
  103394. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  103395. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103396. */
  103397. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  103398. /**
  103399. * Creates a new AnaglyphArcRotateCamera
  103400. * @param name defines camera name
  103401. * @param alpha defines alpha angle (in radians)
  103402. * @param beta defines beta angle (in radians)
  103403. * @param radius defines radius
  103404. * @param target defines camera target
  103405. * @param interaxialDistance defines distance between each color axis
  103406. * @param scene defines the hosting scene
  103407. */
  103408. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  103409. /**
  103410. * Gets camera class name
  103411. * @returns AnaglyphArcRotateCamera
  103412. */
  103413. getClassName(): string;
  103414. }
  103415. }
  103416. declare module BABYLON {
  103417. /**
  103418. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  103419. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103420. */
  103421. export class AnaglyphFreeCamera extends FreeCamera {
  103422. /**
  103423. * Creates a new AnaglyphFreeCamera
  103424. * @param name defines camera name
  103425. * @param position defines initial position
  103426. * @param interaxialDistance defines distance between each color axis
  103427. * @param scene defines the hosting scene
  103428. */
  103429. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103430. /**
  103431. * Gets camera class name
  103432. * @returns AnaglyphFreeCamera
  103433. */
  103434. getClassName(): string;
  103435. }
  103436. }
  103437. declare module BABYLON {
  103438. /**
  103439. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  103440. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103441. */
  103442. export class AnaglyphGamepadCamera extends GamepadCamera {
  103443. /**
  103444. * Creates a new AnaglyphGamepadCamera
  103445. * @param name defines camera name
  103446. * @param position defines initial position
  103447. * @param interaxialDistance defines distance between each color axis
  103448. * @param scene defines the hosting scene
  103449. */
  103450. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103451. /**
  103452. * Gets camera class name
  103453. * @returns AnaglyphGamepadCamera
  103454. */
  103455. getClassName(): string;
  103456. }
  103457. }
  103458. declare module BABYLON {
  103459. /**
  103460. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  103461. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103462. */
  103463. export class AnaglyphUniversalCamera extends UniversalCamera {
  103464. /**
  103465. * Creates a new AnaglyphUniversalCamera
  103466. * @param name defines camera name
  103467. * @param position defines initial position
  103468. * @param interaxialDistance defines distance between each color axis
  103469. * @param scene defines the hosting scene
  103470. */
  103471. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103472. /**
  103473. * Gets camera class name
  103474. * @returns AnaglyphUniversalCamera
  103475. */
  103476. getClassName(): string;
  103477. }
  103478. }
  103479. declare module BABYLON {
  103480. /** @hidden */
  103481. export var stereoscopicInterlacePixelShader: {
  103482. name: string;
  103483. shader: string;
  103484. };
  103485. }
  103486. declare module BABYLON {
  103487. /**
  103488. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  103489. */
  103490. export class StereoscopicInterlacePostProcess extends PostProcess {
  103491. private _stepSize;
  103492. private _passedProcess;
  103493. /**
  103494. * Initializes a StereoscopicInterlacePostProcess
  103495. * @param name The name of the effect.
  103496. * @param rigCameras The rig cameras to be appled to the post process
  103497. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  103498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103499. * @param engine The engine which the post process will be applied. (default: current engine)
  103500. * @param reusable If the post process can be reused on the same frame. (default: false)
  103501. */
  103502. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  103503. }
  103504. }
  103505. declare module BABYLON {
  103506. /**
  103507. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  103508. * @see http://doc.babylonjs.com/features/cameras
  103509. */
  103510. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  103511. /**
  103512. * Creates a new StereoscopicArcRotateCamera
  103513. * @param name defines camera name
  103514. * @param alpha defines alpha angle (in radians)
  103515. * @param beta defines beta angle (in radians)
  103516. * @param radius defines radius
  103517. * @param target defines camera target
  103518. * @param interaxialDistance defines distance between each color axis
  103519. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103520. * @param scene defines the hosting scene
  103521. */
  103522. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103523. /**
  103524. * Gets camera class name
  103525. * @returns StereoscopicArcRotateCamera
  103526. */
  103527. getClassName(): string;
  103528. }
  103529. }
  103530. declare module BABYLON {
  103531. /**
  103532. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  103533. * @see http://doc.babylonjs.com/features/cameras
  103534. */
  103535. export class StereoscopicFreeCamera extends FreeCamera {
  103536. /**
  103537. * Creates a new StereoscopicFreeCamera
  103538. * @param name defines camera name
  103539. * @param position defines initial position
  103540. * @param interaxialDistance defines distance between each color axis
  103541. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103542. * @param scene defines the hosting scene
  103543. */
  103544. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103545. /**
  103546. * Gets camera class name
  103547. * @returns StereoscopicFreeCamera
  103548. */
  103549. getClassName(): string;
  103550. }
  103551. }
  103552. declare module BABYLON {
  103553. /**
  103554. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  103555. * @see http://doc.babylonjs.com/features/cameras
  103556. */
  103557. export class StereoscopicGamepadCamera extends GamepadCamera {
  103558. /**
  103559. * Creates a new StereoscopicGamepadCamera
  103560. * @param name defines camera name
  103561. * @param position defines initial position
  103562. * @param interaxialDistance defines distance between each color axis
  103563. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103564. * @param scene defines the hosting scene
  103565. */
  103566. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103567. /**
  103568. * Gets camera class name
  103569. * @returns StereoscopicGamepadCamera
  103570. */
  103571. getClassName(): string;
  103572. }
  103573. }
  103574. declare module BABYLON {
  103575. /**
  103576. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  103577. * @see http://doc.babylonjs.com/features/cameras
  103578. */
  103579. export class StereoscopicUniversalCamera extends UniversalCamera {
  103580. /**
  103581. * Creates a new StereoscopicUniversalCamera
  103582. * @param name defines camera name
  103583. * @param position defines initial position
  103584. * @param interaxialDistance defines distance between each color axis
  103585. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103586. * @param scene defines the hosting scene
  103587. */
  103588. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103589. /**
  103590. * Gets camera class name
  103591. * @returns StereoscopicUniversalCamera
  103592. */
  103593. getClassName(): string;
  103594. }
  103595. }
  103596. declare module BABYLON {
  103597. /**
  103598. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  103599. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103600. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103601. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103602. */
  103603. export class VirtualJoysticksCamera extends FreeCamera {
  103604. /**
  103605. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  103606. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103607. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103608. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103609. * @param name Define the name of the camera in the scene
  103610. * @param position Define the start position of the camera in the scene
  103611. * @param scene Define the scene the camera belongs to
  103612. */
  103613. constructor(name: string, position: Vector3, scene: Scene);
  103614. /**
  103615. * Gets the current object class name.
  103616. * @return the class name
  103617. */
  103618. getClassName(): string;
  103619. }
  103620. }
  103621. declare module BABYLON {
  103622. /**
  103623. * This represents all the required metrics to create a VR camera.
  103624. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  103625. */
  103626. export class VRCameraMetrics {
  103627. /**
  103628. * Define the horizontal resolution off the screen.
  103629. */
  103630. hResolution: number;
  103631. /**
  103632. * Define the vertical resolution off the screen.
  103633. */
  103634. vResolution: number;
  103635. /**
  103636. * Define the horizontal screen size.
  103637. */
  103638. hScreenSize: number;
  103639. /**
  103640. * Define the vertical screen size.
  103641. */
  103642. vScreenSize: number;
  103643. /**
  103644. * Define the vertical screen center position.
  103645. */
  103646. vScreenCenter: number;
  103647. /**
  103648. * Define the distance of the eyes to the screen.
  103649. */
  103650. eyeToScreenDistance: number;
  103651. /**
  103652. * Define the distance between both lenses
  103653. */
  103654. lensSeparationDistance: number;
  103655. /**
  103656. * Define the distance between both viewer's eyes.
  103657. */
  103658. interpupillaryDistance: number;
  103659. /**
  103660. * Define the distortion factor of the VR postprocess.
  103661. * Please, touch with care.
  103662. */
  103663. distortionK: number[];
  103664. /**
  103665. * Define the chromatic aberration correction factors for the VR post process.
  103666. */
  103667. chromaAbCorrection: number[];
  103668. /**
  103669. * Define the scale factor of the post process.
  103670. * The smaller the better but the slower.
  103671. */
  103672. postProcessScaleFactor: number;
  103673. /**
  103674. * Define an offset for the lens center.
  103675. */
  103676. lensCenterOffset: number;
  103677. /**
  103678. * Define if the current vr camera should compensate the distortion of the lense or not.
  103679. */
  103680. compensateDistortion: boolean;
  103681. /**
  103682. * Defines if multiview should be enabled when rendering (Default: false)
  103683. */
  103684. multiviewEnabled: boolean;
  103685. /**
  103686. * Gets the rendering aspect ratio based on the provided resolutions.
  103687. */
  103688. readonly aspectRatio: number;
  103689. /**
  103690. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  103691. */
  103692. readonly aspectRatioFov: number;
  103693. /**
  103694. * @hidden
  103695. */
  103696. readonly leftHMatrix: Matrix;
  103697. /**
  103698. * @hidden
  103699. */
  103700. readonly rightHMatrix: Matrix;
  103701. /**
  103702. * @hidden
  103703. */
  103704. readonly leftPreViewMatrix: Matrix;
  103705. /**
  103706. * @hidden
  103707. */
  103708. readonly rightPreViewMatrix: Matrix;
  103709. /**
  103710. * Get the default VRMetrics based on the most generic setup.
  103711. * @returns the default vr metrics
  103712. */
  103713. static GetDefault(): VRCameraMetrics;
  103714. }
  103715. }
  103716. declare module BABYLON {
  103717. /** @hidden */
  103718. export var vrDistortionCorrectionPixelShader: {
  103719. name: string;
  103720. shader: string;
  103721. };
  103722. }
  103723. declare module BABYLON {
  103724. /**
  103725. * VRDistortionCorrectionPostProcess used for mobile VR
  103726. */
  103727. export class VRDistortionCorrectionPostProcess extends PostProcess {
  103728. private _isRightEye;
  103729. private _distortionFactors;
  103730. private _postProcessScaleFactor;
  103731. private _lensCenterOffset;
  103732. private _scaleIn;
  103733. private _scaleFactor;
  103734. private _lensCenter;
  103735. /**
  103736. * Initializes the VRDistortionCorrectionPostProcess
  103737. * @param name The name of the effect.
  103738. * @param camera The camera to apply the render pass to.
  103739. * @param isRightEye If this is for the right eye distortion
  103740. * @param vrMetrics All the required metrics for the VR camera
  103741. */
  103742. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  103743. }
  103744. }
  103745. declare module BABYLON {
  103746. /**
  103747. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  103748. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103749. */
  103750. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  103751. /**
  103752. * Creates a new VRDeviceOrientationArcRotateCamera
  103753. * @param name defines camera name
  103754. * @param alpha defines the camera rotation along the logitudinal axis
  103755. * @param beta defines the camera rotation along the latitudinal axis
  103756. * @param radius defines the camera distance from its target
  103757. * @param target defines the camera target
  103758. * @param scene defines the scene the camera belongs to
  103759. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103760. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103761. */
  103762. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103763. /**
  103764. * Gets camera class name
  103765. * @returns VRDeviceOrientationArcRotateCamera
  103766. */
  103767. getClassName(): string;
  103768. }
  103769. }
  103770. declare module BABYLON {
  103771. /**
  103772. * Camera used to simulate VR rendering (based on FreeCamera)
  103773. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103774. */
  103775. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  103776. /**
  103777. * Creates a new VRDeviceOrientationFreeCamera
  103778. * @param name defines camera name
  103779. * @param position defines the start position of the camera
  103780. * @param scene defines the scene the camera belongs to
  103781. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103782. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103783. */
  103784. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103785. /**
  103786. * Gets camera class name
  103787. * @returns VRDeviceOrientationFreeCamera
  103788. */
  103789. getClassName(): string;
  103790. }
  103791. }
  103792. declare module BABYLON {
  103793. /**
  103794. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  103795. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103796. */
  103797. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  103798. /**
  103799. * Creates a new VRDeviceOrientationGamepadCamera
  103800. * @param name defines camera name
  103801. * @param position defines the start position of the camera
  103802. * @param scene defines the scene the camera belongs to
  103803. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103804. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103805. */
  103806. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103807. /**
  103808. * Gets camera class name
  103809. * @returns VRDeviceOrientationGamepadCamera
  103810. */
  103811. getClassName(): string;
  103812. }
  103813. }
  103814. declare module BABYLON {
  103815. /**
  103816. * Base class of materials working in push mode in babylon JS
  103817. * @hidden
  103818. */
  103819. export class PushMaterial extends Material {
  103820. protected _activeEffect: Effect;
  103821. protected _normalMatrix: Matrix;
  103822. /**
  103823. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  103824. * This means that the material can keep using a previous shader while a new one is being compiled.
  103825. * This is mostly used when shader parallel compilation is supported (true by default)
  103826. */
  103827. allowShaderHotSwapping: boolean;
  103828. constructor(name: string, scene: Scene);
  103829. getEffect(): Effect;
  103830. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103831. /**
  103832. * Binds the given world matrix to the active effect
  103833. *
  103834. * @param world the matrix to bind
  103835. */
  103836. bindOnlyWorldMatrix(world: Matrix): void;
  103837. /**
  103838. * Binds the given normal matrix to the active effect
  103839. *
  103840. * @param normalMatrix the matrix to bind
  103841. */
  103842. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  103843. bind(world: Matrix, mesh?: Mesh): void;
  103844. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  103845. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  103846. }
  103847. }
  103848. declare module BABYLON {
  103849. /**
  103850. * This groups all the flags used to control the materials channel.
  103851. */
  103852. export class MaterialFlags {
  103853. private static _DiffuseTextureEnabled;
  103854. /**
  103855. * Are diffuse textures enabled in the application.
  103856. */
  103857. static DiffuseTextureEnabled: boolean;
  103858. private static _AmbientTextureEnabled;
  103859. /**
  103860. * Are ambient textures enabled in the application.
  103861. */
  103862. static AmbientTextureEnabled: boolean;
  103863. private static _OpacityTextureEnabled;
  103864. /**
  103865. * Are opacity textures enabled in the application.
  103866. */
  103867. static OpacityTextureEnabled: boolean;
  103868. private static _ReflectionTextureEnabled;
  103869. /**
  103870. * Are reflection textures enabled in the application.
  103871. */
  103872. static ReflectionTextureEnabled: boolean;
  103873. private static _EmissiveTextureEnabled;
  103874. /**
  103875. * Are emissive textures enabled in the application.
  103876. */
  103877. static EmissiveTextureEnabled: boolean;
  103878. private static _SpecularTextureEnabled;
  103879. /**
  103880. * Are specular textures enabled in the application.
  103881. */
  103882. static SpecularTextureEnabled: boolean;
  103883. private static _BumpTextureEnabled;
  103884. /**
  103885. * Are bump textures enabled in the application.
  103886. */
  103887. static BumpTextureEnabled: boolean;
  103888. private static _LightmapTextureEnabled;
  103889. /**
  103890. * Are lightmap textures enabled in the application.
  103891. */
  103892. static LightmapTextureEnabled: boolean;
  103893. private static _RefractionTextureEnabled;
  103894. /**
  103895. * Are refraction textures enabled in the application.
  103896. */
  103897. static RefractionTextureEnabled: boolean;
  103898. private static _ColorGradingTextureEnabled;
  103899. /**
  103900. * Are color grading textures enabled in the application.
  103901. */
  103902. static ColorGradingTextureEnabled: boolean;
  103903. private static _FresnelEnabled;
  103904. /**
  103905. * Are fresnels enabled in the application.
  103906. */
  103907. static FresnelEnabled: boolean;
  103908. private static _ClearCoatTextureEnabled;
  103909. /**
  103910. * Are clear coat textures enabled in the application.
  103911. */
  103912. static ClearCoatTextureEnabled: boolean;
  103913. private static _ClearCoatBumpTextureEnabled;
  103914. /**
  103915. * Are clear coat bump textures enabled in the application.
  103916. */
  103917. static ClearCoatBumpTextureEnabled: boolean;
  103918. private static _ClearCoatTintTextureEnabled;
  103919. /**
  103920. * Are clear coat tint textures enabled in the application.
  103921. */
  103922. static ClearCoatTintTextureEnabled: boolean;
  103923. private static _SheenTextureEnabled;
  103924. /**
  103925. * Are sheen textures enabled in the application.
  103926. */
  103927. static SheenTextureEnabled: boolean;
  103928. private static _AnisotropicTextureEnabled;
  103929. /**
  103930. * Are anisotropic textures enabled in the application.
  103931. */
  103932. static AnisotropicTextureEnabled: boolean;
  103933. private static _ThicknessTextureEnabled;
  103934. /**
  103935. * Are thickness textures enabled in the application.
  103936. */
  103937. static ThicknessTextureEnabled: boolean;
  103938. }
  103939. }
  103940. declare module BABYLON {
  103941. /** @hidden */
  103942. export var defaultFragmentDeclaration: {
  103943. name: string;
  103944. shader: string;
  103945. };
  103946. }
  103947. declare module BABYLON {
  103948. /** @hidden */
  103949. export var defaultUboDeclaration: {
  103950. name: string;
  103951. shader: string;
  103952. };
  103953. }
  103954. declare module BABYLON {
  103955. /** @hidden */
  103956. export var lightFragmentDeclaration: {
  103957. name: string;
  103958. shader: string;
  103959. };
  103960. }
  103961. declare module BABYLON {
  103962. /** @hidden */
  103963. export var lightUboDeclaration: {
  103964. name: string;
  103965. shader: string;
  103966. };
  103967. }
  103968. declare module BABYLON {
  103969. /** @hidden */
  103970. export var lightsFragmentFunctions: {
  103971. name: string;
  103972. shader: string;
  103973. };
  103974. }
  103975. declare module BABYLON {
  103976. /** @hidden */
  103977. export var shadowsFragmentFunctions: {
  103978. name: string;
  103979. shader: string;
  103980. };
  103981. }
  103982. declare module BABYLON {
  103983. /** @hidden */
  103984. export var fresnelFunction: {
  103985. name: string;
  103986. shader: string;
  103987. };
  103988. }
  103989. declare module BABYLON {
  103990. /** @hidden */
  103991. export var reflectionFunction: {
  103992. name: string;
  103993. shader: string;
  103994. };
  103995. }
  103996. declare module BABYLON {
  103997. /** @hidden */
  103998. export var bumpFragmentFunctions: {
  103999. name: string;
  104000. shader: string;
  104001. };
  104002. }
  104003. declare module BABYLON {
  104004. /** @hidden */
  104005. export var logDepthDeclaration: {
  104006. name: string;
  104007. shader: string;
  104008. };
  104009. }
  104010. declare module BABYLON {
  104011. /** @hidden */
  104012. export var bumpFragment: {
  104013. name: string;
  104014. shader: string;
  104015. };
  104016. }
  104017. declare module BABYLON {
  104018. /** @hidden */
  104019. export var depthPrePass: {
  104020. name: string;
  104021. shader: string;
  104022. };
  104023. }
  104024. declare module BABYLON {
  104025. /** @hidden */
  104026. export var lightFragment: {
  104027. name: string;
  104028. shader: string;
  104029. };
  104030. }
  104031. declare module BABYLON {
  104032. /** @hidden */
  104033. export var logDepthFragment: {
  104034. name: string;
  104035. shader: string;
  104036. };
  104037. }
  104038. declare module BABYLON {
  104039. /** @hidden */
  104040. export var defaultPixelShader: {
  104041. name: string;
  104042. shader: string;
  104043. };
  104044. }
  104045. declare module BABYLON {
  104046. /** @hidden */
  104047. export var defaultVertexDeclaration: {
  104048. name: string;
  104049. shader: string;
  104050. };
  104051. }
  104052. declare module BABYLON {
  104053. /** @hidden */
  104054. export var bumpVertexDeclaration: {
  104055. name: string;
  104056. shader: string;
  104057. };
  104058. }
  104059. declare module BABYLON {
  104060. /** @hidden */
  104061. export var bumpVertex: {
  104062. name: string;
  104063. shader: string;
  104064. };
  104065. }
  104066. declare module BABYLON {
  104067. /** @hidden */
  104068. export var fogVertex: {
  104069. name: string;
  104070. shader: string;
  104071. };
  104072. }
  104073. declare module BABYLON {
  104074. /** @hidden */
  104075. export var shadowsVertex: {
  104076. name: string;
  104077. shader: string;
  104078. };
  104079. }
  104080. declare module BABYLON {
  104081. /** @hidden */
  104082. export var pointCloudVertex: {
  104083. name: string;
  104084. shader: string;
  104085. };
  104086. }
  104087. declare module BABYLON {
  104088. /** @hidden */
  104089. export var logDepthVertex: {
  104090. name: string;
  104091. shader: string;
  104092. };
  104093. }
  104094. declare module BABYLON {
  104095. /** @hidden */
  104096. export var defaultVertexShader: {
  104097. name: string;
  104098. shader: string;
  104099. };
  104100. }
  104101. declare module BABYLON {
  104102. /** @hidden */
  104103. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  104104. MAINUV1: boolean;
  104105. MAINUV2: boolean;
  104106. DIFFUSE: boolean;
  104107. DIFFUSEDIRECTUV: number;
  104108. AMBIENT: boolean;
  104109. AMBIENTDIRECTUV: number;
  104110. OPACITY: boolean;
  104111. OPACITYDIRECTUV: number;
  104112. OPACITYRGB: boolean;
  104113. REFLECTION: boolean;
  104114. EMISSIVE: boolean;
  104115. EMISSIVEDIRECTUV: number;
  104116. SPECULAR: boolean;
  104117. SPECULARDIRECTUV: number;
  104118. BUMP: boolean;
  104119. BUMPDIRECTUV: number;
  104120. PARALLAX: boolean;
  104121. PARALLAXOCCLUSION: boolean;
  104122. SPECULAROVERALPHA: boolean;
  104123. CLIPPLANE: boolean;
  104124. CLIPPLANE2: boolean;
  104125. CLIPPLANE3: boolean;
  104126. CLIPPLANE4: boolean;
  104127. ALPHATEST: boolean;
  104128. DEPTHPREPASS: boolean;
  104129. ALPHAFROMDIFFUSE: boolean;
  104130. POINTSIZE: boolean;
  104131. FOG: boolean;
  104132. SPECULARTERM: boolean;
  104133. DIFFUSEFRESNEL: boolean;
  104134. OPACITYFRESNEL: boolean;
  104135. REFLECTIONFRESNEL: boolean;
  104136. REFRACTIONFRESNEL: boolean;
  104137. EMISSIVEFRESNEL: boolean;
  104138. FRESNEL: boolean;
  104139. NORMAL: boolean;
  104140. UV1: boolean;
  104141. UV2: boolean;
  104142. VERTEXCOLOR: boolean;
  104143. VERTEXALPHA: boolean;
  104144. NUM_BONE_INFLUENCERS: number;
  104145. BonesPerMesh: number;
  104146. BONETEXTURE: boolean;
  104147. INSTANCES: boolean;
  104148. GLOSSINESS: boolean;
  104149. ROUGHNESS: boolean;
  104150. EMISSIVEASILLUMINATION: boolean;
  104151. LINKEMISSIVEWITHDIFFUSE: boolean;
  104152. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104153. LIGHTMAP: boolean;
  104154. LIGHTMAPDIRECTUV: number;
  104155. OBJECTSPACE_NORMALMAP: boolean;
  104156. USELIGHTMAPASSHADOWMAP: boolean;
  104157. REFLECTIONMAP_3D: boolean;
  104158. REFLECTIONMAP_SPHERICAL: boolean;
  104159. REFLECTIONMAP_PLANAR: boolean;
  104160. REFLECTIONMAP_CUBIC: boolean;
  104161. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104162. REFLECTIONMAP_PROJECTION: boolean;
  104163. REFLECTIONMAP_SKYBOX: boolean;
  104164. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104165. REFLECTIONMAP_EXPLICIT: boolean;
  104166. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104167. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104168. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104169. INVERTCUBICMAP: boolean;
  104170. LOGARITHMICDEPTH: boolean;
  104171. REFRACTION: boolean;
  104172. REFRACTIONMAP_3D: boolean;
  104173. REFLECTIONOVERALPHA: boolean;
  104174. TWOSIDEDLIGHTING: boolean;
  104175. SHADOWFLOAT: boolean;
  104176. MORPHTARGETS: boolean;
  104177. MORPHTARGETS_NORMAL: boolean;
  104178. MORPHTARGETS_TANGENT: boolean;
  104179. MORPHTARGETS_UV: boolean;
  104180. NUM_MORPH_INFLUENCERS: number;
  104181. NONUNIFORMSCALING: boolean;
  104182. PREMULTIPLYALPHA: boolean;
  104183. IMAGEPROCESSING: boolean;
  104184. VIGNETTE: boolean;
  104185. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104186. VIGNETTEBLENDMODEOPAQUE: boolean;
  104187. TONEMAPPING: boolean;
  104188. TONEMAPPING_ACES: boolean;
  104189. CONTRAST: boolean;
  104190. COLORCURVES: boolean;
  104191. COLORGRADING: boolean;
  104192. COLORGRADING3D: boolean;
  104193. SAMPLER3DGREENDEPTH: boolean;
  104194. SAMPLER3DBGRMAP: boolean;
  104195. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104196. MULTIVIEW: boolean;
  104197. /**
  104198. * If the reflection texture on this material is in linear color space
  104199. * @hidden
  104200. */
  104201. IS_REFLECTION_LINEAR: boolean;
  104202. /**
  104203. * If the refraction texture on this material is in linear color space
  104204. * @hidden
  104205. */
  104206. IS_REFRACTION_LINEAR: boolean;
  104207. EXPOSURE: boolean;
  104208. constructor();
  104209. setReflectionMode(modeToEnable: string): void;
  104210. }
  104211. /**
  104212. * This is the default material used in Babylon. It is the best trade off between quality
  104213. * and performances.
  104214. * @see http://doc.babylonjs.com/babylon101/materials
  104215. */
  104216. export class StandardMaterial extends PushMaterial {
  104217. private _diffuseTexture;
  104218. /**
  104219. * The basic texture of the material as viewed under a light.
  104220. */
  104221. diffuseTexture: Nullable<BaseTexture>;
  104222. private _ambientTexture;
  104223. /**
  104224. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104225. */
  104226. ambientTexture: Nullable<BaseTexture>;
  104227. private _opacityTexture;
  104228. /**
  104229. * Define the transparency of the material from a texture.
  104230. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104231. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104232. */
  104233. opacityTexture: Nullable<BaseTexture>;
  104234. private _reflectionTexture;
  104235. /**
  104236. * Define the texture used to display the reflection.
  104237. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104238. */
  104239. reflectionTexture: Nullable<BaseTexture>;
  104240. private _emissiveTexture;
  104241. /**
  104242. * Define texture of the material as if self lit.
  104243. * This will be mixed in the final result even in the absence of light.
  104244. */
  104245. emissiveTexture: Nullable<BaseTexture>;
  104246. private _specularTexture;
  104247. /**
  104248. * Define how the color and intensity of the highlight given by the light in the material.
  104249. */
  104250. specularTexture: Nullable<BaseTexture>;
  104251. private _bumpTexture;
  104252. /**
  104253. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104254. * 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.
  104255. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  104256. */
  104257. bumpTexture: Nullable<BaseTexture>;
  104258. private _lightmapTexture;
  104259. /**
  104260. * Complex lighting can be computationally expensive to compute at runtime.
  104261. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104262. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  104263. */
  104264. lightmapTexture: Nullable<BaseTexture>;
  104265. private _refractionTexture;
  104266. /**
  104267. * Define the texture used to display the refraction.
  104268. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104269. */
  104270. refractionTexture: Nullable<BaseTexture>;
  104271. /**
  104272. * The color of the material lit by the environmental background lighting.
  104273. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104274. */
  104275. ambientColor: Color3;
  104276. /**
  104277. * The basic color of the material as viewed under a light.
  104278. */
  104279. diffuseColor: Color3;
  104280. /**
  104281. * Define how the color and intensity of the highlight given by the light in the material.
  104282. */
  104283. specularColor: Color3;
  104284. /**
  104285. * Define the color of the material as if self lit.
  104286. * This will be mixed in the final result even in the absence of light.
  104287. */
  104288. emissiveColor: Color3;
  104289. /**
  104290. * Defines how sharp are the highlights in the material.
  104291. * The bigger the value the sharper giving a more glossy feeling to the result.
  104292. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104293. */
  104294. specularPower: number;
  104295. private _useAlphaFromDiffuseTexture;
  104296. /**
  104297. * Does the transparency come from the diffuse texture alpha channel.
  104298. */
  104299. useAlphaFromDiffuseTexture: boolean;
  104300. private _useEmissiveAsIllumination;
  104301. /**
  104302. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104303. */
  104304. useEmissiveAsIllumination: boolean;
  104305. private _linkEmissiveWithDiffuse;
  104306. /**
  104307. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104308. * the emissive level when the final color is close to one.
  104309. */
  104310. linkEmissiveWithDiffuse: boolean;
  104311. private _useSpecularOverAlpha;
  104312. /**
  104313. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104314. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104315. */
  104316. useSpecularOverAlpha: boolean;
  104317. private _useReflectionOverAlpha;
  104318. /**
  104319. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104320. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104321. */
  104322. useReflectionOverAlpha: boolean;
  104323. private _disableLighting;
  104324. /**
  104325. * Does lights from the scene impacts this material.
  104326. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104327. */
  104328. disableLighting: boolean;
  104329. private _useObjectSpaceNormalMap;
  104330. /**
  104331. * Allows using an object space normal map (instead of tangent space).
  104332. */
  104333. useObjectSpaceNormalMap: boolean;
  104334. private _useParallax;
  104335. /**
  104336. * Is parallax enabled or not.
  104337. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104338. */
  104339. useParallax: boolean;
  104340. private _useParallaxOcclusion;
  104341. /**
  104342. * Is parallax occlusion enabled or not.
  104343. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104344. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104345. */
  104346. useParallaxOcclusion: boolean;
  104347. /**
  104348. * 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.
  104349. */
  104350. parallaxScaleBias: number;
  104351. private _roughness;
  104352. /**
  104353. * Helps to define how blurry the reflections should appears in the material.
  104354. */
  104355. roughness: number;
  104356. /**
  104357. * In case of refraction, define the value of the index of refraction.
  104358. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104359. */
  104360. indexOfRefraction: number;
  104361. /**
  104362. * Invert the refraction texture alongside the y axis.
  104363. * It can be useful with procedural textures or probe for instance.
  104364. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104365. */
  104366. invertRefractionY: boolean;
  104367. /**
  104368. * Defines the alpha limits in alpha test mode.
  104369. */
  104370. alphaCutOff: number;
  104371. private _useLightmapAsShadowmap;
  104372. /**
  104373. * In case of light mapping, define whether the map contains light or shadow informations.
  104374. */
  104375. useLightmapAsShadowmap: boolean;
  104376. private _diffuseFresnelParameters;
  104377. /**
  104378. * Define the diffuse fresnel parameters of the material.
  104379. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104380. */
  104381. diffuseFresnelParameters: FresnelParameters;
  104382. private _opacityFresnelParameters;
  104383. /**
  104384. * Define the opacity fresnel parameters of the material.
  104385. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104386. */
  104387. opacityFresnelParameters: FresnelParameters;
  104388. private _reflectionFresnelParameters;
  104389. /**
  104390. * Define the reflection fresnel parameters of the material.
  104391. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104392. */
  104393. reflectionFresnelParameters: FresnelParameters;
  104394. private _refractionFresnelParameters;
  104395. /**
  104396. * Define the refraction fresnel parameters of the material.
  104397. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104398. */
  104399. refractionFresnelParameters: FresnelParameters;
  104400. private _emissiveFresnelParameters;
  104401. /**
  104402. * Define the emissive fresnel parameters of the material.
  104403. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104404. */
  104405. emissiveFresnelParameters: FresnelParameters;
  104406. private _useReflectionFresnelFromSpecular;
  104407. /**
  104408. * If true automatically deducts the fresnels values from the material specularity.
  104409. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104410. */
  104411. useReflectionFresnelFromSpecular: boolean;
  104412. private _useGlossinessFromSpecularMapAlpha;
  104413. /**
  104414. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104415. */
  104416. useGlossinessFromSpecularMapAlpha: boolean;
  104417. private _maxSimultaneousLights;
  104418. /**
  104419. * Defines the maximum number of lights that can be used in the material
  104420. */
  104421. maxSimultaneousLights: number;
  104422. private _invertNormalMapX;
  104423. /**
  104424. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104425. */
  104426. invertNormalMapX: boolean;
  104427. private _invertNormalMapY;
  104428. /**
  104429. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104430. */
  104431. invertNormalMapY: boolean;
  104432. private _twoSidedLighting;
  104433. /**
  104434. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104435. */
  104436. twoSidedLighting: boolean;
  104437. /**
  104438. * Default configuration related to image processing available in the standard Material.
  104439. */
  104440. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104441. /**
  104442. * Gets the image processing configuration used either in this material.
  104443. */
  104444. /**
  104445. * Sets the Default image processing configuration used either in the this material.
  104446. *
  104447. * If sets to null, the scene one is in use.
  104448. */
  104449. imageProcessingConfiguration: ImageProcessingConfiguration;
  104450. /**
  104451. * Keep track of the image processing observer to allow dispose and replace.
  104452. */
  104453. private _imageProcessingObserver;
  104454. /**
  104455. * Attaches a new image processing configuration to the Standard Material.
  104456. * @param configuration
  104457. */
  104458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104459. /**
  104460. * Gets wether the color curves effect is enabled.
  104461. */
  104462. /**
  104463. * Sets wether the color curves effect is enabled.
  104464. */
  104465. cameraColorCurvesEnabled: boolean;
  104466. /**
  104467. * Gets wether the color grading effect is enabled.
  104468. */
  104469. /**
  104470. * Gets wether the color grading effect is enabled.
  104471. */
  104472. cameraColorGradingEnabled: boolean;
  104473. /**
  104474. * Gets wether tonemapping is enabled or not.
  104475. */
  104476. /**
  104477. * Sets wether tonemapping is enabled or not
  104478. */
  104479. cameraToneMappingEnabled: boolean;
  104480. /**
  104481. * The camera exposure used on this material.
  104482. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104483. * This corresponds to a photographic exposure.
  104484. */
  104485. /**
  104486. * The camera exposure used on this material.
  104487. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104488. * This corresponds to a photographic exposure.
  104489. */
  104490. cameraExposure: number;
  104491. /**
  104492. * Gets The camera contrast used on this material.
  104493. */
  104494. /**
  104495. * Sets The camera contrast used on this material.
  104496. */
  104497. cameraContrast: number;
  104498. /**
  104499. * Gets the Color Grading 2D Lookup Texture.
  104500. */
  104501. /**
  104502. * Sets the Color Grading 2D Lookup Texture.
  104503. */
  104504. cameraColorGradingTexture: Nullable<BaseTexture>;
  104505. /**
  104506. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104507. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104508. * 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;
  104509. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104510. */
  104511. /**
  104512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104514. * 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;
  104515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104516. */
  104517. cameraColorCurves: Nullable<ColorCurves>;
  104518. /**
  104519. * Custom callback helping to override the default shader used in the material.
  104520. */
  104521. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  104522. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104523. protected _worldViewProjectionMatrix: Matrix;
  104524. protected _globalAmbientColor: Color3;
  104525. protected _useLogarithmicDepth: boolean;
  104526. /**
  104527. * Instantiates a new standard material.
  104528. * This is the default material used in Babylon. It is the best trade off between quality
  104529. * and performances.
  104530. * @see http://doc.babylonjs.com/babylon101/materials
  104531. * @param name Define the name of the material in the scene
  104532. * @param scene Define the scene the material belong to
  104533. */
  104534. constructor(name: string, scene: Scene);
  104535. /**
  104536. * Gets a boolean indicating that current material needs to register RTT
  104537. */
  104538. readonly hasRenderTargetTextures: boolean;
  104539. /**
  104540. * Gets the current class name of the material e.g. "StandardMaterial"
  104541. * Mainly use in serialization.
  104542. * @returns the class name
  104543. */
  104544. getClassName(): string;
  104545. /**
  104546. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104547. * You can try switching to logarithmic depth.
  104548. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104549. */
  104550. useLogarithmicDepth: boolean;
  104551. /**
  104552. * Specifies if the material will require alpha blending
  104553. * @returns a boolean specifying if alpha blending is needed
  104554. */
  104555. needAlphaBlending(): boolean;
  104556. /**
  104557. * Specifies if this material should be rendered in alpha test mode
  104558. * @returns a boolean specifying if an alpha test is needed.
  104559. */
  104560. needAlphaTesting(): boolean;
  104561. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104562. /**
  104563. * Get the texture used for alpha test purpose.
  104564. * @returns the diffuse texture in case of the standard material.
  104565. */
  104566. getAlphaTestTexture(): Nullable<BaseTexture>;
  104567. /**
  104568. * Get if the submesh is ready to be used and all its information available.
  104569. * Child classes can use it to update shaders
  104570. * @param mesh defines the mesh to check
  104571. * @param subMesh defines which submesh to check
  104572. * @param useInstances specifies that instances should be used
  104573. * @returns a boolean indicating that the submesh is ready or not
  104574. */
  104575. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104576. /**
  104577. * Builds the material UBO layouts.
  104578. * Used internally during the effect preparation.
  104579. */
  104580. buildUniformLayout(): void;
  104581. /**
  104582. * Unbinds the material from the mesh
  104583. */
  104584. unbind(): void;
  104585. /**
  104586. * Binds the submesh to this material by preparing the effect and shader to draw
  104587. * @param world defines the world transformation matrix
  104588. * @param mesh defines the mesh containing the submesh
  104589. * @param subMesh defines the submesh to bind the material to
  104590. */
  104591. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104592. /**
  104593. * Get the list of animatables in the material.
  104594. * @returns the list of animatables object used in the material
  104595. */
  104596. getAnimatables(): IAnimatable[];
  104597. /**
  104598. * Gets the active textures from the material
  104599. * @returns an array of textures
  104600. */
  104601. getActiveTextures(): BaseTexture[];
  104602. /**
  104603. * Specifies if the material uses a texture
  104604. * @param texture defines the texture to check against the material
  104605. * @returns a boolean specifying if the material uses the texture
  104606. */
  104607. hasTexture(texture: BaseTexture): boolean;
  104608. /**
  104609. * Disposes the material
  104610. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104611. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104612. */
  104613. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104614. /**
  104615. * Makes a duplicate of the material, and gives it a new name
  104616. * @param name defines the new name for the duplicated material
  104617. * @returns the cloned material
  104618. */
  104619. clone(name: string): StandardMaterial;
  104620. /**
  104621. * Serializes this material in a JSON representation
  104622. * @returns the serialized material object
  104623. */
  104624. serialize(): any;
  104625. /**
  104626. * Creates a standard material from parsed material data
  104627. * @param source defines the JSON representation of the material
  104628. * @param scene defines the hosting scene
  104629. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104630. * @returns a new standard material
  104631. */
  104632. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104633. /**
  104634. * Are diffuse textures enabled in the application.
  104635. */
  104636. static DiffuseTextureEnabled: boolean;
  104637. /**
  104638. * Are ambient textures enabled in the application.
  104639. */
  104640. static AmbientTextureEnabled: boolean;
  104641. /**
  104642. * Are opacity textures enabled in the application.
  104643. */
  104644. static OpacityTextureEnabled: boolean;
  104645. /**
  104646. * Are reflection textures enabled in the application.
  104647. */
  104648. static ReflectionTextureEnabled: boolean;
  104649. /**
  104650. * Are emissive textures enabled in the application.
  104651. */
  104652. static EmissiveTextureEnabled: boolean;
  104653. /**
  104654. * Are specular textures enabled in the application.
  104655. */
  104656. static SpecularTextureEnabled: boolean;
  104657. /**
  104658. * Are bump textures enabled in the application.
  104659. */
  104660. static BumpTextureEnabled: boolean;
  104661. /**
  104662. * Are lightmap textures enabled in the application.
  104663. */
  104664. static LightmapTextureEnabled: boolean;
  104665. /**
  104666. * Are refraction textures enabled in the application.
  104667. */
  104668. static RefractionTextureEnabled: boolean;
  104669. /**
  104670. * Are color grading textures enabled in the application.
  104671. */
  104672. static ColorGradingTextureEnabled: boolean;
  104673. /**
  104674. * Are fresnels enabled in the application.
  104675. */
  104676. static FresnelEnabled: boolean;
  104677. }
  104678. }
  104679. declare module BABYLON {
  104680. /**
  104681. * A class extending Texture allowing drawing on a texture
  104682. * @see http://doc.babylonjs.com/how_to/dynamictexture
  104683. */
  104684. export class DynamicTexture extends Texture {
  104685. private _generateMipMaps;
  104686. private _canvas;
  104687. private _context;
  104688. private _engine;
  104689. /**
  104690. * Creates a DynamicTexture
  104691. * @param name defines the name of the texture
  104692. * @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
  104693. * @param scene defines the scene where you want the texture
  104694. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  104695. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  104696. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  104697. */
  104698. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  104699. /**
  104700. * Get the current class name of the texture useful for serialization or dynamic coding.
  104701. * @returns "DynamicTexture"
  104702. */
  104703. getClassName(): string;
  104704. /**
  104705. * Gets the current state of canRescale
  104706. */
  104707. readonly canRescale: boolean;
  104708. private _recreate;
  104709. /**
  104710. * Scales the texture
  104711. * @param ratio the scale factor to apply to both width and height
  104712. */
  104713. scale(ratio: number): void;
  104714. /**
  104715. * Resizes the texture
  104716. * @param width the new width
  104717. * @param height the new height
  104718. */
  104719. scaleTo(width: number, height: number): void;
  104720. /**
  104721. * Gets the context of the canvas used by the texture
  104722. * @returns the canvas context of the dynamic texture
  104723. */
  104724. getContext(): CanvasRenderingContext2D;
  104725. /**
  104726. * Clears the texture
  104727. */
  104728. clear(): void;
  104729. /**
  104730. * Updates the texture
  104731. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104732. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  104733. */
  104734. update(invertY?: boolean, premulAlpha?: boolean): void;
  104735. /**
  104736. * Draws text onto the texture
  104737. * @param text defines the text to be drawn
  104738. * @param x defines the placement of the text from the left
  104739. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  104740. * @param font defines the font to be used with font-style, font-size, font-name
  104741. * @param color defines the color used for the text
  104742. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  104743. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104744. * @param update defines whether texture is immediately update (default is true)
  104745. */
  104746. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  104747. /**
  104748. * Clones the texture
  104749. * @returns the clone of the texture.
  104750. */
  104751. clone(): DynamicTexture;
  104752. /**
  104753. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  104754. * @returns a serialized dynamic texture object
  104755. */
  104756. serialize(): any;
  104757. /** @hidden */
  104758. _rebuild(): void;
  104759. }
  104760. }
  104761. declare module BABYLON {
  104762. /** @hidden */
  104763. export var imageProcessingPixelShader: {
  104764. name: string;
  104765. shader: string;
  104766. };
  104767. }
  104768. declare module BABYLON {
  104769. /**
  104770. * ImageProcessingPostProcess
  104771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104772. */
  104773. export class ImageProcessingPostProcess extends PostProcess {
  104774. /**
  104775. * Default configuration related to image processing available in the PBR Material.
  104776. */
  104777. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104778. /**
  104779. * Gets the image processing configuration used either in this material.
  104780. */
  104781. /**
  104782. * Sets the Default image processing configuration used either in the this material.
  104783. *
  104784. * If sets to null, the scene one is in use.
  104785. */
  104786. imageProcessingConfiguration: ImageProcessingConfiguration;
  104787. /**
  104788. * Keep track of the image processing observer to allow dispose and replace.
  104789. */
  104790. private _imageProcessingObserver;
  104791. /**
  104792. * Attaches a new image processing configuration to the PBR Material.
  104793. * @param configuration
  104794. */
  104795. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104796. /**
  104797. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104798. */
  104799. /**
  104800. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104801. */
  104802. colorCurves: Nullable<ColorCurves>;
  104803. /**
  104804. * Gets wether the color curves effect is enabled.
  104805. */
  104806. /**
  104807. * Sets wether the color curves effect is enabled.
  104808. */
  104809. colorCurvesEnabled: boolean;
  104810. /**
  104811. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104812. */
  104813. /**
  104814. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104815. */
  104816. colorGradingTexture: Nullable<BaseTexture>;
  104817. /**
  104818. * Gets wether the color grading effect is enabled.
  104819. */
  104820. /**
  104821. * Gets wether the color grading effect is enabled.
  104822. */
  104823. colorGradingEnabled: boolean;
  104824. /**
  104825. * Gets exposure used in the effect.
  104826. */
  104827. /**
  104828. * Sets exposure used in the effect.
  104829. */
  104830. exposure: number;
  104831. /**
  104832. * Gets wether tonemapping is enabled or not.
  104833. */
  104834. /**
  104835. * Sets wether tonemapping is enabled or not
  104836. */
  104837. toneMappingEnabled: boolean;
  104838. /**
  104839. * Gets the type of tone mapping effect.
  104840. */
  104841. /**
  104842. * Sets the type of tone mapping effect.
  104843. */
  104844. toneMappingType: number;
  104845. /**
  104846. * Gets contrast used in the effect.
  104847. */
  104848. /**
  104849. * Sets contrast used in the effect.
  104850. */
  104851. contrast: number;
  104852. /**
  104853. * Gets Vignette stretch size.
  104854. */
  104855. /**
  104856. * Sets Vignette stretch size.
  104857. */
  104858. vignetteStretch: number;
  104859. /**
  104860. * Gets Vignette centre X Offset.
  104861. */
  104862. /**
  104863. * Sets Vignette centre X Offset.
  104864. */
  104865. vignetteCentreX: number;
  104866. /**
  104867. * Gets Vignette centre Y Offset.
  104868. */
  104869. /**
  104870. * Sets Vignette centre Y Offset.
  104871. */
  104872. vignetteCentreY: number;
  104873. /**
  104874. * Gets Vignette weight or intensity of the vignette effect.
  104875. */
  104876. /**
  104877. * Sets Vignette weight or intensity of the vignette effect.
  104878. */
  104879. vignetteWeight: number;
  104880. /**
  104881. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104882. * if vignetteEnabled is set to true.
  104883. */
  104884. /**
  104885. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104886. * if vignetteEnabled is set to true.
  104887. */
  104888. vignetteColor: Color4;
  104889. /**
  104890. * Gets Camera field of view used by the Vignette effect.
  104891. */
  104892. /**
  104893. * Sets Camera field of view used by the Vignette effect.
  104894. */
  104895. vignetteCameraFov: number;
  104896. /**
  104897. * Gets the vignette blend mode allowing different kind of effect.
  104898. */
  104899. /**
  104900. * Sets the vignette blend mode allowing different kind of effect.
  104901. */
  104902. vignetteBlendMode: number;
  104903. /**
  104904. * Gets wether the vignette effect is enabled.
  104905. */
  104906. /**
  104907. * Sets wether the vignette effect is enabled.
  104908. */
  104909. vignetteEnabled: boolean;
  104910. private _fromLinearSpace;
  104911. /**
  104912. * Gets wether the input of the processing is in Gamma or Linear Space.
  104913. */
  104914. /**
  104915. * Sets wether the input of the processing is in Gamma or Linear Space.
  104916. */
  104917. fromLinearSpace: boolean;
  104918. /**
  104919. * Defines cache preventing GC.
  104920. */
  104921. private _defines;
  104922. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104923. /**
  104924. * "ImageProcessingPostProcess"
  104925. * @returns "ImageProcessingPostProcess"
  104926. */
  104927. getClassName(): string;
  104928. protected _updateParameters(): void;
  104929. dispose(camera?: Camera): void;
  104930. }
  104931. }
  104932. declare module BABYLON {
  104933. /**
  104934. * Class containing static functions to help procedurally build meshes
  104935. */
  104936. export class GroundBuilder {
  104937. /**
  104938. * Creates a ground mesh
  104939. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104940. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104942. * @param name defines the name of the mesh
  104943. * @param options defines the options used to create the mesh
  104944. * @param scene defines the hosting scene
  104945. * @returns the ground mesh
  104946. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104947. */
  104948. static CreateGround(name: string, options: {
  104949. width?: number;
  104950. height?: number;
  104951. subdivisions?: number;
  104952. subdivisionsX?: number;
  104953. subdivisionsY?: number;
  104954. updatable?: boolean;
  104955. }, scene: any): Mesh;
  104956. /**
  104957. * Creates a tiled ground mesh
  104958. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104959. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104960. * * 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
  104961. * * 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
  104962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104963. * @param name defines the name of the mesh
  104964. * @param options defines the options used to create the mesh
  104965. * @param scene defines the hosting scene
  104966. * @returns the tiled ground mesh
  104967. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104968. */
  104969. static CreateTiledGround(name: string, options: {
  104970. xmin: number;
  104971. zmin: number;
  104972. xmax: number;
  104973. zmax: number;
  104974. subdivisions?: {
  104975. w: number;
  104976. h: number;
  104977. };
  104978. precision?: {
  104979. w: number;
  104980. h: number;
  104981. };
  104982. updatable?: boolean;
  104983. }, scene?: Nullable<Scene>): Mesh;
  104984. /**
  104985. * Creates a ground mesh from a height map
  104986. * * The parameter `url` sets the URL of the height map image resource.
  104987. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104988. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104989. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104990. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104991. * * 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.
  104992. * * 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).
  104993. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104995. * @param name defines the name of the mesh
  104996. * @param url defines the url to the height map
  104997. * @param options defines the options used to create the mesh
  104998. * @param scene defines the hosting scene
  104999. * @returns the ground mesh
  105000. * @see https://doc.babylonjs.com/babylon101/height_map
  105001. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105002. */
  105003. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105004. width?: number;
  105005. height?: number;
  105006. subdivisions?: number;
  105007. minHeight?: number;
  105008. maxHeight?: number;
  105009. colorFilter?: Color3;
  105010. alphaFilter?: number;
  105011. updatable?: boolean;
  105012. onReady?: (mesh: GroundMesh) => void;
  105013. }, scene?: Nullable<Scene>): GroundMesh;
  105014. }
  105015. }
  105016. declare module BABYLON {
  105017. /**
  105018. * Class containing static functions to help procedurally build meshes
  105019. */
  105020. export class TorusBuilder {
  105021. /**
  105022. * Creates a torus mesh
  105023. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105024. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105025. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105029. * @param name defines the name of the mesh
  105030. * @param options defines the options used to create the mesh
  105031. * @param scene defines the hosting scene
  105032. * @returns the torus mesh
  105033. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105034. */
  105035. static CreateTorus(name: string, options: {
  105036. diameter?: number;
  105037. thickness?: number;
  105038. tessellation?: number;
  105039. updatable?: boolean;
  105040. sideOrientation?: number;
  105041. frontUVs?: Vector4;
  105042. backUVs?: Vector4;
  105043. }, scene: any): Mesh;
  105044. }
  105045. }
  105046. declare module BABYLON {
  105047. /**
  105048. * Class containing static functions to help procedurally build meshes
  105049. */
  105050. export class CylinderBuilder {
  105051. /**
  105052. * Creates a cylinder or a cone mesh
  105053. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105054. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105055. * * 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.
  105056. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105057. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105058. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105059. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105060. * * 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).
  105061. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105062. * * 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).
  105063. * * 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
  105064. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105065. * * 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
  105066. * * 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.
  105067. * * If `enclose` is false, a ring surface is one element.
  105068. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105069. * * 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
  105070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105071. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105073. * @param name defines the name of the mesh
  105074. * @param options defines the options used to create the mesh
  105075. * @param scene defines the hosting scene
  105076. * @returns the cylinder mesh
  105077. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105078. */
  105079. static CreateCylinder(name: string, options: {
  105080. height?: number;
  105081. diameterTop?: number;
  105082. diameterBottom?: number;
  105083. diameter?: number;
  105084. tessellation?: number;
  105085. subdivisions?: number;
  105086. arc?: number;
  105087. faceColors?: Color4[];
  105088. faceUV?: Vector4[];
  105089. updatable?: boolean;
  105090. hasRings?: boolean;
  105091. enclose?: boolean;
  105092. cap?: number;
  105093. sideOrientation?: number;
  105094. frontUVs?: Vector4;
  105095. backUVs?: Vector4;
  105096. }, scene: any): Mesh;
  105097. }
  105098. }
  105099. declare module BABYLON {
  105100. /**
  105101. * Options to modify the vr teleportation behavior.
  105102. */
  105103. export interface VRTeleportationOptions {
  105104. /**
  105105. * The name of the mesh which should be used as the teleportation floor. (default: null)
  105106. */
  105107. floorMeshName?: string;
  105108. /**
  105109. * A list of meshes to be used as the teleportation floor. (default: empty)
  105110. */
  105111. floorMeshes?: Mesh[];
  105112. }
  105113. /**
  105114. * Options to modify the vr experience helper's behavior.
  105115. */
  105116. export interface VRExperienceHelperOptions extends WebVROptions {
  105117. /**
  105118. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  105119. */
  105120. createDeviceOrientationCamera?: boolean;
  105121. /**
  105122. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  105123. */
  105124. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  105125. /**
  105126. * Uses the main button on the controller to toggle the laser casted. (default: true)
  105127. */
  105128. laserToggle?: boolean;
  105129. /**
  105130. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  105131. */
  105132. floorMeshes?: Mesh[];
  105133. /**
  105134. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  105135. */
  105136. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  105137. }
  105138. /**
  105139. * Event containing information after VR has been entered
  105140. */
  105141. export class OnAfterEnteringVRObservableEvent {
  105142. /**
  105143. * If entering vr was successful
  105144. */
  105145. success: boolean;
  105146. }
  105147. /**
  105148. * Helps to quickly add VR support to an existing scene.
  105149. * See http://doc.babylonjs.com/how_to/webvr_helper
  105150. */
  105151. export class VRExperienceHelper {
  105152. /** Options to modify the vr experience helper's behavior. */
  105153. webVROptions: VRExperienceHelperOptions;
  105154. private _scene;
  105155. private _position;
  105156. private _btnVR;
  105157. private _btnVRDisplayed;
  105158. private _webVRsupported;
  105159. private _webVRready;
  105160. private _webVRrequesting;
  105161. private _webVRpresenting;
  105162. private _hasEnteredVR;
  105163. private _fullscreenVRpresenting;
  105164. private _canvas;
  105165. private _webVRCamera;
  105166. private _vrDeviceOrientationCamera;
  105167. private _deviceOrientationCamera;
  105168. private _existingCamera;
  105169. private _onKeyDown;
  105170. private _onVrDisplayPresentChange;
  105171. private _onVRDisplayChanged;
  105172. private _onVRRequestPresentStart;
  105173. private _onVRRequestPresentComplete;
  105174. /**
  105175. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  105176. */
  105177. enableGazeEvenWhenNoPointerLock: boolean;
  105178. /**
  105179. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  105180. */
  105181. exitVROnDoubleTap: boolean;
  105182. /**
  105183. * Observable raised right before entering VR.
  105184. */
  105185. onEnteringVRObservable: Observable<VRExperienceHelper>;
  105186. /**
  105187. * Observable raised when entering VR has completed.
  105188. */
  105189. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  105190. /**
  105191. * Observable raised when exiting VR.
  105192. */
  105193. onExitingVRObservable: Observable<VRExperienceHelper>;
  105194. /**
  105195. * Observable raised when controller mesh is loaded.
  105196. */
  105197. onControllerMeshLoadedObservable: Observable<WebVRController>;
  105198. /** Return this.onEnteringVRObservable
  105199. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  105200. */
  105201. readonly onEnteringVR: Observable<VRExperienceHelper>;
  105202. /** Return this.onExitingVRObservable
  105203. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  105204. */
  105205. readonly onExitingVR: Observable<VRExperienceHelper>;
  105206. /** Return this.onControllerMeshLoadedObservable
  105207. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  105208. */
  105209. readonly onControllerMeshLoaded: Observable<WebVRController>;
  105210. private _rayLength;
  105211. private _useCustomVRButton;
  105212. private _teleportationRequested;
  105213. private _teleportActive;
  105214. private _floorMeshName;
  105215. private _floorMeshesCollection;
  105216. private _rotationAllowed;
  105217. private _teleportBackwardsVector;
  105218. private _teleportationTarget;
  105219. private _isDefaultTeleportationTarget;
  105220. private _postProcessMove;
  105221. private _teleportationFillColor;
  105222. private _teleportationBorderColor;
  105223. private _rotationAngle;
  105224. private _haloCenter;
  105225. private _cameraGazer;
  105226. private _padSensibilityUp;
  105227. private _padSensibilityDown;
  105228. private _leftController;
  105229. private _rightController;
  105230. /**
  105231. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  105232. */
  105233. onNewMeshSelected: Observable<AbstractMesh>;
  105234. /**
  105235. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  105236. */
  105237. onNewMeshPicked: Observable<PickingInfo>;
  105238. private _circleEase;
  105239. /**
  105240. * Observable raised before camera teleportation
  105241. */
  105242. onBeforeCameraTeleport: Observable<Vector3>;
  105243. /**
  105244. * Observable raised after camera teleportation
  105245. */
  105246. onAfterCameraTeleport: Observable<Vector3>;
  105247. /**
  105248. * Observable raised when current selected mesh gets unselected
  105249. */
  105250. onSelectedMeshUnselected: Observable<AbstractMesh>;
  105251. private _raySelectionPredicate;
  105252. /**
  105253. * To be optionaly changed by user to define custom ray selection
  105254. */
  105255. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  105256. /**
  105257. * To be optionaly changed by user to define custom selection logic (after ray selection)
  105258. */
  105259. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105260. /**
  105261. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  105262. */
  105263. teleportationEnabled: boolean;
  105264. private _defaultHeight;
  105265. private _teleportationInitialized;
  105266. private _interactionsEnabled;
  105267. private _interactionsRequested;
  105268. private _displayGaze;
  105269. private _displayLaserPointer;
  105270. /**
  105271. * The mesh used to display where the user is going to teleport.
  105272. */
  105273. /**
  105274. * Sets the mesh to be used to display where the user is going to teleport.
  105275. */
  105276. teleportationTarget: Mesh;
  105277. /**
  105278. * 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
  105279. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  105280. * See http://doc.babylonjs.com/resources/baking_transformations
  105281. */
  105282. gazeTrackerMesh: Mesh;
  105283. /**
  105284. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  105285. */
  105286. updateGazeTrackerScale: boolean;
  105287. /**
  105288. * If the gaze trackers color should be updated when selecting meshes
  105289. */
  105290. updateGazeTrackerColor: boolean;
  105291. /**
  105292. * The gaze tracking mesh corresponding to the left controller
  105293. */
  105294. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  105295. /**
  105296. * The gaze tracking mesh corresponding to the right controller
  105297. */
  105298. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  105299. /**
  105300. * If the ray of the gaze should be displayed.
  105301. */
  105302. /**
  105303. * Sets if the ray of the gaze should be displayed.
  105304. */
  105305. displayGaze: boolean;
  105306. /**
  105307. * If the ray of the LaserPointer should be displayed.
  105308. */
  105309. /**
  105310. * Sets if the ray of the LaserPointer should be displayed.
  105311. */
  105312. displayLaserPointer: boolean;
  105313. /**
  105314. * The deviceOrientationCamera used as the camera when not in VR.
  105315. */
  105316. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  105317. /**
  105318. * Based on the current WebVR support, returns the current VR camera used.
  105319. */
  105320. readonly currentVRCamera: Nullable<Camera>;
  105321. /**
  105322. * The webVRCamera which is used when in VR.
  105323. */
  105324. readonly webVRCamera: WebVRFreeCamera;
  105325. /**
  105326. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  105327. */
  105328. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  105329. /**
  105330. * The html button that is used to trigger entering into VR.
  105331. */
  105332. readonly vrButton: Nullable<HTMLButtonElement>;
  105333. private readonly _teleportationRequestInitiated;
  105334. /**
  105335. * Defines wether or not Pointer lock should be requested when switching to
  105336. * full screen.
  105337. */
  105338. requestPointerLockOnFullScreen: boolean;
  105339. /**
  105340. * Instantiates a VRExperienceHelper.
  105341. * Helps to quickly add VR support to an existing scene.
  105342. * @param scene The scene the VRExperienceHelper belongs to.
  105343. * @param webVROptions Options to modify the vr experience helper's behavior.
  105344. */
  105345. constructor(scene: Scene,
  105346. /** Options to modify the vr experience helper's behavior. */
  105347. webVROptions?: VRExperienceHelperOptions);
  105348. private _onDefaultMeshLoaded;
  105349. private _onResize;
  105350. private _onFullscreenChange;
  105351. /**
  105352. * Gets a value indicating if we are currently in VR mode.
  105353. */
  105354. readonly isInVRMode: boolean;
  105355. private onVrDisplayPresentChange;
  105356. private onVRDisplayChanged;
  105357. private moveButtonToBottomRight;
  105358. private displayVRButton;
  105359. private updateButtonVisibility;
  105360. private _cachedAngularSensibility;
  105361. /**
  105362. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  105363. * Otherwise, will use the fullscreen API.
  105364. */
  105365. enterVR(): void;
  105366. /**
  105367. * Attempt to exit VR, or fullscreen.
  105368. */
  105369. exitVR(): void;
  105370. /**
  105371. * The position of the vr experience helper.
  105372. */
  105373. /**
  105374. * Sets the position of the vr experience helper.
  105375. */
  105376. position: Vector3;
  105377. /**
  105378. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  105379. */
  105380. enableInteractions(): void;
  105381. private readonly _noControllerIsActive;
  105382. private beforeRender;
  105383. private _isTeleportationFloor;
  105384. /**
  105385. * Adds a floor mesh to be used for teleportation.
  105386. * @param floorMesh the mesh to be used for teleportation.
  105387. */
  105388. addFloorMesh(floorMesh: Mesh): void;
  105389. /**
  105390. * Removes a floor mesh from being used for teleportation.
  105391. * @param floorMesh the mesh to be removed.
  105392. */
  105393. removeFloorMesh(floorMesh: Mesh): void;
  105394. /**
  105395. * Enables interactions and teleportation using the VR controllers and gaze.
  105396. * @param vrTeleportationOptions options to modify teleportation behavior.
  105397. */
  105398. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  105399. private _onNewGamepadConnected;
  105400. private _tryEnableInteractionOnController;
  105401. private _onNewGamepadDisconnected;
  105402. private _enableInteractionOnController;
  105403. private _checkTeleportWithRay;
  105404. private _checkRotate;
  105405. private _checkTeleportBackwards;
  105406. private _enableTeleportationOnController;
  105407. private _createTeleportationCircles;
  105408. private _displayTeleportationTarget;
  105409. private _hideTeleportationTarget;
  105410. private _rotateCamera;
  105411. private _moveTeleportationSelectorTo;
  105412. private _workingVector;
  105413. private _workingQuaternion;
  105414. private _workingMatrix;
  105415. /**
  105416. * Teleports the users feet to the desired location
  105417. * @param location The location where the user's feet should be placed
  105418. */
  105419. teleportCamera(location: Vector3): void;
  105420. private _convertNormalToDirectionOfRay;
  105421. private _castRayAndSelectObject;
  105422. private _notifySelectedMeshUnselected;
  105423. /**
  105424. * Sets the color of the laser ray from the vr controllers.
  105425. * @param color new color for the ray.
  105426. */
  105427. changeLaserColor(color: Color3): void;
  105428. /**
  105429. * Sets the color of the ray from the vr headsets gaze.
  105430. * @param color new color for the ray.
  105431. */
  105432. changeGazeColor(color: Color3): void;
  105433. /**
  105434. * Exits VR and disposes of the vr experience helper
  105435. */
  105436. dispose(): void;
  105437. /**
  105438. * Gets the name of the VRExperienceHelper class
  105439. * @returns "VRExperienceHelper"
  105440. */
  105441. getClassName(): string;
  105442. }
  105443. }
  105444. declare module BABYLON {
  105445. /**
  105446. * Manages an XRSession to work with Babylon's engine
  105447. * @see https://doc.babylonjs.com/how_to/webxr
  105448. */
  105449. export class WebXRSessionManager implements IDisposable {
  105450. private scene;
  105451. /**
  105452. * Fires every time a new xrFrame arrives which can be used to update the camera
  105453. */
  105454. onXRFrameObservable: Observable<any>;
  105455. /**
  105456. * Fires when the xr session is ended either by the device or manually done
  105457. */
  105458. onXRSessionEnded: Observable<any>;
  105459. /**
  105460. * Underlying xr session
  105461. */
  105462. session: XRSession;
  105463. /**
  105464. * Type of reference space used when creating the session
  105465. */
  105466. referenceSpace: XRReferenceSpace;
  105467. /** @hidden */
  105468. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  105469. /**
  105470. * Current XR frame
  105471. */
  105472. currentFrame: Nullable<XRFrame>;
  105473. private _xrNavigator;
  105474. private baseLayer;
  105475. /**
  105476. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  105477. * @param scene The scene which the session should be created for
  105478. */
  105479. constructor(scene: Scene);
  105480. /**
  105481. * Initializes the manager
  105482. * After initialization enterXR can be called to start an XR session
  105483. * @returns Promise which resolves after it is initialized
  105484. */
  105485. initializeAsync(): Promise<void>;
  105486. /**
  105487. * Initializes an xr session
  105488. * @param xrSessionMode mode to initialize
  105489. * @returns a promise which will resolve once the session has been initialized
  105490. */
  105491. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  105492. /**
  105493. * Sets the reference space on the xr session
  105494. * @param referenceSpace space to set
  105495. * @returns a promise that will resolve once the reference space has been set
  105496. */
  105497. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  105498. /**
  105499. * Updates the render state of the session
  105500. * @param state state to set
  105501. * @returns a promise that resolves once the render state has been updated
  105502. */
  105503. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  105504. /**
  105505. * Starts rendering to the xr layer
  105506. * @returns a promise that will resolve once rendering has started
  105507. */
  105508. startRenderingToXRAsync(): Promise<void>;
  105509. /**
  105510. * Stops the xrSession and restores the renderloop
  105511. * @returns Promise which resolves after it exits XR
  105512. */
  105513. exitXRAsync(): Promise<unknown>;
  105514. /**
  105515. * Checks if a session would be supported for the creation options specified
  105516. * @param sessionMode session mode to check if supported eg. immersive-vr
  105517. * @returns true if supported
  105518. */
  105519. supportsSessionAsync(sessionMode: XRSessionMode): any;
  105520. /**
  105521. * @hidden
  105522. * Converts the render layer of xrSession to a render target
  105523. * @param session session to create render target for
  105524. * @param scene scene the new render target should be created for
  105525. */
  105526. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  105527. /**
  105528. * Disposes of the session manager
  105529. */
  105530. dispose(): void;
  105531. }
  105532. }
  105533. declare module BABYLON {
  105534. /**
  105535. * WebXR Camera which holds the views for the xrSession
  105536. * @see https://doc.babylonjs.com/how_to/webxr
  105537. */
  105538. export class WebXRCamera extends FreeCamera {
  105539. private static _TmpMatrix;
  105540. /**
  105541. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  105542. * @param name the name of the camera
  105543. * @param scene the scene to add the camera to
  105544. */
  105545. constructor(name: string, scene: Scene);
  105546. private _updateNumberOfRigCameras;
  105547. /** @hidden */
  105548. _updateForDualEyeDebugging(pupilDistance?: number): void;
  105549. /**
  105550. * Updates the cameras position from the current pose information of the XR session
  105551. * @param xrSessionManager the session containing pose information
  105552. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  105553. */
  105554. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  105555. }
  105556. }
  105557. declare module BABYLON {
  105558. /**
  105559. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  105560. */
  105561. export class WebXRManagedOutputCanvas implements IDisposable {
  105562. private helper;
  105563. private _canvas;
  105564. /**
  105565. * xrpresent context of the canvas which can be used to display/mirror xr content
  105566. */
  105567. canvasContext: WebGLRenderingContext;
  105568. /**
  105569. * xr layer for the canvas
  105570. */
  105571. xrLayer: Nullable<XRWebGLLayer>;
  105572. /**
  105573. * Initializes the xr layer for the session
  105574. * @param xrSession xr session
  105575. * @returns a promise that will resolve once the XR Layer has been created
  105576. */
  105577. initializeXRLayerAsync(xrSession: any): any;
  105578. /**
  105579. * Initializes the canvas to be added/removed upon entering/exiting xr
  105580. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  105581. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  105582. */
  105583. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  105584. /**
  105585. * Disposes of the object
  105586. */
  105587. dispose(): void;
  105588. private _setManagedOutputCanvas;
  105589. private _addCanvas;
  105590. private _removeCanvas;
  105591. }
  105592. }
  105593. declare module BABYLON {
  105594. /**
  105595. * States of the webXR experience
  105596. */
  105597. export enum WebXRState {
  105598. /**
  105599. * Transitioning to being in XR mode
  105600. */
  105601. ENTERING_XR = 0,
  105602. /**
  105603. * Transitioning to non XR mode
  105604. */
  105605. EXITING_XR = 1,
  105606. /**
  105607. * In XR mode and presenting
  105608. */
  105609. IN_XR = 2,
  105610. /**
  105611. * Not entered XR mode
  105612. */
  105613. NOT_IN_XR = 3
  105614. }
  105615. /**
  105616. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  105617. * @see https://doc.babylonjs.com/how_to/webxr
  105618. */
  105619. export class WebXRExperienceHelper implements IDisposable {
  105620. private scene;
  105621. /**
  105622. * 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
  105623. */
  105624. container: AbstractMesh;
  105625. /**
  105626. * Camera used to render xr content
  105627. */
  105628. camera: WebXRCamera;
  105629. /**
  105630. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  105631. */
  105632. state: WebXRState;
  105633. private _setState;
  105634. private static _TmpVector;
  105635. /**
  105636. * Fires when the state of the experience helper has changed
  105637. */
  105638. onStateChangedObservable: Observable<WebXRState>;
  105639. /** Session manager used to keep track of xr session */
  105640. sessionManager: WebXRSessionManager;
  105641. private _nonVRCamera;
  105642. private _originalSceneAutoClear;
  105643. private _supported;
  105644. /**
  105645. * Creates the experience helper
  105646. * @param scene the scene to attach the experience helper to
  105647. * @returns a promise for the experience helper
  105648. */
  105649. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  105650. /**
  105651. * Creates a WebXRExperienceHelper
  105652. * @param scene The scene the helper should be created in
  105653. */
  105654. private constructor();
  105655. /**
  105656. * Exits XR mode and returns the scene to its original state
  105657. * @returns promise that resolves after xr mode has exited
  105658. */
  105659. exitXRAsync(): Promise<unknown>;
  105660. /**
  105661. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  105662. * @param sessionCreationOptions options for the XR session
  105663. * @param referenceSpaceType frame of reference of the XR session
  105664. * @param outputCanvas the output canvas that will be used to enter XR mode
  105665. * @returns promise that resolves after xr mode has entered
  105666. */
  105667. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  105668. /**
  105669. * Updates the global position of the camera by moving the camera's container
  105670. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  105671. * @param position The desired global position of the camera
  105672. */
  105673. setPositionOfCameraUsingContainer(position: Vector3): void;
  105674. /**
  105675. * Rotates the xr camera by rotating the camera's container around the camera's position
  105676. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  105677. * @param rotation the desired quaternion rotation to apply to the camera
  105678. */
  105679. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  105680. /**
  105681. * Disposes of the experience helper
  105682. */
  105683. dispose(): void;
  105684. }
  105685. }
  105686. declare module BABYLON {
  105687. /**
  105688. * Button which can be used to enter a different mode of XR
  105689. */
  105690. export class WebXREnterExitUIButton {
  105691. /** button element */
  105692. element: HTMLElement;
  105693. /** XR initialization options for the button */
  105694. sessionMode: XRSessionMode;
  105695. /** Reference space type */
  105696. referenceSpaceType: XRReferenceSpaceType;
  105697. /**
  105698. * Creates a WebXREnterExitUIButton
  105699. * @param element button element
  105700. * @param sessionMode XR initialization session mode
  105701. * @param referenceSpaceType the type of reference space to be used
  105702. */
  105703. constructor(
  105704. /** button element */
  105705. element: HTMLElement,
  105706. /** XR initialization options for the button */
  105707. sessionMode: XRSessionMode,
  105708. /** Reference space type */
  105709. referenceSpaceType: XRReferenceSpaceType);
  105710. /**
  105711. * Overwritable function which can be used to update the button's visuals when the state changes
  105712. * @param activeButton the current active button in the UI
  105713. */
  105714. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  105715. }
  105716. /**
  105717. * Options to create the webXR UI
  105718. */
  105719. export class WebXREnterExitUIOptions {
  105720. /**
  105721. * Context to enter xr with
  105722. */
  105723. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  105724. /**
  105725. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  105726. */
  105727. customButtons?: Array<WebXREnterExitUIButton>;
  105728. }
  105729. /**
  105730. * UI to allow the user to enter/exit XR mode
  105731. */
  105732. export class WebXREnterExitUI implements IDisposable {
  105733. private scene;
  105734. private _overlay;
  105735. private _buttons;
  105736. private _activeButton;
  105737. /**
  105738. * Fired every time the active button is changed.
  105739. *
  105740. * When xr is entered via a button that launches xr that button will be the callback parameter
  105741. *
  105742. * When exiting xr the callback parameter will be null)
  105743. */
  105744. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  105745. /**
  105746. * Creates UI to allow the user to enter/exit XR mode
  105747. * @param scene the scene to add the ui to
  105748. * @param helper the xr experience helper to enter/exit xr with
  105749. * @param options options to configure the UI
  105750. * @returns the created ui
  105751. */
  105752. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  105753. private constructor();
  105754. private _updateButtons;
  105755. /**
  105756. * Disposes of the object
  105757. */
  105758. dispose(): void;
  105759. }
  105760. }
  105761. declare module BABYLON {
  105762. /**
  105763. * Represents an XR input
  105764. */
  105765. export class WebXRController {
  105766. private scene;
  105767. /** The underlying input source for the controller */
  105768. inputSource: XRInputSource;
  105769. private parentContainer;
  105770. /**
  105771. * 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
  105772. */
  105773. grip?: AbstractMesh;
  105774. /**
  105775. * Pointer which can be used to select objects or attach a visible laser to
  105776. */
  105777. pointer: AbstractMesh;
  105778. /**
  105779. * Event that fires when the controller is removed/disposed
  105780. */
  105781. onDisposeObservable: Observable<{}>;
  105782. private _tmpMatrix;
  105783. private _tmpQuaternion;
  105784. private _tmpVector;
  105785. /**
  105786. * Creates the controller
  105787. * @see https://doc.babylonjs.com/how_to/webxr
  105788. * @param scene the scene which the controller should be associated to
  105789. * @param inputSource the underlying input source for the controller
  105790. * @param parentContainer parent that the controller meshes should be children of
  105791. */
  105792. constructor(scene: Scene,
  105793. /** The underlying input source for the controller */
  105794. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  105795. /**
  105796. * Updates the controller pose based on the given XRFrame
  105797. * @param xrFrame xr frame to update the pose with
  105798. * @param referenceSpace reference space to use
  105799. */
  105800. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  105801. /**
  105802. * Gets a world space ray coming from the controller
  105803. * @param result the resulting ray
  105804. */
  105805. getWorldPointerRayToRef(result: Ray): void;
  105806. /**
  105807. * Disposes of the object
  105808. */
  105809. dispose(): void;
  105810. }
  105811. }
  105812. declare module BABYLON {
  105813. /**
  105814. * XR input used to track XR inputs such as controllers/rays
  105815. */
  105816. export class WebXRInput implements IDisposable {
  105817. /**
  105818. * Base experience the input listens to
  105819. */
  105820. baseExperience: WebXRExperienceHelper;
  105821. /**
  105822. * XR controllers being tracked
  105823. */
  105824. controllers: Array<WebXRController>;
  105825. private _frameObserver;
  105826. private _stateObserver;
  105827. /**
  105828. * Event when a controller has been connected/added
  105829. */
  105830. onControllerAddedObservable: Observable<WebXRController>;
  105831. /**
  105832. * Event when a controller has been removed/disconnected
  105833. */
  105834. onControllerRemovedObservable: Observable<WebXRController>;
  105835. /**
  105836. * Initializes the WebXRInput
  105837. * @param baseExperience experience helper which the input should be created for
  105838. */
  105839. constructor(
  105840. /**
  105841. * Base experience the input listens to
  105842. */
  105843. baseExperience: WebXRExperienceHelper);
  105844. private _onInputSourcesChange;
  105845. private _addAndRemoveControllers;
  105846. /**
  105847. * Disposes of the object
  105848. */
  105849. dispose(): void;
  105850. }
  105851. }
  105852. declare module BABYLON {
  105853. /**
  105854. * Enables teleportation
  105855. */
  105856. export class WebXRControllerTeleportation {
  105857. private _teleportationFillColor;
  105858. private _teleportationBorderColor;
  105859. private _tmpRay;
  105860. private _tmpVector;
  105861. /**
  105862. * Creates a WebXRControllerTeleportation
  105863. * @param input input manager to add teleportation to
  105864. * @param floorMeshes floormeshes which can be teleported to
  105865. */
  105866. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  105867. }
  105868. }
  105869. declare module BABYLON {
  105870. /**
  105871. * Handles pointer input automatically for the pointer of XR controllers
  105872. */
  105873. export class WebXRControllerPointerSelection {
  105874. private static _idCounter;
  105875. private _tmpRay;
  105876. /**
  105877. * Creates a WebXRControllerPointerSelection
  105878. * @param input input manager to setup pointer selection
  105879. */
  105880. constructor(input: WebXRInput);
  105881. private _convertNormalToDirectionOfRay;
  105882. private _updatePointerDistance;
  105883. }
  105884. }
  105885. declare module BABYLON {
  105886. /**
  105887. * Class used to represent data loading progression
  105888. */
  105889. export class SceneLoaderProgressEvent {
  105890. /** defines if data length to load can be evaluated */
  105891. readonly lengthComputable: boolean;
  105892. /** defines the loaded data length */
  105893. readonly loaded: number;
  105894. /** defines the data length to load */
  105895. readonly total: number;
  105896. /**
  105897. * Create a new progress event
  105898. * @param lengthComputable defines if data length to load can be evaluated
  105899. * @param loaded defines the loaded data length
  105900. * @param total defines the data length to load
  105901. */
  105902. constructor(
  105903. /** defines if data length to load can be evaluated */
  105904. lengthComputable: boolean,
  105905. /** defines the loaded data length */
  105906. loaded: number,
  105907. /** defines the data length to load */
  105908. total: number);
  105909. /**
  105910. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105911. * @param event defines the source event
  105912. * @returns a new SceneLoaderProgressEvent
  105913. */
  105914. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105915. }
  105916. /**
  105917. * Interface used by SceneLoader plugins to define supported file extensions
  105918. */
  105919. export interface ISceneLoaderPluginExtensions {
  105920. /**
  105921. * Defines the list of supported extensions
  105922. */
  105923. [extension: string]: {
  105924. isBinary: boolean;
  105925. };
  105926. }
  105927. /**
  105928. * Interface used by SceneLoader plugin factory
  105929. */
  105930. export interface ISceneLoaderPluginFactory {
  105931. /**
  105932. * Defines the name of the factory
  105933. */
  105934. name: string;
  105935. /**
  105936. * Function called to create a new plugin
  105937. * @return the new plugin
  105938. */
  105939. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105940. /**
  105941. * Boolean indicating if the plugin can direct load specific data
  105942. */
  105943. canDirectLoad?: (data: string) => boolean;
  105944. }
  105945. /**
  105946. * Interface used to define a SceneLoader plugin
  105947. */
  105948. export interface ISceneLoaderPlugin {
  105949. /**
  105950. * The friendly name of this plugin.
  105951. */
  105952. name: string;
  105953. /**
  105954. * The file extensions supported by this plugin.
  105955. */
  105956. extensions: string | ISceneLoaderPluginExtensions;
  105957. /**
  105958. * Import meshes into a scene.
  105959. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105960. * @param scene The scene to import into
  105961. * @param data The data to import
  105962. * @param rootUrl The root url for scene and resources
  105963. * @param meshes The meshes array to import into
  105964. * @param particleSystems The particle systems array to import into
  105965. * @param skeletons The skeletons array to import into
  105966. * @param onError The callback when import fails
  105967. * @returns True if successful or false otherwise
  105968. */
  105969. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105970. /**
  105971. * Load into a scene.
  105972. * @param scene The scene to load into
  105973. * @param data The data to import
  105974. * @param rootUrl The root url for scene and resources
  105975. * @param onError The callback when import fails
  105976. * @returns true if successful or false otherwise
  105977. */
  105978. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105979. /**
  105980. * The callback that returns true if the data can be directly loaded.
  105981. */
  105982. canDirectLoad?: (data: string) => boolean;
  105983. /**
  105984. * The callback that allows custom handling of the root url based on the response url.
  105985. */
  105986. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105987. /**
  105988. * Load into an asset container.
  105989. * @param scene The scene to load into
  105990. * @param data The data to import
  105991. * @param rootUrl The root url for scene and resources
  105992. * @param onError The callback when import fails
  105993. * @returns The loaded asset container
  105994. */
  105995. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105996. }
  105997. /**
  105998. * Interface used to define an async SceneLoader plugin
  105999. */
  106000. export interface ISceneLoaderPluginAsync {
  106001. /**
  106002. * The friendly name of this plugin.
  106003. */
  106004. name: string;
  106005. /**
  106006. * The file extensions supported by this plugin.
  106007. */
  106008. extensions: string | ISceneLoaderPluginExtensions;
  106009. /**
  106010. * Import meshes into a scene.
  106011. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106012. * @param scene The scene to import into
  106013. * @param data The data to import
  106014. * @param rootUrl The root url for scene and resources
  106015. * @param onProgress The callback when the load progresses
  106016. * @param fileName Defines the name of the file to load
  106017. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  106018. */
  106019. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  106020. meshes: AbstractMesh[];
  106021. particleSystems: IParticleSystem[];
  106022. skeletons: Skeleton[];
  106023. animationGroups: AnimationGroup[];
  106024. }>;
  106025. /**
  106026. * Load into a scene.
  106027. * @param scene The scene to load into
  106028. * @param data The data to import
  106029. * @param rootUrl The root url for scene and resources
  106030. * @param onProgress The callback when the load progresses
  106031. * @param fileName Defines the name of the file to load
  106032. * @returns Nothing
  106033. */
  106034. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  106035. /**
  106036. * The callback that returns true if the data can be directly loaded.
  106037. */
  106038. canDirectLoad?: (data: string) => boolean;
  106039. /**
  106040. * The callback that allows custom handling of the root url based on the response url.
  106041. */
  106042. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106043. /**
  106044. * Load into an asset container.
  106045. * @param scene The scene to load into
  106046. * @param data The data to import
  106047. * @param rootUrl The root url for scene and resources
  106048. * @param onProgress The callback when the load progresses
  106049. * @param fileName Defines the name of the file to load
  106050. * @returns The loaded asset container
  106051. */
  106052. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  106053. }
  106054. /**
  106055. * Class used to load scene from various file formats using registered plugins
  106056. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  106057. */
  106058. export class SceneLoader {
  106059. /**
  106060. * No logging while loading
  106061. */
  106062. static readonly NO_LOGGING: number;
  106063. /**
  106064. * Minimal logging while loading
  106065. */
  106066. static readonly MINIMAL_LOGGING: number;
  106067. /**
  106068. * Summary logging while loading
  106069. */
  106070. static readonly SUMMARY_LOGGING: number;
  106071. /**
  106072. * Detailled logging while loading
  106073. */
  106074. static readonly DETAILED_LOGGING: number;
  106075. /**
  106076. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106077. */
  106078. static ForceFullSceneLoadingForIncremental: boolean;
  106079. /**
  106080. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106081. */
  106082. static ShowLoadingScreen: boolean;
  106083. /**
  106084. * Defines the current logging level (while loading the scene)
  106085. * @ignorenaming
  106086. */
  106087. static loggingLevel: number;
  106088. /**
  106089. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106090. */
  106091. static CleanBoneMatrixWeights: boolean;
  106092. /**
  106093. * Event raised when a plugin is used to load a scene
  106094. */
  106095. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  106096. private static _registeredPlugins;
  106097. private static _getDefaultPlugin;
  106098. private static _getPluginForExtension;
  106099. private static _getPluginForDirectLoad;
  106100. private static _getPluginForFilename;
  106101. private static _getDirectLoad;
  106102. private static _loadData;
  106103. private static _getFileInfo;
  106104. /**
  106105. * Gets a plugin that can load the given extension
  106106. * @param extension defines the extension to load
  106107. * @returns a plugin or null if none works
  106108. */
  106109. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  106110. /**
  106111. * Gets a boolean indicating that the given extension can be loaded
  106112. * @param extension defines the extension to load
  106113. * @returns true if the extension is supported
  106114. */
  106115. static IsPluginForExtensionAvailable(extension: string): boolean;
  106116. /**
  106117. * Adds a new plugin to the list of registered plugins
  106118. * @param plugin defines the plugin to add
  106119. */
  106120. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  106121. /**
  106122. * Import meshes into a scene
  106123. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106124. * @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)
  106125. * @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)
  106126. * @param scene the instance of BABYLON.Scene to append to
  106127. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  106128. * @param onProgress a callback with a progress event for each file being loaded
  106129. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106130. * @param pluginExtension the extension used to determine the plugin
  106131. * @returns The loaded plugin
  106132. */
  106133. 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>;
  106134. /**
  106135. * Import meshes into a scene
  106136. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106137. * @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)
  106138. * @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)
  106139. * @param scene the instance of BABYLON.Scene to append to
  106140. * @param onProgress a callback with a progress event for each file being loaded
  106141. * @param pluginExtension the extension used to determine the plugin
  106142. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  106143. */
  106144. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  106145. meshes: AbstractMesh[];
  106146. particleSystems: IParticleSystem[];
  106147. skeletons: Skeleton[];
  106148. animationGroups: AnimationGroup[];
  106149. }>;
  106150. /**
  106151. * Load a scene
  106152. * @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)
  106153. * @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)
  106154. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106155. * @param onSuccess a callback with the scene when import succeeds
  106156. * @param onProgress a callback with a progress event for each file being loaded
  106157. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106158. * @param pluginExtension the extension used to determine the plugin
  106159. * @returns The loaded plugin
  106160. */
  106161. 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>;
  106162. /**
  106163. * Load a scene
  106164. * @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)
  106165. * @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)
  106166. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106167. * @param onProgress a callback with a progress event for each file being loaded
  106168. * @param pluginExtension the extension used to determine the plugin
  106169. * @returns The loaded scene
  106170. */
  106171. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106172. /**
  106173. * Append a scene
  106174. * @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)
  106175. * @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)
  106176. * @param scene is the instance of BABYLON.Scene to append to
  106177. * @param onSuccess a callback with the scene when import succeeds
  106178. * @param onProgress a callback with a progress event for each file being loaded
  106179. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106180. * @param pluginExtension the extension used to determine the plugin
  106181. * @returns The loaded plugin
  106182. */
  106183. 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>;
  106184. /**
  106185. * Append a scene
  106186. * @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)
  106187. * @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)
  106188. * @param scene is the instance of BABYLON.Scene to append to
  106189. * @param onProgress a callback with a progress event for each file being loaded
  106190. * @param pluginExtension the extension used to determine the plugin
  106191. * @returns The given scene
  106192. */
  106193. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106194. /**
  106195. * Load a scene into an asset container
  106196. * @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)
  106197. * @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)
  106198. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106199. * @param onSuccess a callback with the scene when import succeeds
  106200. * @param onProgress a callback with a progress event for each file being loaded
  106201. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106202. * @param pluginExtension the extension used to determine the plugin
  106203. * @returns The loaded plugin
  106204. */
  106205. 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>;
  106206. /**
  106207. * Load a scene into an asset container
  106208. * @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)
  106209. * @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)
  106210. * @param scene is the instance of Scene to append to
  106211. * @param onProgress a callback with a progress event for each file being loaded
  106212. * @param pluginExtension the extension used to determine the plugin
  106213. * @returns The loaded asset container
  106214. */
  106215. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  106216. }
  106217. }
  106218. declare module BABYLON {
  106219. /**
  106220. * Generic Controller
  106221. */
  106222. export class GenericController extends WebVRController {
  106223. /**
  106224. * Base Url for the controller model.
  106225. */
  106226. static readonly MODEL_BASE_URL: string;
  106227. /**
  106228. * File name for the controller model.
  106229. */
  106230. static readonly MODEL_FILENAME: string;
  106231. /**
  106232. * Creates a new GenericController from a gamepad
  106233. * @param vrGamepad the gamepad that the controller should be created from
  106234. */
  106235. constructor(vrGamepad: any);
  106236. /**
  106237. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106238. * @param scene scene in which to add meshes
  106239. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106240. */
  106241. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106242. /**
  106243. * Called once for each button that changed state since the last frame
  106244. * @param buttonIdx Which button index changed
  106245. * @param state New state of the button
  106246. * @param changes Which properties on the state changed since last frame
  106247. */
  106248. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106249. }
  106250. }
  106251. declare module BABYLON {
  106252. /**
  106253. * Defines the WindowsMotionController object that the state of the windows motion controller
  106254. */
  106255. export class WindowsMotionController extends WebVRController {
  106256. /**
  106257. * The base url used to load the left and right controller models
  106258. */
  106259. static MODEL_BASE_URL: string;
  106260. /**
  106261. * The name of the left controller model file
  106262. */
  106263. static MODEL_LEFT_FILENAME: string;
  106264. /**
  106265. * The name of the right controller model file
  106266. */
  106267. static MODEL_RIGHT_FILENAME: string;
  106268. /**
  106269. * The controller name prefix for this controller type
  106270. */
  106271. static readonly GAMEPAD_ID_PREFIX: string;
  106272. /**
  106273. * The controller id pattern for this controller type
  106274. */
  106275. private static readonly GAMEPAD_ID_PATTERN;
  106276. private _loadedMeshInfo;
  106277. private readonly _mapping;
  106278. /**
  106279. * Fired when the trackpad on this controller is clicked
  106280. */
  106281. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106282. /**
  106283. * Fired when the trackpad on this controller is modified
  106284. */
  106285. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106286. /**
  106287. * The current x and y values of this controller's trackpad
  106288. */
  106289. trackpad: StickValues;
  106290. /**
  106291. * Creates a new WindowsMotionController from a gamepad
  106292. * @param vrGamepad the gamepad that the controller should be created from
  106293. */
  106294. constructor(vrGamepad: any);
  106295. /**
  106296. * Fired when the trigger on this controller is modified
  106297. */
  106298. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106299. /**
  106300. * Fired when the menu button on this controller is modified
  106301. */
  106302. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106303. /**
  106304. * Fired when the grip button on this controller is modified
  106305. */
  106306. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106307. /**
  106308. * Fired when the thumbstick button on this controller is modified
  106309. */
  106310. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106311. /**
  106312. * Fired when the touchpad button on this controller is modified
  106313. */
  106314. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106315. /**
  106316. * Fired when the touchpad values on this controller are modified
  106317. */
  106318. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  106319. private _updateTrackpad;
  106320. /**
  106321. * Called once per frame by the engine.
  106322. */
  106323. update(): void;
  106324. /**
  106325. * Called once for each button that changed state since the last frame
  106326. * @param buttonIdx Which button index changed
  106327. * @param state New state of the button
  106328. * @param changes Which properties on the state changed since last frame
  106329. */
  106330. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106331. /**
  106332. * Moves the buttons on the controller mesh based on their current state
  106333. * @param buttonName the name of the button to move
  106334. * @param buttonValue the value of the button which determines the buttons new position
  106335. */
  106336. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106337. /**
  106338. * Moves the axis on the controller mesh based on its current state
  106339. * @param axis the index of the axis
  106340. * @param axisValue the value of the axis which determines the meshes new position
  106341. * @hidden
  106342. */
  106343. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106344. /**
  106345. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106346. * @param scene scene in which to add meshes
  106347. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106348. */
  106349. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106350. /**
  106351. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106352. * can be transformed by button presses and axes values, based on this._mapping.
  106353. *
  106354. * @param scene scene in which the meshes exist
  106355. * @param meshes list of meshes that make up the controller model to process
  106356. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106357. */
  106358. private processModel;
  106359. private createMeshInfo;
  106360. /**
  106361. * Gets the ray of the controller in the direction the controller is pointing
  106362. * @param length the length the resulting ray should be
  106363. * @returns a ray in the direction the controller is pointing
  106364. */
  106365. getForwardRay(length?: number): Ray;
  106366. /**
  106367. * Disposes of the controller
  106368. */
  106369. dispose(): void;
  106370. }
  106371. }
  106372. declare module BABYLON {
  106373. /**
  106374. * Oculus Touch Controller
  106375. */
  106376. export class OculusTouchController extends WebVRController {
  106377. /**
  106378. * Base Url for the controller model.
  106379. */
  106380. static MODEL_BASE_URL: string;
  106381. /**
  106382. * File name for the left controller model.
  106383. */
  106384. static MODEL_LEFT_FILENAME: string;
  106385. /**
  106386. * File name for the right controller model.
  106387. */
  106388. static MODEL_RIGHT_FILENAME: string;
  106389. /**
  106390. * Base Url for the Quest controller model.
  106391. */
  106392. static QUEST_MODEL_BASE_URL: string;
  106393. /**
  106394. * @hidden
  106395. * If the controllers are running on a device that needs the updated Quest controller models
  106396. */
  106397. static _IsQuest: boolean;
  106398. /**
  106399. * Fired when the secondary trigger on this controller is modified
  106400. */
  106401. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  106402. /**
  106403. * Fired when the thumb rest on this controller is modified
  106404. */
  106405. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  106406. /**
  106407. * Creates a new OculusTouchController from a gamepad
  106408. * @param vrGamepad the gamepad that the controller should be created from
  106409. */
  106410. constructor(vrGamepad: any);
  106411. /**
  106412. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106413. * @param scene scene in which to add meshes
  106414. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106415. */
  106416. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106417. /**
  106418. * Fired when the A button on this controller is modified
  106419. */
  106420. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106421. /**
  106422. * Fired when the B button on this controller is modified
  106423. */
  106424. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106425. /**
  106426. * Fired when the X button on this controller is modified
  106427. */
  106428. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106429. /**
  106430. * Fired when the Y button on this controller is modified
  106431. */
  106432. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106433. /**
  106434. * Called once for each button that changed state since the last frame
  106435. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  106436. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  106437. * 2) secondary trigger (same)
  106438. * 3) A (right) X (left), touch, pressed = value
  106439. * 4) B / Y
  106440. * 5) thumb rest
  106441. * @param buttonIdx Which button index changed
  106442. * @param state New state of the button
  106443. * @param changes Which properties on the state changed since last frame
  106444. */
  106445. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106446. }
  106447. }
  106448. declare module BABYLON {
  106449. /**
  106450. * Vive Controller
  106451. */
  106452. export class ViveController extends WebVRController {
  106453. /**
  106454. * Base Url for the controller model.
  106455. */
  106456. static MODEL_BASE_URL: string;
  106457. /**
  106458. * File name for the controller model.
  106459. */
  106460. static MODEL_FILENAME: string;
  106461. /**
  106462. * Creates a new ViveController from a gamepad
  106463. * @param vrGamepad the gamepad that the controller should be created from
  106464. */
  106465. constructor(vrGamepad: any);
  106466. /**
  106467. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106468. * @param scene scene in which to add meshes
  106469. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106470. */
  106471. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106472. /**
  106473. * Fired when the left button on this controller is modified
  106474. */
  106475. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106476. /**
  106477. * Fired when the right button on this controller is modified
  106478. */
  106479. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106480. /**
  106481. * Fired when the menu button on this controller is modified
  106482. */
  106483. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106484. /**
  106485. * Called once for each button that changed state since the last frame
  106486. * Vive mapping:
  106487. * 0: touchpad
  106488. * 1: trigger
  106489. * 2: left AND right buttons
  106490. * 3: menu button
  106491. * @param buttonIdx Which button index changed
  106492. * @param state New state of the button
  106493. * @param changes Which properties on the state changed since last frame
  106494. */
  106495. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106496. }
  106497. }
  106498. declare module BABYLON {
  106499. /**
  106500. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  106501. */
  106502. export class WebXRControllerModelLoader {
  106503. /**
  106504. * Creates the WebXRControllerModelLoader
  106505. * @param input xr input that creates the controllers
  106506. */
  106507. constructor(input: WebXRInput);
  106508. }
  106509. }
  106510. declare module BABYLON {
  106511. /**
  106512. * Contains an array of blocks representing the octree
  106513. */
  106514. export interface IOctreeContainer<T> {
  106515. /**
  106516. * Blocks within the octree
  106517. */
  106518. blocks: Array<OctreeBlock<T>>;
  106519. }
  106520. /**
  106521. * Class used to store a cell in an octree
  106522. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106523. */
  106524. export class OctreeBlock<T> {
  106525. /**
  106526. * Gets the content of the current block
  106527. */
  106528. entries: T[];
  106529. /**
  106530. * Gets the list of block children
  106531. */
  106532. blocks: Array<OctreeBlock<T>>;
  106533. private _depth;
  106534. private _maxDepth;
  106535. private _capacity;
  106536. private _minPoint;
  106537. private _maxPoint;
  106538. private _boundingVectors;
  106539. private _creationFunc;
  106540. /**
  106541. * Creates a new block
  106542. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  106543. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  106544. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106545. * @param depth defines the current depth of this block in the octree
  106546. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  106547. * @param creationFunc defines a callback to call when an element is added to the block
  106548. */
  106549. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  106550. /**
  106551. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106552. */
  106553. readonly capacity: number;
  106554. /**
  106555. * Gets the minimum vector (in world space) of the block's bounding box
  106556. */
  106557. readonly minPoint: Vector3;
  106558. /**
  106559. * Gets the maximum vector (in world space) of the block's bounding box
  106560. */
  106561. readonly maxPoint: Vector3;
  106562. /**
  106563. * Add a new element to this block
  106564. * @param entry defines the element to add
  106565. */
  106566. addEntry(entry: T): void;
  106567. /**
  106568. * Remove an element from this block
  106569. * @param entry defines the element to remove
  106570. */
  106571. removeEntry(entry: T): void;
  106572. /**
  106573. * Add an array of elements to this block
  106574. * @param entries defines the array of elements to add
  106575. */
  106576. addEntries(entries: T[]): void;
  106577. /**
  106578. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  106579. * @param frustumPlanes defines the frustum planes to test
  106580. * @param selection defines the array to store current content if selection is positive
  106581. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106582. */
  106583. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106584. /**
  106585. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  106586. * @param sphereCenter defines the bounding sphere center
  106587. * @param sphereRadius defines the bounding sphere radius
  106588. * @param selection defines the array to store current content if selection is positive
  106589. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106590. */
  106591. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106592. /**
  106593. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  106594. * @param ray defines the ray to test with
  106595. * @param selection defines the array to store current content if selection is positive
  106596. */
  106597. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  106598. /**
  106599. * Subdivide the content into child blocks (this block will then be empty)
  106600. */
  106601. createInnerBlocks(): void;
  106602. /**
  106603. * @hidden
  106604. */
  106605. 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;
  106606. }
  106607. }
  106608. declare module BABYLON {
  106609. /**
  106610. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  106611. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106612. */
  106613. export class Octree<T> {
  106614. /** 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.) */
  106615. maxDepth: number;
  106616. /**
  106617. * Blocks within the octree containing objects
  106618. */
  106619. blocks: Array<OctreeBlock<T>>;
  106620. /**
  106621. * Content stored in the octree
  106622. */
  106623. dynamicContent: T[];
  106624. private _maxBlockCapacity;
  106625. private _selectionContent;
  106626. private _creationFunc;
  106627. /**
  106628. * Creates a octree
  106629. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106630. * @param creationFunc function to be used to instatiate the octree
  106631. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  106632. * @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.)
  106633. */
  106634. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  106635. /** 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.) */
  106636. maxDepth?: number);
  106637. /**
  106638. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  106639. * @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);
  106640. * @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);
  106641. * @param entries meshes to be added to the octree blocks
  106642. */
  106643. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  106644. /**
  106645. * Adds a mesh to the octree
  106646. * @param entry Mesh to add to the octree
  106647. */
  106648. addMesh(entry: T): void;
  106649. /**
  106650. * Remove an element from the octree
  106651. * @param entry defines the element to remove
  106652. */
  106653. removeMesh(entry: T): void;
  106654. /**
  106655. * Selects an array of meshes within the frustum
  106656. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  106657. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  106658. * @returns array of meshes within the frustum
  106659. */
  106660. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  106661. /**
  106662. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  106663. * @param sphereCenter defines the bounding sphere center
  106664. * @param sphereRadius defines the bounding sphere radius
  106665. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106666. * @returns an array of objects that intersect the sphere
  106667. */
  106668. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  106669. /**
  106670. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  106671. * @param ray defines the ray to test with
  106672. * @returns array of intersected objects
  106673. */
  106674. intersectsRay(ray: Ray): SmartArray<T>;
  106675. /**
  106676. * Adds a mesh into the octree block if it intersects the block
  106677. */
  106678. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  106679. /**
  106680. * Adds a submesh into the octree block if it intersects the block
  106681. */
  106682. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  106683. }
  106684. }
  106685. declare module BABYLON {
  106686. interface Scene {
  106687. /**
  106688. * @hidden
  106689. * Backing Filed
  106690. */
  106691. _selectionOctree: Octree<AbstractMesh>;
  106692. /**
  106693. * Gets the octree used to boost mesh selection (picking)
  106694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106695. */
  106696. selectionOctree: Octree<AbstractMesh>;
  106697. /**
  106698. * Creates or updates the octree used to boost selection (picking)
  106699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106700. * @param maxCapacity defines the maximum capacity per leaf
  106701. * @param maxDepth defines the maximum depth of the octree
  106702. * @returns an octree of AbstractMesh
  106703. */
  106704. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  106705. }
  106706. interface AbstractMesh {
  106707. /**
  106708. * @hidden
  106709. * Backing Field
  106710. */
  106711. _submeshesOctree: Octree<SubMesh>;
  106712. /**
  106713. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  106714. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106715. * @param maxCapacity defines the maximum size of each block (64 by default)
  106716. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  106717. * @returns the new octree
  106718. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  106719. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106720. */
  106721. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  106722. }
  106723. /**
  106724. * Defines the octree scene component responsible to manage any octrees
  106725. * in a given scene.
  106726. */
  106727. export class OctreeSceneComponent {
  106728. /**
  106729. * The component name help to identify the component in the list of scene components.
  106730. */
  106731. readonly name: string;
  106732. /**
  106733. * The scene the component belongs to.
  106734. */
  106735. scene: Scene;
  106736. /**
  106737. * Indicates if the meshes have been checked to make sure they are isEnabled()
  106738. */
  106739. readonly checksIsEnabled: boolean;
  106740. /**
  106741. * Creates a new instance of the component for the given scene
  106742. * @param scene Defines the scene to register the component in
  106743. */
  106744. constructor(scene: Scene);
  106745. /**
  106746. * Registers the component in a given scene
  106747. */
  106748. register(): void;
  106749. /**
  106750. * Return the list of active meshes
  106751. * @returns the list of active meshes
  106752. */
  106753. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106754. /**
  106755. * Return the list of active sub meshes
  106756. * @param mesh The mesh to get the candidates sub meshes from
  106757. * @returns the list of active sub meshes
  106758. */
  106759. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106760. private _tempRay;
  106761. /**
  106762. * Return the list of sub meshes intersecting with a given local ray
  106763. * @param mesh defines the mesh to find the submesh for
  106764. * @param localRay defines the ray in local space
  106765. * @returns the list of intersecting sub meshes
  106766. */
  106767. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  106768. /**
  106769. * Return the list of sub meshes colliding with a collider
  106770. * @param mesh defines the mesh to find the submesh for
  106771. * @param collider defines the collider to evaluate the collision against
  106772. * @returns the list of colliding sub meshes
  106773. */
  106774. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  106775. /**
  106776. * Rebuilds the elements related to this component in case of
  106777. * context lost for instance.
  106778. */
  106779. rebuild(): void;
  106780. /**
  106781. * Disposes the component and the associated ressources.
  106782. */
  106783. dispose(): void;
  106784. }
  106785. }
  106786. declare module BABYLON {
  106787. /**
  106788. * Renders a layer on top of an existing scene
  106789. */
  106790. export class UtilityLayerRenderer implements IDisposable {
  106791. /** the original scene that will be rendered on top of */
  106792. originalScene: Scene;
  106793. private _pointerCaptures;
  106794. private _lastPointerEvents;
  106795. private static _DefaultUtilityLayer;
  106796. private static _DefaultKeepDepthUtilityLayer;
  106797. private _sharedGizmoLight;
  106798. private _renderCamera;
  106799. /**
  106800. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  106801. * @returns the camera that is used when rendering the utility layer
  106802. */
  106803. getRenderCamera(): Nullable<Camera>;
  106804. /**
  106805. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  106806. * @param cam the camera that should be used when rendering the utility layer
  106807. */
  106808. setRenderCamera(cam: Nullable<Camera>): void;
  106809. /**
  106810. * @hidden
  106811. * Light which used by gizmos to get light shading
  106812. */
  106813. _getSharedGizmoLight(): HemisphericLight;
  106814. /**
  106815. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  106816. */
  106817. pickUtilitySceneFirst: boolean;
  106818. /**
  106819. * 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)
  106820. */
  106821. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  106822. /**
  106823. * 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)
  106824. */
  106825. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  106826. /**
  106827. * The scene that is rendered on top of the original scene
  106828. */
  106829. utilityLayerScene: Scene;
  106830. /**
  106831. * If the utility layer should automatically be rendered on top of existing scene
  106832. */
  106833. shouldRender: boolean;
  106834. /**
  106835. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  106836. */
  106837. onlyCheckPointerDownEvents: boolean;
  106838. /**
  106839. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  106840. */
  106841. processAllEvents: boolean;
  106842. /**
  106843. * Observable raised when the pointer move from the utility layer scene to the main scene
  106844. */
  106845. onPointerOutObservable: Observable<number>;
  106846. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  106847. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  106848. private _afterRenderObserver;
  106849. private _sceneDisposeObserver;
  106850. private _originalPointerObserver;
  106851. /**
  106852. * Instantiates a UtilityLayerRenderer
  106853. * @param originalScene the original scene that will be rendered on top of
  106854. * @param handleEvents boolean indicating if the utility layer should handle events
  106855. */
  106856. constructor(
  106857. /** the original scene that will be rendered on top of */
  106858. originalScene: Scene, handleEvents?: boolean);
  106859. private _notifyObservers;
  106860. /**
  106861. * Renders the utility layers scene on top of the original scene
  106862. */
  106863. render(): void;
  106864. /**
  106865. * Disposes of the renderer
  106866. */
  106867. dispose(): void;
  106868. private _updateCamera;
  106869. }
  106870. }
  106871. declare module BABYLON {
  106872. /**
  106873. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  106874. */
  106875. export class Gizmo implements IDisposable {
  106876. /** The utility layer the gizmo will be added to */
  106877. gizmoLayer: UtilityLayerRenderer;
  106878. /**
  106879. * The root mesh of the gizmo
  106880. */
  106881. _rootMesh: Mesh;
  106882. private _attachedMesh;
  106883. /**
  106884. * Ratio for the scale of the gizmo (Default: 1)
  106885. */
  106886. scaleRatio: number;
  106887. /**
  106888. * If a custom mesh has been set (Default: false)
  106889. */
  106890. protected _customMeshSet: boolean;
  106891. /**
  106892. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  106893. * * When set, interactions will be enabled
  106894. */
  106895. attachedMesh: Nullable<AbstractMesh>;
  106896. /**
  106897. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106898. * @param mesh The mesh to replace the default mesh of the gizmo
  106899. */
  106900. setCustomMesh(mesh: Mesh): void;
  106901. /**
  106902. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  106903. */
  106904. updateGizmoRotationToMatchAttachedMesh: boolean;
  106905. /**
  106906. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  106907. */
  106908. updateGizmoPositionToMatchAttachedMesh: boolean;
  106909. /**
  106910. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  106911. */
  106912. updateScale: boolean;
  106913. protected _interactionsEnabled: boolean;
  106914. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106915. private _beforeRenderObserver;
  106916. private _tempVector;
  106917. /**
  106918. * Creates a gizmo
  106919. * @param gizmoLayer The utility layer the gizmo will be added to
  106920. */
  106921. constructor(
  106922. /** The utility layer the gizmo will be added to */
  106923. gizmoLayer?: UtilityLayerRenderer);
  106924. /**
  106925. * Updates the gizmo to match the attached mesh's position/rotation
  106926. */
  106927. protected _update(): void;
  106928. /**
  106929. * Disposes of the gizmo
  106930. */
  106931. dispose(): void;
  106932. }
  106933. }
  106934. declare module BABYLON {
  106935. /**
  106936. * Single plane drag gizmo
  106937. */
  106938. export class PlaneDragGizmo extends Gizmo {
  106939. /**
  106940. * Drag behavior responsible for the gizmos dragging interactions
  106941. */
  106942. dragBehavior: PointerDragBehavior;
  106943. private _pointerObserver;
  106944. /**
  106945. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106946. */
  106947. snapDistance: number;
  106948. /**
  106949. * Event that fires each time the gizmo snaps to a new location.
  106950. * * snapDistance is the the change in distance
  106951. */
  106952. onSnapObservable: Observable<{
  106953. snapDistance: number;
  106954. }>;
  106955. private _plane;
  106956. private _coloredMaterial;
  106957. private _hoverMaterial;
  106958. private _isEnabled;
  106959. private _parent;
  106960. /** @hidden */
  106961. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  106962. /** @hidden */
  106963. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106964. /**
  106965. * Creates a PlaneDragGizmo
  106966. * @param gizmoLayer The utility layer the gizmo will be added to
  106967. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  106968. * @param color The color of the gizmo
  106969. */
  106970. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106971. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106972. /**
  106973. * If the gizmo is enabled
  106974. */
  106975. isEnabled: boolean;
  106976. /**
  106977. * Disposes of the gizmo
  106978. */
  106979. dispose(): void;
  106980. }
  106981. }
  106982. declare module BABYLON {
  106983. /**
  106984. * Gizmo that enables dragging a mesh along 3 axis
  106985. */
  106986. export class PositionGizmo extends Gizmo {
  106987. /**
  106988. * Internal gizmo used for interactions on the x axis
  106989. */
  106990. xGizmo: AxisDragGizmo;
  106991. /**
  106992. * Internal gizmo used for interactions on the y axis
  106993. */
  106994. yGizmo: AxisDragGizmo;
  106995. /**
  106996. * Internal gizmo used for interactions on the z axis
  106997. */
  106998. zGizmo: AxisDragGizmo;
  106999. /**
  107000. * Internal gizmo used for interactions on the yz plane
  107001. */
  107002. xPlaneGizmo: PlaneDragGizmo;
  107003. /**
  107004. * Internal gizmo used for interactions on the xz plane
  107005. */
  107006. yPlaneGizmo: PlaneDragGizmo;
  107007. /**
  107008. * Internal gizmo used for interactions on the xy plane
  107009. */
  107010. zPlaneGizmo: PlaneDragGizmo;
  107011. /**
  107012. * private variables
  107013. */
  107014. private _meshAttached;
  107015. private _updateGizmoRotationToMatchAttachedMesh;
  107016. private _snapDistance;
  107017. private _scaleRatio;
  107018. /** Fires an event when any of it's sub gizmos are dragged */
  107019. onDragStartObservable: Observable<unknown>;
  107020. /** Fires an event when any of it's sub gizmos are released from dragging */
  107021. onDragEndObservable: Observable<unknown>;
  107022. /**
  107023. * If set to true, planar drag is enabled
  107024. */
  107025. private _planarGizmoEnabled;
  107026. attachedMesh: Nullable<AbstractMesh>;
  107027. /**
  107028. * Creates a PositionGizmo
  107029. * @param gizmoLayer The utility layer the gizmo will be added to
  107030. */
  107031. constructor(gizmoLayer?: UtilityLayerRenderer);
  107032. /**
  107033. * If the planar drag gizmo is enabled
  107034. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  107035. */
  107036. planarGizmoEnabled: boolean;
  107037. updateGizmoRotationToMatchAttachedMesh: boolean;
  107038. /**
  107039. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107040. */
  107041. snapDistance: number;
  107042. /**
  107043. * Ratio for the scale of the gizmo (Default: 1)
  107044. */
  107045. scaleRatio: number;
  107046. /**
  107047. * Disposes of the gizmo
  107048. */
  107049. dispose(): void;
  107050. /**
  107051. * CustomMeshes are not supported by this gizmo
  107052. * @param mesh The mesh to replace the default mesh of the gizmo
  107053. */
  107054. setCustomMesh(mesh: Mesh): void;
  107055. }
  107056. }
  107057. declare module BABYLON {
  107058. /**
  107059. * Single axis drag gizmo
  107060. */
  107061. export class AxisDragGizmo extends Gizmo {
  107062. /**
  107063. * Drag behavior responsible for the gizmos dragging interactions
  107064. */
  107065. dragBehavior: PointerDragBehavior;
  107066. private _pointerObserver;
  107067. /**
  107068. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107069. */
  107070. snapDistance: number;
  107071. /**
  107072. * Event that fires each time the gizmo snaps to a new location.
  107073. * * snapDistance is the the change in distance
  107074. */
  107075. onSnapObservable: Observable<{
  107076. snapDistance: number;
  107077. }>;
  107078. private _isEnabled;
  107079. private _parent;
  107080. private _arrow;
  107081. private _coloredMaterial;
  107082. private _hoverMaterial;
  107083. /** @hidden */
  107084. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  107085. /** @hidden */
  107086. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107087. /**
  107088. * Creates an AxisDragGizmo
  107089. * @param gizmoLayer The utility layer the gizmo will be added to
  107090. * @param dragAxis The axis which the gizmo will be able to drag on
  107091. * @param color The color of the gizmo
  107092. */
  107093. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107094. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107095. /**
  107096. * If the gizmo is enabled
  107097. */
  107098. isEnabled: boolean;
  107099. /**
  107100. * Disposes of the gizmo
  107101. */
  107102. dispose(): void;
  107103. }
  107104. }
  107105. declare module BABYLON.Debug {
  107106. /**
  107107. * The Axes viewer will show 3 axes in a specific point in space
  107108. */
  107109. export class AxesViewer {
  107110. private _xAxis;
  107111. private _yAxis;
  107112. private _zAxis;
  107113. private _scaleLinesFactor;
  107114. private _instanced;
  107115. /**
  107116. * Gets the hosting scene
  107117. */
  107118. scene: Scene;
  107119. /**
  107120. * Gets or sets a number used to scale line length
  107121. */
  107122. scaleLines: number;
  107123. /** Gets the node hierarchy used to render x-axis */
  107124. readonly xAxis: TransformNode;
  107125. /** Gets the node hierarchy used to render y-axis */
  107126. readonly yAxis: TransformNode;
  107127. /** Gets the node hierarchy used to render z-axis */
  107128. readonly zAxis: TransformNode;
  107129. /**
  107130. * Creates a new AxesViewer
  107131. * @param scene defines the hosting scene
  107132. * @param scaleLines defines a number used to scale line length (1 by default)
  107133. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  107134. * @param xAxis defines the node hierarchy used to render the x-axis
  107135. * @param yAxis defines the node hierarchy used to render the y-axis
  107136. * @param zAxis defines the node hierarchy used to render the z-axis
  107137. */
  107138. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  107139. /**
  107140. * Force the viewer to update
  107141. * @param position defines the position of the viewer
  107142. * @param xaxis defines the x axis of the viewer
  107143. * @param yaxis defines the y axis of the viewer
  107144. * @param zaxis defines the z axis of the viewer
  107145. */
  107146. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  107147. /**
  107148. * Creates an instance of this axes viewer.
  107149. * @returns a new axes viewer with instanced meshes
  107150. */
  107151. createInstance(): AxesViewer;
  107152. /** Releases resources */
  107153. dispose(): void;
  107154. private static _SetRenderingGroupId;
  107155. }
  107156. }
  107157. declare module BABYLON.Debug {
  107158. /**
  107159. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  107160. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  107161. */
  107162. export class BoneAxesViewer extends AxesViewer {
  107163. /**
  107164. * Gets or sets the target mesh where to display the axes viewer
  107165. */
  107166. mesh: Nullable<Mesh>;
  107167. /**
  107168. * Gets or sets the target bone where to display the axes viewer
  107169. */
  107170. bone: Nullable<Bone>;
  107171. /** Gets current position */
  107172. pos: Vector3;
  107173. /** Gets direction of X axis */
  107174. xaxis: Vector3;
  107175. /** Gets direction of Y axis */
  107176. yaxis: Vector3;
  107177. /** Gets direction of Z axis */
  107178. zaxis: Vector3;
  107179. /**
  107180. * Creates a new BoneAxesViewer
  107181. * @param scene defines the hosting scene
  107182. * @param bone defines the target bone
  107183. * @param mesh defines the target mesh
  107184. * @param scaleLines defines a scaling factor for line length (1 by default)
  107185. */
  107186. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  107187. /**
  107188. * Force the viewer to update
  107189. */
  107190. update(): void;
  107191. /** Releases resources */
  107192. dispose(): void;
  107193. }
  107194. }
  107195. declare module BABYLON {
  107196. /**
  107197. * Interface used to define scene explorer extensibility option
  107198. */
  107199. export interface IExplorerExtensibilityOption {
  107200. /**
  107201. * Define the option label
  107202. */
  107203. label: string;
  107204. /**
  107205. * Defines the action to execute on click
  107206. */
  107207. action: (entity: any) => void;
  107208. }
  107209. /**
  107210. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  107211. */
  107212. export interface IExplorerExtensibilityGroup {
  107213. /**
  107214. * Defines a predicate to test if a given type mut be extended
  107215. */
  107216. predicate: (entity: any) => boolean;
  107217. /**
  107218. * Gets the list of options added to a type
  107219. */
  107220. entries: IExplorerExtensibilityOption[];
  107221. }
  107222. /**
  107223. * Interface used to define the options to use to create the Inspector
  107224. */
  107225. export interface IInspectorOptions {
  107226. /**
  107227. * Display in overlay mode (default: false)
  107228. */
  107229. overlay?: boolean;
  107230. /**
  107231. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  107232. */
  107233. globalRoot?: HTMLElement;
  107234. /**
  107235. * Display the Scene explorer
  107236. */
  107237. showExplorer?: boolean;
  107238. /**
  107239. * Display the property inspector
  107240. */
  107241. showInspector?: boolean;
  107242. /**
  107243. * Display in embed mode (both panes on the right)
  107244. */
  107245. embedMode?: boolean;
  107246. /**
  107247. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  107248. */
  107249. handleResize?: boolean;
  107250. /**
  107251. * Allow the panes to popup (default: true)
  107252. */
  107253. enablePopup?: boolean;
  107254. /**
  107255. * Allow the panes to be closed by users (default: true)
  107256. */
  107257. enableClose?: boolean;
  107258. /**
  107259. * Optional list of extensibility entries
  107260. */
  107261. explorerExtensibility?: IExplorerExtensibilityGroup[];
  107262. /**
  107263. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  107264. */
  107265. inspectorURL?: string;
  107266. }
  107267. interface Scene {
  107268. /**
  107269. * @hidden
  107270. * Backing field
  107271. */
  107272. _debugLayer: DebugLayer;
  107273. /**
  107274. * Gets the debug layer (aka Inspector) associated with the scene
  107275. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107276. */
  107277. debugLayer: DebugLayer;
  107278. }
  107279. /**
  107280. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107281. * what is happening in your scene
  107282. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107283. */
  107284. export class DebugLayer {
  107285. /**
  107286. * Define the url to get the inspector script from.
  107287. * By default it uses the babylonjs CDN.
  107288. * @ignoreNaming
  107289. */
  107290. static InspectorURL: string;
  107291. private _scene;
  107292. private BJSINSPECTOR;
  107293. private _onPropertyChangedObservable?;
  107294. /**
  107295. * Observable triggered when a property is changed through the inspector.
  107296. */
  107297. readonly onPropertyChangedObservable: any;
  107298. /**
  107299. * Instantiates a new debug layer.
  107300. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107301. * what is happening in your scene
  107302. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107303. * @param scene Defines the scene to inspect
  107304. */
  107305. constructor(scene: Scene);
  107306. /** Creates the inspector window. */
  107307. private _createInspector;
  107308. /**
  107309. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  107310. * @param entity defines the entity to select
  107311. * @param lineContainerTitle defines the specific block to highlight
  107312. */
  107313. select(entity: any, lineContainerTitle?: string): void;
  107314. /** Get the inspector from bundle or global */
  107315. private _getGlobalInspector;
  107316. /**
  107317. * Get if the inspector is visible or not.
  107318. * @returns true if visible otherwise, false
  107319. */
  107320. isVisible(): boolean;
  107321. /**
  107322. * Hide the inspector and close its window.
  107323. */
  107324. hide(): void;
  107325. /**
  107326. * Launch the debugLayer.
  107327. * @param config Define the configuration of the inspector
  107328. * @return a promise fulfilled when the debug layer is visible
  107329. */
  107330. show(config?: IInspectorOptions): Promise<DebugLayer>;
  107331. }
  107332. }
  107333. declare module BABYLON {
  107334. /**
  107335. * Class containing static functions to help procedurally build meshes
  107336. */
  107337. export class BoxBuilder {
  107338. /**
  107339. * Creates a box mesh
  107340. * * The parameter `size` sets the size (float) of each box side (default 1)
  107341. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107342. * * 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)
  107343. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107347. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107348. * @param name defines the name of the mesh
  107349. * @param options defines the options used to create the mesh
  107350. * @param scene defines the hosting scene
  107351. * @returns the box mesh
  107352. */
  107353. static CreateBox(name: string, options: {
  107354. size?: number;
  107355. width?: number;
  107356. height?: number;
  107357. depth?: number;
  107358. faceUV?: Vector4[];
  107359. faceColors?: Color4[];
  107360. sideOrientation?: number;
  107361. frontUVs?: Vector4;
  107362. backUVs?: Vector4;
  107363. wrap?: boolean;
  107364. topBaseAt?: number;
  107365. bottomBaseAt?: number;
  107366. updatable?: boolean;
  107367. }, scene?: Nullable<Scene>): Mesh;
  107368. }
  107369. }
  107370. declare module BABYLON {
  107371. /**
  107372. * Class containing static functions to help procedurally build meshes
  107373. */
  107374. export class SphereBuilder {
  107375. /**
  107376. * Creates a sphere mesh
  107377. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107378. * * 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`)
  107379. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107380. * * 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
  107381. * * 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)
  107382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107385. * @param name defines the name of the mesh
  107386. * @param options defines the options used to create the mesh
  107387. * @param scene defines the hosting scene
  107388. * @returns the sphere mesh
  107389. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107390. */
  107391. static CreateSphere(name: string, options: {
  107392. segments?: number;
  107393. diameter?: number;
  107394. diameterX?: number;
  107395. diameterY?: number;
  107396. diameterZ?: number;
  107397. arc?: number;
  107398. slice?: number;
  107399. sideOrientation?: number;
  107400. frontUVs?: Vector4;
  107401. backUVs?: Vector4;
  107402. updatable?: boolean;
  107403. }, scene: any): Mesh;
  107404. }
  107405. }
  107406. declare module BABYLON.Debug {
  107407. /**
  107408. * Used to show the physics impostor around the specific mesh
  107409. */
  107410. export class PhysicsViewer {
  107411. /** @hidden */
  107412. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  107413. /** @hidden */
  107414. protected _meshes: Array<Nullable<AbstractMesh>>;
  107415. /** @hidden */
  107416. protected _scene: Nullable<Scene>;
  107417. /** @hidden */
  107418. protected _numMeshes: number;
  107419. /** @hidden */
  107420. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  107421. private _renderFunction;
  107422. private _utilityLayer;
  107423. private _debugBoxMesh;
  107424. private _debugSphereMesh;
  107425. private _debugCylinderMesh;
  107426. private _debugMaterial;
  107427. private _debugMeshMeshes;
  107428. /**
  107429. * Creates a new PhysicsViewer
  107430. * @param scene defines the hosting scene
  107431. */
  107432. constructor(scene: Scene);
  107433. /** @hidden */
  107434. protected _updateDebugMeshes(): void;
  107435. /**
  107436. * Renders a specified physic impostor
  107437. * @param impostor defines the impostor to render
  107438. * @param targetMesh defines the mesh represented by the impostor
  107439. * @returns the new debug mesh used to render the impostor
  107440. */
  107441. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  107442. /**
  107443. * Hides a specified physic impostor
  107444. * @param impostor defines the impostor to hide
  107445. */
  107446. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  107447. private _getDebugMaterial;
  107448. private _getDebugBoxMesh;
  107449. private _getDebugSphereMesh;
  107450. private _getDebugCylinderMesh;
  107451. private _getDebugMeshMesh;
  107452. private _getDebugMesh;
  107453. /** Releases all resources */
  107454. dispose(): void;
  107455. }
  107456. }
  107457. declare module BABYLON {
  107458. /**
  107459. * Class containing static functions to help procedurally build meshes
  107460. */
  107461. export class LinesBuilder {
  107462. /**
  107463. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107464. * * 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
  107465. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107466. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107467. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107468. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107469. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107470. * * 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
  107471. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107474. * @param name defines the name of the new line system
  107475. * @param options defines the options used to create the line system
  107476. * @param scene defines the hosting scene
  107477. * @returns a new line system mesh
  107478. */
  107479. static CreateLineSystem(name: string, options: {
  107480. lines: Vector3[][];
  107481. updatable?: boolean;
  107482. instance?: Nullable<LinesMesh>;
  107483. colors?: Nullable<Color4[][]>;
  107484. useVertexAlpha?: boolean;
  107485. }, scene: Nullable<Scene>): LinesMesh;
  107486. /**
  107487. * Creates a line mesh
  107488. * 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
  107489. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107490. * * The parameter `points` is an array successive Vector3
  107491. * * 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
  107492. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107493. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107494. * * When updating an instance, remember that only point positions can change, not the number of points
  107495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107497. * @param name defines the name of the new line system
  107498. * @param options defines the options used to create the line system
  107499. * @param scene defines the hosting scene
  107500. * @returns a new line mesh
  107501. */
  107502. static CreateLines(name: string, options: {
  107503. points: Vector3[];
  107504. updatable?: boolean;
  107505. instance?: Nullable<LinesMesh>;
  107506. colors?: Color4[];
  107507. useVertexAlpha?: boolean;
  107508. }, scene?: Nullable<Scene>): LinesMesh;
  107509. /**
  107510. * Creates a dashed line mesh
  107511. * * 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
  107512. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107513. * * The parameter `points` is an array successive Vector3
  107514. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107515. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107516. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107517. * * 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
  107518. * * When updating an instance, remember that only point positions can change, not the number of points
  107519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107520. * @param name defines the name of the mesh
  107521. * @param options defines the options used to create the mesh
  107522. * @param scene defines the hosting scene
  107523. * @returns the dashed line mesh
  107524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107525. */
  107526. static CreateDashedLines(name: string, options: {
  107527. points: Vector3[];
  107528. dashSize?: number;
  107529. gapSize?: number;
  107530. dashNb?: number;
  107531. updatable?: boolean;
  107532. instance?: LinesMesh;
  107533. }, scene?: Nullable<Scene>): LinesMesh;
  107534. }
  107535. }
  107536. declare module BABYLON {
  107537. /**
  107538. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107539. * in order to better appreciate the issue one might have.
  107540. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107541. */
  107542. export class RayHelper {
  107543. /**
  107544. * Defines the ray we are currently tryin to visualize.
  107545. */
  107546. ray: Nullable<Ray>;
  107547. private _renderPoints;
  107548. private _renderLine;
  107549. private _renderFunction;
  107550. private _scene;
  107551. private _updateToMeshFunction;
  107552. private _attachedToMesh;
  107553. private _meshSpaceDirection;
  107554. private _meshSpaceOrigin;
  107555. /**
  107556. * Helper function to create a colored helper in a scene in one line.
  107557. * @param ray Defines the ray we are currently tryin to visualize
  107558. * @param scene Defines the scene the ray is used in
  107559. * @param color Defines the color we want to see the ray in
  107560. * @returns The newly created ray helper.
  107561. */
  107562. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  107563. /**
  107564. * Instantiate a new ray helper.
  107565. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107566. * in order to better appreciate the issue one might have.
  107567. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107568. * @param ray Defines the ray we are currently tryin to visualize
  107569. */
  107570. constructor(ray: Ray);
  107571. /**
  107572. * Shows the ray we are willing to debug.
  107573. * @param scene Defines the scene the ray needs to be rendered in
  107574. * @param color Defines the color the ray needs to be rendered in
  107575. */
  107576. show(scene: Scene, color?: Color3): void;
  107577. /**
  107578. * Hides the ray we are debugging.
  107579. */
  107580. hide(): void;
  107581. private _render;
  107582. /**
  107583. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  107584. * @param mesh Defines the mesh we want the helper attached to
  107585. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  107586. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  107587. * @param length Defines the length of the ray
  107588. */
  107589. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  107590. /**
  107591. * Detach the ray helper from the mesh it has previously been attached to.
  107592. */
  107593. detachFromMesh(): void;
  107594. private _updateToMesh;
  107595. /**
  107596. * Dispose the helper and release its associated resources.
  107597. */
  107598. dispose(): void;
  107599. }
  107600. }
  107601. declare module BABYLON.Debug {
  107602. /**
  107603. * Class used to render a debug view of a given skeleton
  107604. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  107605. */
  107606. export class SkeletonViewer {
  107607. /** defines the skeleton to render */
  107608. skeleton: Skeleton;
  107609. /** defines the mesh attached to the skeleton */
  107610. mesh: AbstractMesh;
  107611. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107612. autoUpdateBonesMatrices: boolean;
  107613. /** defines the rendering group id to use with the viewer */
  107614. renderingGroupId: number;
  107615. /** Gets or sets the color used to render the skeleton */
  107616. color: Color3;
  107617. private _scene;
  107618. private _debugLines;
  107619. private _debugMesh;
  107620. private _isEnabled;
  107621. private _renderFunction;
  107622. private _utilityLayer;
  107623. /**
  107624. * Returns the mesh used to render the bones
  107625. */
  107626. readonly debugMesh: Nullable<LinesMesh>;
  107627. /**
  107628. * Creates a new SkeletonViewer
  107629. * @param skeleton defines the skeleton to render
  107630. * @param mesh defines the mesh attached to the skeleton
  107631. * @param scene defines the hosting scene
  107632. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  107633. * @param renderingGroupId defines the rendering group id to use with the viewer
  107634. */
  107635. constructor(
  107636. /** defines the skeleton to render */
  107637. skeleton: Skeleton,
  107638. /** defines the mesh attached to the skeleton */
  107639. mesh: AbstractMesh, scene: Scene,
  107640. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107641. autoUpdateBonesMatrices?: boolean,
  107642. /** defines the rendering group id to use with the viewer */
  107643. renderingGroupId?: number);
  107644. /** Gets or sets a boolean indicating if the viewer is enabled */
  107645. isEnabled: boolean;
  107646. private _getBonePosition;
  107647. private _getLinesForBonesWithLength;
  107648. private _getLinesForBonesNoLength;
  107649. /** Update the viewer to sync with current skeleton state */
  107650. update(): void;
  107651. /** Release associated resources */
  107652. dispose(): void;
  107653. }
  107654. }
  107655. declare module BABYLON {
  107656. /**
  107657. * Options to create the null engine
  107658. */
  107659. export class NullEngineOptions {
  107660. /**
  107661. * Render width (Default: 512)
  107662. */
  107663. renderWidth: number;
  107664. /**
  107665. * Render height (Default: 256)
  107666. */
  107667. renderHeight: number;
  107668. /**
  107669. * Texture size (Default: 512)
  107670. */
  107671. textureSize: number;
  107672. /**
  107673. * If delta time between frames should be constant
  107674. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107675. */
  107676. deterministicLockstep: boolean;
  107677. /**
  107678. * Maximum about of steps between frames (Default: 4)
  107679. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107680. */
  107681. lockstepMaxSteps: number;
  107682. }
  107683. /**
  107684. * The null engine class provides support for headless version of babylon.js.
  107685. * This can be used in server side scenario or for testing purposes
  107686. */
  107687. export class NullEngine extends Engine {
  107688. private _options;
  107689. /**
  107690. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107691. */
  107692. isDeterministicLockStep(): boolean;
  107693. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  107694. getLockstepMaxSteps(): number;
  107695. /**
  107696. * Sets hardware scaling, used to save performance if needed
  107697. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  107698. */
  107699. getHardwareScalingLevel(): number;
  107700. constructor(options?: NullEngineOptions);
  107701. createVertexBuffer(vertices: FloatArray): DataBuffer;
  107702. createIndexBuffer(indices: IndicesArray): DataBuffer;
  107703. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107704. getRenderWidth(useScreen?: boolean): number;
  107705. getRenderHeight(useScreen?: boolean): number;
  107706. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107707. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  107708. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  107709. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  107710. bindSamplers(effect: Effect): void;
  107711. enableEffect(effect: Effect): void;
  107712. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  107713. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  107714. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  107715. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  107716. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  107717. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  107718. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  107719. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  107720. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  107721. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  107722. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  107723. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  107724. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  107725. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  107726. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107727. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107728. setFloat(uniform: WebGLUniformLocation, value: number): void;
  107729. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  107730. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  107731. setBool(uniform: WebGLUniformLocation, bool: number): void;
  107732. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  107733. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107734. bindBuffers(vertexBuffers: {
  107735. [key: string]: VertexBuffer;
  107736. }, indexBuffer: DataBuffer, effect: Effect): void;
  107737. wipeCaches(bruteForce?: boolean): void;
  107738. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  107739. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  107740. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107741. /** @hidden */
  107742. _createTexture(): WebGLTexture;
  107743. /** @hidden */
  107744. _releaseTexture(texture: InternalTexture): void;
  107745. 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;
  107746. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  107747. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  107748. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  107749. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107750. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  107751. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  107752. areAllEffectsReady(): boolean;
  107753. /**
  107754. * @hidden
  107755. * Get the current error code of the webGL context
  107756. * @returns the error code
  107757. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  107758. */
  107759. getError(): number;
  107760. /** @hidden */
  107761. _getUnpackAlignement(): number;
  107762. /** @hidden */
  107763. _unpackFlipY(value: boolean): void;
  107764. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  107765. /**
  107766. * Updates a dynamic vertex buffer.
  107767. * @param vertexBuffer the vertex buffer to update
  107768. * @param data the data used to update the vertex buffer
  107769. * @param byteOffset the byte offset of the data (optional)
  107770. * @param byteLength the byte length of the data (optional)
  107771. */
  107772. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  107773. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  107774. /** @hidden */
  107775. _bindTexture(channel: number, texture: InternalTexture): void;
  107776. /** @hidden */
  107777. _releaseBuffer(buffer: DataBuffer): boolean;
  107778. releaseEffects(): void;
  107779. displayLoadingUI(): void;
  107780. hideLoadingUI(): void;
  107781. /** @hidden */
  107782. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107783. /** @hidden */
  107784. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107785. /** @hidden */
  107786. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107787. /** @hidden */
  107788. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  107789. }
  107790. }
  107791. declare module BABYLON {
  107792. /** @hidden */
  107793. export class _OcclusionDataStorage {
  107794. /** @hidden */
  107795. occlusionInternalRetryCounter: number;
  107796. /** @hidden */
  107797. isOcclusionQueryInProgress: boolean;
  107798. /** @hidden */
  107799. isOccluded: boolean;
  107800. /** @hidden */
  107801. occlusionRetryCount: number;
  107802. /** @hidden */
  107803. occlusionType: number;
  107804. /** @hidden */
  107805. occlusionQueryAlgorithmType: number;
  107806. }
  107807. interface Engine {
  107808. /**
  107809. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  107810. * @return the new query
  107811. */
  107812. createQuery(): WebGLQuery;
  107813. /**
  107814. * Delete and release a webGL query
  107815. * @param query defines the query to delete
  107816. * @return the current engine
  107817. */
  107818. deleteQuery(query: WebGLQuery): Engine;
  107819. /**
  107820. * Check if a given query has resolved and got its value
  107821. * @param query defines the query to check
  107822. * @returns true if the query got its value
  107823. */
  107824. isQueryResultAvailable(query: WebGLQuery): boolean;
  107825. /**
  107826. * Gets the value of a given query
  107827. * @param query defines the query to check
  107828. * @returns the value of the query
  107829. */
  107830. getQueryResult(query: WebGLQuery): number;
  107831. /**
  107832. * Initiates an occlusion query
  107833. * @param algorithmType defines the algorithm to use
  107834. * @param query defines the query to use
  107835. * @returns the current engine
  107836. * @see http://doc.babylonjs.com/features/occlusionquery
  107837. */
  107838. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  107839. /**
  107840. * Ends an occlusion query
  107841. * @see http://doc.babylonjs.com/features/occlusionquery
  107842. * @param algorithmType defines the algorithm to use
  107843. * @returns the current engine
  107844. */
  107845. endOcclusionQuery(algorithmType: number): Engine;
  107846. /**
  107847. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  107848. * Please note that only one query can be issued at a time
  107849. * @returns a time token used to track the time span
  107850. */
  107851. startTimeQuery(): Nullable<_TimeToken>;
  107852. /**
  107853. * Ends a time query
  107854. * @param token defines the token used to measure the time span
  107855. * @returns the time spent (in ns)
  107856. */
  107857. endTimeQuery(token: _TimeToken): int;
  107858. /** @hidden */
  107859. _currentNonTimestampToken: Nullable<_TimeToken>;
  107860. /** @hidden */
  107861. _createTimeQuery(): WebGLQuery;
  107862. /** @hidden */
  107863. _deleteTimeQuery(query: WebGLQuery): void;
  107864. /** @hidden */
  107865. _getGlAlgorithmType(algorithmType: number): number;
  107866. /** @hidden */
  107867. _getTimeQueryResult(query: WebGLQuery): any;
  107868. /** @hidden */
  107869. _getTimeQueryAvailability(query: WebGLQuery): any;
  107870. }
  107871. interface AbstractMesh {
  107872. /**
  107873. * Backing filed
  107874. * @hidden
  107875. */
  107876. __occlusionDataStorage: _OcclusionDataStorage;
  107877. /**
  107878. * Access property
  107879. * @hidden
  107880. */
  107881. _occlusionDataStorage: _OcclusionDataStorage;
  107882. /**
  107883. * 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.
  107884. * The default value is -1 which means don't break the query and wait till the result
  107885. * @see http://doc.babylonjs.com/features/occlusionquery
  107886. */
  107887. occlusionRetryCount: number;
  107888. /**
  107889. * 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:
  107890. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  107891. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  107892. * * 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.
  107893. * @see http://doc.babylonjs.com/features/occlusionquery
  107894. */
  107895. occlusionType: number;
  107896. /**
  107897. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  107898. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  107899. * * 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.
  107900. * @see http://doc.babylonjs.com/features/occlusionquery
  107901. */
  107902. occlusionQueryAlgorithmType: number;
  107903. /**
  107904. * 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
  107905. * @see http://doc.babylonjs.com/features/occlusionquery
  107906. */
  107907. isOccluded: boolean;
  107908. /**
  107909. * Flag to check the progress status of the query
  107910. * @see http://doc.babylonjs.com/features/occlusionquery
  107911. */
  107912. isOcclusionQueryInProgress: boolean;
  107913. }
  107914. }
  107915. declare module BABYLON {
  107916. /** @hidden */
  107917. export var _forceTransformFeedbackToBundle: boolean;
  107918. interface Engine {
  107919. /**
  107920. * Creates a webGL transform feedback object
  107921. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  107922. * @returns the webGL transform feedback object
  107923. */
  107924. createTransformFeedback(): WebGLTransformFeedback;
  107925. /**
  107926. * Delete a webGL transform feedback object
  107927. * @param value defines the webGL transform feedback object to delete
  107928. */
  107929. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  107930. /**
  107931. * Bind a webGL transform feedback object to the webgl context
  107932. * @param value defines the webGL transform feedback object to bind
  107933. */
  107934. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  107935. /**
  107936. * Begins a transform feedback operation
  107937. * @param usePoints defines if points or triangles must be used
  107938. */
  107939. beginTransformFeedback(usePoints: boolean): void;
  107940. /**
  107941. * Ends a transform feedback operation
  107942. */
  107943. endTransformFeedback(): void;
  107944. /**
  107945. * Specify the varyings to use with transform feedback
  107946. * @param program defines the associated webGL program
  107947. * @param value defines the list of strings representing the varying names
  107948. */
  107949. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  107950. /**
  107951. * Bind a webGL buffer for a transform feedback operation
  107952. * @param value defines the webGL buffer to bind
  107953. */
  107954. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  107955. }
  107956. }
  107957. declare module BABYLON {
  107958. /**
  107959. * Creation options of the multi render target texture.
  107960. */
  107961. export interface IMultiRenderTargetOptions {
  107962. /**
  107963. * Define if the texture needs to create mip maps after render.
  107964. */
  107965. generateMipMaps?: boolean;
  107966. /**
  107967. * Define the types of all the draw buffers we want to create
  107968. */
  107969. types?: number[];
  107970. /**
  107971. * Define the sampling modes of all the draw buffers we want to create
  107972. */
  107973. samplingModes?: number[];
  107974. /**
  107975. * Define if a depth buffer is required
  107976. */
  107977. generateDepthBuffer?: boolean;
  107978. /**
  107979. * Define if a stencil buffer is required
  107980. */
  107981. generateStencilBuffer?: boolean;
  107982. /**
  107983. * Define if a depth texture is required instead of a depth buffer
  107984. */
  107985. generateDepthTexture?: boolean;
  107986. /**
  107987. * Define the number of desired draw buffers
  107988. */
  107989. textureCount?: number;
  107990. /**
  107991. * Define if aspect ratio should be adapted to the texture or stay the scene one
  107992. */
  107993. doNotChangeAspectRatio?: boolean;
  107994. /**
  107995. * Define the default type of the buffers we are creating
  107996. */
  107997. defaultType?: number;
  107998. }
  107999. /**
  108000. * A multi render target, like a render target provides the ability to render to a texture.
  108001. * Unlike the render target, it can render to several draw buffers in one draw.
  108002. * This is specially interesting in deferred rendering or for any effects requiring more than
  108003. * just one color from a single pass.
  108004. */
  108005. export class MultiRenderTarget extends RenderTargetTexture {
  108006. private _internalTextures;
  108007. private _textures;
  108008. private _multiRenderTargetOptions;
  108009. /**
  108010. * Get if draw buffers are currently supported by the used hardware and browser.
  108011. */
  108012. readonly isSupported: boolean;
  108013. /**
  108014. * Get the list of textures generated by the multi render target.
  108015. */
  108016. readonly textures: Texture[];
  108017. /**
  108018. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  108019. */
  108020. readonly depthTexture: Texture;
  108021. /**
  108022. * Set the wrapping mode on U of all the textures we are rendering to.
  108023. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108024. */
  108025. wrapU: number;
  108026. /**
  108027. * Set the wrapping mode on V of all the textures we are rendering to.
  108028. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108029. */
  108030. wrapV: number;
  108031. /**
  108032. * Instantiate a new multi render target texture.
  108033. * A multi render target, like a render target provides the ability to render to a texture.
  108034. * Unlike the render target, it can render to several draw buffers in one draw.
  108035. * This is specially interesting in deferred rendering or for any effects requiring more than
  108036. * just one color from a single pass.
  108037. * @param name Define the name of the texture
  108038. * @param size Define the size of the buffers to render to
  108039. * @param count Define the number of target we are rendering into
  108040. * @param scene Define the scene the texture belongs to
  108041. * @param options Define the options used to create the multi render target
  108042. */
  108043. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  108044. /** @hidden */
  108045. _rebuild(): void;
  108046. private _createInternalTextures;
  108047. private _createTextures;
  108048. /**
  108049. * Define the number of samples used if MSAA is enabled.
  108050. */
  108051. samples: number;
  108052. /**
  108053. * Resize all the textures in the multi render target.
  108054. * Be carrefull as it will recreate all the data in the new texture.
  108055. * @param size Define the new size
  108056. */
  108057. resize(size: any): void;
  108058. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  108059. /**
  108060. * Dispose the render targets and their associated resources
  108061. */
  108062. dispose(): void;
  108063. /**
  108064. * Release all the underlying texture used as draw buffers.
  108065. */
  108066. releaseInternalTextures(): void;
  108067. }
  108068. }
  108069. declare module BABYLON {
  108070. interface Engine {
  108071. /**
  108072. * Unbind a list of render target textures from the webGL context
  108073. * This is used only when drawBuffer extension or webGL2 are active
  108074. * @param textures defines the render target textures to unbind
  108075. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  108076. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  108077. */
  108078. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  108079. /**
  108080. * Create a multi render target texture
  108081. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  108082. * @param size defines the size of the texture
  108083. * @param options defines the creation options
  108084. * @returns the cube texture as an InternalTexture
  108085. */
  108086. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  108087. /**
  108088. * Update the sample count for a given multiple render target texture
  108089. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108090. * @param textures defines the textures to update
  108091. * @param samples defines the sample count to set
  108092. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108093. */
  108094. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  108095. }
  108096. }
  108097. declare module BABYLON {
  108098. /**
  108099. * Gather the list of clipboard event types as constants.
  108100. */
  108101. export class ClipboardEventTypes {
  108102. /**
  108103. * The clipboard event is fired when a copy command is active (pressed).
  108104. */
  108105. static readonly COPY: number;
  108106. /**
  108107. * The clipboard event is fired when a cut command is active (pressed).
  108108. */
  108109. static readonly CUT: number;
  108110. /**
  108111. * The clipboard event is fired when a paste command is active (pressed).
  108112. */
  108113. static readonly PASTE: number;
  108114. }
  108115. /**
  108116. * This class is used to store clipboard related info for the onClipboardObservable event.
  108117. */
  108118. export class ClipboardInfo {
  108119. /**
  108120. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108121. */
  108122. type: number;
  108123. /**
  108124. * Defines the related dom event
  108125. */
  108126. event: ClipboardEvent;
  108127. /**
  108128. *Creates an instance of ClipboardInfo.
  108129. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  108130. * @param event Defines the related dom event
  108131. */
  108132. constructor(
  108133. /**
  108134. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108135. */
  108136. type: number,
  108137. /**
  108138. * Defines the related dom event
  108139. */
  108140. event: ClipboardEvent);
  108141. /**
  108142. * Get the clipboard event's type from the keycode.
  108143. * @param keyCode Defines the keyCode for the current keyboard event.
  108144. * @return {number}
  108145. */
  108146. static GetTypeFromCharacter(keyCode: number): number;
  108147. }
  108148. }
  108149. declare module BABYLON {
  108150. /**
  108151. * Google Daydream controller
  108152. */
  108153. export class DaydreamController extends WebVRController {
  108154. /**
  108155. * Base Url for the controller model.
  108156. */
  108157. static MODEL_BASE_URL: string;
  108158. /**
  108159. * File name for the controller model.
  108160. */
  108161. static MODEL_FILENAME: string;
  108162. /**
  108163. * Gamepad Id prefix used to identify Daydream Controller.
  108164. */
  108165. static readonly GAMEPAD_ID_PREFIX: string;
  108166. /**
  108167. * Creates a new DaydreamController from a gamepad
  108168. * @param vrGamepad the gamepad that the controller should be created from
  108169. */
  108170. constructor(vrGamepad: any);
  108171. /**
  108172. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108173. * @param scene scene in which to add meshes
  108174. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108175. */
  108176. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108177. /**
  108178. * Called once for each button that changed state since the last frame
  108179. * @param buttonIdx Which button index changed
  108180. * @param state New state of the button
  108181. * @param changes Which properties on the state changed since last frame
  108182. */
  108183. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108184. }
  108185. }
  108186. declare module BABYLON {
  108187. /**
  108188. * Gear VR Controller
  108189. */
  108190. export class GearVRController extends WebVRController {
  108191. /**
  108192. * Base Url for the controller model.
  108193. */
  108194. static MODEL_BASE_URL: string;
  108195. /**
  108196. * File name for the controller model.
  108197. */
  108198. static MODEL_FILENAME: string;
  108199. /**
  108200. * Gamepad Id prefix used to identify this controller.
  108201. */
  108202. static readonly GAMEPAD_ID_PREFIX: string;
  108203. private readonly _buttonIndexToObservableNameMap;
  108204. /**
  108205. * Creates a new GearVRController from a gamepad
  108206. * @param vrGamepad the gamepad that the controller should be created from
  108207. */
  108208. constructor(vrGamepad: any);
  108209. /**
  108210. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108211. * @param scene scene in which to add meshes
  108212. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108213. */
  108214. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108215. /**
  108216. * Called once for each button that changed state since the last frame
  108217. * @param buttonIdx Which button index changed
  108218. * @param state New state of the button
  108219. * @param changes Which properties on the state changed since last frame
  108220. */
  108221. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108222. }
  108223. }
  108224. declare module BABYLON {
  108225. /**
  108226. * Class containing static functions to help procedurally build meshes
  108227. */
  108228. export class PolyhedronBuilder {
  108229. /**
  108230. * Creates a polyhedron mesh
  108231. * * 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
  108232. * * The parameter `size` (positive float, default 1) sets the polygon size
  108233. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108234. * * 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`
  108235. * * 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
  108236. * * 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)`)
  108237. * * 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
  108238. * * 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
  108239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108242. * @param name defines the name of the mesh
  108243. * @param options defines the options used to create the mesh
  108244. * @param scene defines the hosting scene
  108245. * @returns the polyhedron mesh
  108246. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108247. */
  108248. static CreatePolyhedron(name: string, options: {
  108249. type?: number;
  108250. size?: number;
  108251. sizeX?: number;
  108252. sizeY?: number;
  108253. sizeZ?: number;
  108254. custom?: any;
  108255. faceUV?: Vector4[];
  108256. faceColors?: Color4[];
  108257. flat?: boolean;
  108258. updatable?: boolean;
  108259. sideOrientation?: number;
  108260. frontUVs?: Vector4;
  108261. backUVs?: Vector4;
  108262. }, scene?: Nullable<Scene>): Mesh;
  108263. }
  108264. }
  108265. declare module BABYLON {
  108266. /**
  108267. * Gizmo that enables scaling a mesh along 3 axis
  108268. */
  108269. export class ScaleGizmo extends Gizmo {
  108270. /**
  108271. * Internal gizmo used for interactions on the x axis
  108272. */
  108273. xGizmo: AxisScaleGizmo;
  108274. /**
  108275. * Internal gizmo used for interactions on the y axis
  108276. */
  108277. yGizmo: AxisScaleGizmo;
  108278. /**
  108279. * Internal gizmo used for interactions on the z axis
  108280. */
  108281. zGizmo: AxisScaleGizmo;
  108282. /**
  108283. * Internal gizmo used to scale all axis equally
  108284. */
  108285. uniformScaleGizmo: AxisScaleGizmo;
  108286. private _meshAttached;
  108287. private _updateGizmoRotationToMatchAttachedMesh;
  108288. private _snapDistance;
  108289. private _scaleRatio;
  108290. private _uniformScalingMesh;
  108291. private _octahedron;
  108292. /** Fires an event when any of it's sub gizmos are dragged */
  108293. onDragStartObservable: Observable<unknown>;
  108294. /** Fires an event when any of it's sub gizmos are released from dragging */
  108295. onDragEndObservable: Observable<unknown>;
  108296. attachedMesh: Nullable<AbstractMesh>;
  108297. /**
  108298. * Creates a ScaleGizmo
  108299. * @param gizmoLayer The utility layer the gizmo will be added to
  108300. */
  108301. constructor(gizmoLayer?: UtilityLayerRenderer);
  108302. updateGizmoRotationToMatchAttachedMesh: boolean;
  108303. /**
  108304. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108305. */
  108306. snapDistance: number;
  108307. /**
  108308. * Ratio for the scale of the gizmo (Default: 1)
  108309. */
  108310. scaleRatio: number;
  108311. /**
  108312. * Disposes of the gizmo
  108313. */
  108314. dispose(): void;
  108315. }
  108316. }
  108317. declare module BABYLON {
  108318. /**
  108319. * Single axis scale gizmo
  108320. */
  108321. export class AxisScaleGizmo extends Gizmo {
  108322. /**
  108323. * Drag behavior responsible for the gizmos dragging interactions
  108324. */
  108325. dragBehavior: PointerDragBehavior;
  108326. private _pointerObserver;
  108327. /**
  108328. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108329. */
  108330. snapDistance: number;
  108331. /**
  108332. * Event that fires each time the gizmo snaps to a new location.
  108333. * * snapDistance is the the change in distance
  108334. */
  108335. onSnapObservable: Observable<{
  108336. snapDistance: number;
  108337. }>;
  108338. /**
  108339. * If the scaling operation should be done on all axis (default: false)
  108340. */
  108341. uniformScaling: boolean;
  108342. private _isEnabled;
  108343. private _parent;
  108344. private _arrow;
  108345. private _coloredMaterial;
  108346. private _hoverMaterial;
  108347. /**
  108348. * Creates an AxisScaleGizmo
  108349. * @param gizmoLayer The utility layer the gizmo will be added to
  108350. * @param dragAxis The axis which the gizmo will be able to scale on
  108351. * @param color The color of the gizmo
  108352. */
  108353. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  108354. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108355. /**
  108356. * If the gizmo is enabled
  108357. */
  108358. isEnabled: boolean;
  108359. /**
  108360. * Disposes of the gizmo
  108361. */
  108362. dispose(): void;
  108363. /**
  108364. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108365. * @param mesh The mesh to replace the default mesh of the gizmo
  108366. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  108367. */
  108368. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  108369. }
  108370. }
  108371. declare module BABYLON {
  108372. /**
  108373. * Bounding box gizmo
  108374. */
  108375. export class BoundingBoxGizmo extends Gizmo {
  108376. private _lineBoundingBox;
  108377. private _rotateSpheresParent;
  108378. private _scaleBoxesParent;
  108379. private _boundingDimensions;
  108380. private _renderObserver;
  108381. private _pointerObserver;
  108382. private _scaleDragSpeed;
  108383. private _tmpQuaternion;
  108384. private _tmpVector;
  108385. private _tmpRotationMatrix;
  108386. /**
  108387. * 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)
  108388. */
  108389. ignoreChildren: boolean;
  108390. /**
  108391. * 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)
  108392. */
  108393. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  108394. /**
  108395. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  108396. */
  108397. rotationSphereSize: number;
  108398. /**
  108399. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  108400. */
  108401. scaleBoxSize: number;
  108402. /**
  108403. * 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)
  108404. */
  108405. fixedDragMeshScreenSize: boolean;
  108406. /**
  108407. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  108408. */
  108409. fixedDragMeshScreenSizeDistanceFactor: number;
  108410. /**
  108411. * Fired when a rotation sphere or scale box is dragged
  108412. */
  108413. onDragStartObservable: Observable<{}>;
  108414. /**
  108415. * Fired when a scale box is dragged
  108416. */
  108417. onScaleBoxDragObservable: Observable<{}>;
  108418. /**
  108419. * Fired when a scale box drag is ended
  108420. */
  108421. onScaleBoxDragEndObservable: Observable<{}>;
  108422. /**
  108423. * Fired when a rotation sphere is dragged
  108424. */
  108425. onRotationSphereDragObservable: Observable<{}>;
  108426. /**
  108427. * Fired when a rotation sphere drag is ended
  108428. */
  108429. onRotationSphereDragEndObservable: Observable<{}>;
  108430. /**
  108431. * 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)
  108432. */
  108433. scalePivot: Nullable<Vector3>;
  108434. /**
  108435. * Mesh used as a pivot to rotate the attached mesh
  108436. */
  108437. private _anchorMesh;
  108438. private _existingMeshScale;
  108439. private _dragMesh;
  108440. private pointerDragBehavior;
  108441. private coloredMaterial;
  108442. private hoverColoredMaterial;
  108443. /**
  108444. * Sets the color of the bounding box gizmo
  108445. * @param color the color to set
  108446. */
  108447. setColor(color: Color3): void;
  108448. /**
  108449. * Creates an BoundingBoxGizmo
  108450. * @param gizmoLayer The utility layer the gizmo will be added to
  108451. * @param color The color of the gizmo
  108452. */
  108453. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  108454. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108455. private _selectNode;
  108456. /**
  108457. * Updates the bounding box information for the Gizmo
  108458. */
  108459. updateBoundingBox(): void;
  108460. private _updateRotationSpheres;
  108461. private _updateScaleBoxes;
  108462. /**
  108463. * Enables rotation on the specified axis and disables rotation on the others
  108464. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  108465. */
  108466. setEnabledRotationAxis(axis: string): void;
  108467. /**
  108468. * Enables/disables scaling
  108469. * @param enable if scaling should be enabled
  108470. */
  108471. setEnabledScaling(enable: boolean): void;
  108472. private _updateDummy;
  108473. /**
  108474. * Enables a pointer drag behavior on the bounding box of the gizmo
  108475. */
  108476. enableDragBehavior(): void;
  108477. /**
  108478. * Disposes of the gizmo
  108479. */
  108480. dispose(): void;
  108481. /**
  108482. * 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)
  108483. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  108484. * @returns the bounding box mesh with the passed in mesh as a child
  108485. */
  108486. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  108487. /**
  108488. * CustomMeshes are not supported by this gizmo
  108489. * @param mesh The mesh to replace the default mesh of the gizmo
  108490. */
  108491. setCustomMesh(mesh: Mesh): void;
  108492. }
  108493. }
  108494. declare module BABYLON {
  108495. /**
  108496. * Single plane rotation gizmo
  108497. */
  108498. export class PlaneRotationGizmo extends Gizmo {
  108499. /**
  108500. * Drag behavior responsible for the gizmos dragging interactions
  108501. */
  108502. dragBehavior: PointerDragBehavior;
  108503. private _pointerObserver;
  108504. /**
  108505. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  108506. */
  108507. snapDistance: number;
  108508. /**
  108509. * Event that fires each time the gizmo snaps to a new location.
  108510. * * snapDistance is the the change in distance
  108511. */
  108512. onSnapObservable: Observable<{
  108513. snapDistance: number;
  108514. }>;
  108515. private _isEnabled;
  108516. private _parent;
  108517. /**
  108518. * Creates a PlaneRotationGizmo
  108519. * @param gizmoLayer The utility layer the gizmo will be added to
  108520. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  108521. * @param color The color of the gizmo
  108522. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108523. * @param useEulerRotation Use and update Euler angle instead of quaternion
  108524. */
  108525. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  108526. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108527. /**
  108528. * If the gizmo is enabled
  108529. */
  108530. isEnabled: boolean;
  108531. /**
  108532. * Disposes of the gizmo
  108533. */
  108534. dispose(): void;
  108535. }
  108536. }
  108537. declare module BABYLON {
  108538. /**
  108539. * Gizmo that enables rotating a mesh along 3 axis
  108540. */
  108541. export class RotationGizmo extends Gizmo {
  108542. /**
  108543. * Internal gizmo used for interactions on the x axis
  108544. */
  108545. xGizmo: PlaneRotationGizmo;
  108546. /**
  108547. * Internal gizmo used for interactions on the y axis
  108548. */
  108549. yGizmo: PlaneRotationGizmo;
  108550. /**
  108551. * Internal gizmo used for interactions on the z axis
  108552. */
  108553. zGizmo: PlaneRotationGizmo;
  108554. /** Fires an event when any of it's sub gizmos are dragged */
  108555. onDragStartObservable: Observable<unknown>;
  108556. /** Fires an event when any of it's sub gizmos are released from dragging */
  108557. onDragEndObservable: Observable<unknown>;
  108558. private _meshAttached;
  108559. attachedMesh: Nullable<AbstractMesh>;
  108560. /**
  108561. * Creates a RotationGizmo
  108562. * @param gizmoLayer The utility layer the gizmo will be added to
  108563. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108564. * @param useEulerRotation Use and update Euler angle instead of quaternion
  108565. */
  108566. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  108567. updateGizmoRotationToMatchAttachedMesh: boolean;
  108568. /**
  108569. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108570. */
  108571. snapDistance: number;
  108572. /**
  108573. * Ratio for the scale of the gizmo (Default: 1)
  108574. */
  108575. scaleRatio: number;
  108576. /**
  108577. * Disposes of the gizmo
  108578. */
  108579. dispose(): void;
  108580. /**
  108581. * CustomMeshes are not supported by this gizmo
  108582. * @param mesh The mesh to replace the default mesh of the gizmo
  108583. */
  108584. setCustomMesh(mesh: Mesh): void;
  108585. }
  108586. }
  108587. declare module BABYLON {
  108588. /**
  108589. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  108590. */
  108591. export class GizmoManager implements IDisposable {
  108592. private scene;
  108593. /**
  108594. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  108595. */
  108596. gizmos: {
  108597. positionGizmo: Nullable<PositionGizmo>;
  108598. rotationGizmo: Nullable<RotationGizmo>;
  108599. scaleGizmo: Nullable<ScaleGizmo>;
  108600. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  108601. };
  108602. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  108603. clearGizmoOnEmptyPointerEvent: boolean;
  108604. /** Fires an event when the manager is attached to a mesh */
  108605. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  108606. private _gizmosEnabled;
  108607. private _pointerObserver;
  108608. private _attachedMesh;
  108609. private _boundingBoxColor;
  108610. private _defaultUtilityLayer;
  108611. private _defaultKeepDepthUtilityLayer;
  108612. /**
  108613. * When bounding box gizmo is enabled, this can be used to track drag/end events
  108614. */
  108615. boundingBoxDragBehavior: SixDofDragBehavior;
  108616. /**
  108617. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  108618. */
  108619. attachableMeshes: Nullable<Array<AbstractMesh>>;
  108620. /**
  108621. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  108622. */
  108623. usePointerToAttachGizmos: boolean;
  108624. /**
  108625. * Utility layer that the bounding box gizmo belongs to
  108626. */
  108627. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  108628. /**
  108629. * Utility layer that all gizmos besides bounding box belong to
  108630. */
  108631. readonly utilityLayer: UtilityLayerRenderer;
  108632. /**
  108633. * Instatiates a gizmo manager
  108634. * @param scene the scene to overlay the gizmos on top of
  108635. */
  108636. constructor(scene: Scene);
  108637. /**
  108638. * Attaches a set of gizmos to the specified mesh
  108639. * @param mesh The mesh the gizmo's should be attached to
  108640. */
  108641. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108642. /**
  108643. * If the position gizmo is enabled
  108644. */
  108645. positionGizmoEnabled: boolean;
  108646. /**
  108647. * If the rotation gizmo is enabled
  108648. */
  108649. rotationGizmoEnabled: boolean;
  108650. /**
  108651. * If the scale gizmo is enabled
  108652. */
  108653. scaleGizmoEnabled: boolean;
  108654. /**
  108655. * If the boundingBox gizmo is enabled
  108656. */
  108657. boundingBoxGizmoEnabled: boolean;
  108658. /**
  108659. * Disposes of the gizmo manager
  108660. */
  108661. dispose(): void;
  108662. }
  108663. }
  108664. declare module BABYLON {
  108665. /**
  108666. * A directional light is defined by a direction (what a surprise!).
  108667. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  108668. * 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.
  108669. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108670. */
  108671. export class DirectionalLight extends ShadowLight {
  108672. private _shadowFrustumSize;
  108673. /**
  108674. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  108675. */
  108676. /**
  108677. * Specifies a fix frustum size for the shadow generation.
  108678. */
  108679. shadowFrustumSize: number;
  108680. private _shadowOrthoScale;
  108681. /**
  108682. * Gets the shadow projection scale against the optimal computed one.
  108683. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108684. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108685. */
  108686. /**
  108687. * Sets the shadow projection scale against the optimal computed one.
  108688. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108689. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108690. */
  108691. shadowOrthoScale: number;
  108692. /**
  108693. * Automatically compute the projection matrix to best fit (including all the casters)
  108694. * on each frame.
  108695. */
  108696. autoUpdateExtends: boolean;
  108697. private _orthoLeft;
  108698. private _orthoRight;
  108699. private _orthoTop;
  108700. private _orthoBottom;
  108701. /**
  108702. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  108703. * The directional light is emitted from everywhere in the given direction.
  108704. * It can cast shadows.
  108705. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108706. * @param name The friendly name of the light
  108707. * @param direction The direction of the light
  108708. * @param scene The scene the light belongs to
  108709. */
  108710. constructor(name: string, direction: Vector3, scene: Scene);
  108711. /**
  108712. * Returns the string "DirectionalLight".
  108713. * @return The class name
  108714. */
  108715. getClassName(): string;
  108716. /**
  108717. * Returns the integer 1.
  108718. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108719. */
  108720. getTypeID(): number;
  108721. /**
  108722. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  108723. * Returns the DirectionalLight Shadow projection matrix.
  108724. */
  108725. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108726. /**
  108727. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  108728. * Returns the DirectionalLight Shadow projection matrix.
  108729. */
  108730. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  108731. /**
  108732. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  108733. * Returns the DirectionalLight Shadow projection matrix.
  108734. */
  108735. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108736. protected _buildUniformLayout(): void;
  108737. /**
  108738. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  108739. * @param effect The effect to update
  108740. * @param lightIndex The index of the light in the effect to update
  108741. * @returns The directional light
  108742. */
  108743. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  108744. /**
  108745. * Gets the minZ used for shadow according to both the scene and the light.
  108746. *
  108747. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108748. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108749. * @param activeCamera The camera we are returning the min for
  108750. * @returns the depth min z
  108751. */
  108752. getDepthMinZ(activeCamera: Camera): number;
  108753. /**
  108754. * Gets the maxZ used for shadow according to both the scene and the light.
  108755. *
  108756. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108757. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108758. * @param activeCamera The camera we are returning the max for
  108759. * @returns the depth max z
  108760. */
  108761. getDepthMaxZ(activeCamera: Camera): number;
  108762. /**
  108763. * Prepares the list of defines specific to the light type.
  108764. * @param defines the list of defines
  108765. * @param lightIndex defines the index of the light for the effect
  108766. */
  108767. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108768. }
  108769. }
  108770. declare module BABYLON {
  108771. /**
  108772. * Class containing static functions to help procedurally build meshes
  108773. */
  108774. export class HemisphereBuilder {
  108775. /**
  108776. * Creates a hemisphere mesh
  108777. * @param name defines the name of the mesh
  108778. * @param options defines the options used to create the mesh
  108779. * @param scene defines the hosting scene
  108780. * @returns the hemisphere mesh
  108781. */
  108782. static CreateHemisphere(name: string, options: {
  108783. segments?: number;
  108784. diameter?: number;
  108785. sideOrientation?: number;
  108786. }, scene: any): Mesh;
  108787. }
  108788. }
  108789. declare module BABYLON {
  108790. /**
  108791. * A spot light is defined by a position, a direction, an angle, and an exponent.
  108792. * These values define a cone of light starting from the position, emitting toward the direction.
  108793. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  108794. * and the exponent defines the speed of the decay of the light with distance (reach).
  108795. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108796. */
  108797. export class SpotLight extends ShadowLight {
  108798. private _angle;
  108799. private _innerAngle;
  108800. private _cosHalfAngle;
  108801. private _lightAngleScale;
  108802. private _lightAngleOffset;
  108803. /**
  108804. * Gets the cone angle of the spot light in Radians.
  108805. */
  108806. /**
  108807. * Sets the cone angle of the spot light in Radians.
  108808. */
  108809. angle: number;
  108810. /**
  108811. * Only used in gltf falloff mode, this defines the angle where
  108812. * the directional falloff will start before cutting at angle which could be seen
  108813. * as outer angle.
  108814. */
  108815. /**
  108816. * Only used in gltf falloff mode, this defines the angle where
  108817. * the directional falloff will start before cutting at angle which could be seen
  108818. * as outer angle.
  108819. */
  108820. innerAngle: number;
  108821. private _shadowAngleScale;
  108822. /**
  108823. * Allows scaling the angle of the light for shadow generation only.
  108824. */
  108825. /**
  108826. * Allows scaling the angle of the light for shadow generation only.
  108827. */
  108828. shadowAngleScale: number;
  108829. /**
  108830. * The light decay speed with the distance from the emission spot.
  108831. */
  108832. exponent: number;
  108833. private _projectionTextureMatrix;
  108834. /**
  108835. * Allows reading the projecton texture
  108836. */
  108837. readonly projectionTextureMatrix: Matrix;
  108838. protected _projectionTextureLightNear: number;
  108839. /**
  108840. * Gets the near clip of the Spotlight for texture projection.
  108841. */
  108842. /**
  108843. * Sets the near clip of the Spotlight for texture projection.
  108844. */
  108845. projectionTextureLightNear: number;
  108846. protected _projectionTextureLightFar: number;
  108847. /**
  108848. * Gets the far clip of the Spotlight for texture projection.
  108849. */
  108850. /**
  108851. * Sets the far clip of the Spotlight for texture projection.
  108852. */
  108853. projectionTextureLightFar: number;
  108854. protected _projectionTextureUpDirection: Vector3;
  108855. /**
  108856. * Gets the Up vector of the Spotlight for texture projection.
  108857. */
  108858. /**
  108859. * Sets the Up vector of the Spotlight for texture projection.
  108860. */
  108861. projectionTextureUpDirection: Vector3;
  108862. private _projectionTexture;
  108863. /**
  108864. * Gets the projection texture of the light.
  108865. */
  108866. /**
  108867. * Sets the projection texture of the light.
  108868. */
  108869. projectionTexture: Nullable<BaseTexture>;
  108870. private _projectionTextureViewLightDirty;
  108871. private _projectionTextureProjectionLightDirty;
  108872. private _projectionTextureDirty;
  108873. private _projectionTextureViewTargetVector;
  108874. private _projectionTextureViewLightMatrix;
  108875. private _projectionTextureProjectionLightMatrix;
  108876. private _projectionTextureScalingMatrix;
  108877. /**
  108878. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  108879. * It can cast shadows.
  108880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108881. * @param name The light friendly name
  108882. * @param position The position of the spot light in the scene
  108883. * @param direction The direction of the light in the scene
  108884. * @param angle The cone angle of the light in Radians
  108885. * @param exponent The light decay speed with the distance from the emission spot
  108886. * @param scene The scene the lights belongs to
  108887. */
  108888. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  108889. /**
  108890. * Returns the string "SpotLight".
  108891. * @returns the class name
  108892. */
  108893. getClassName(): string;
  108894. /**
  108895. * Returns the integer 2.
  108896. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108897. */
  108898. getTypeID(): number;
  108899. /**
  108900. * Overrides the direction setter to recompute the projection texture view light Matrix.
  108901. */
  108902. protected _setDirection(value: Vector3): void;
  108903. /**
  108904. * Overrides the position setter to recompute the projection texture view light Matrix.
  108905. */
  108906. protected _setPosition(value: Vector3): void;
  108907. /**
  108908. * 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.
  108909. * Returns the SpotLight.
  108910. */
  108911. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108912. protected _computeProjectionTextureViewLightMatrix(): void;
  108913. protected _computeProjectionTextureProjectionLightMatrix(): void;
  108914. /**
  108915. * Main function for light texture projection matrix computing.
  108916. */
  108917. protected _computeProjectionTextureMatrix(): void;
  108918. protected _buildUniformLayout(): void;
  108919. private _computeAngleValues;
  108920. /**
  108921. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  108922. * @param effect The effect to update
  108923. * @param lightIndex The index of the light in the effect to update
  108924. * @returns The spot light
  108925. */
  108926. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  108927. /**
  108928. * Disposes the light and the associated resources.
  108929. */
  108930. dispose(): void;
  108931. /**
  108932. * Prepares the list of defines specific to the light type.
  108933. * @param defines the list of defines
  108934. * @param lightIndex defines the index of the light for the effect
  108935. */
  108936. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108937. }
  108938. }
  108939. declare module BABYLON {
  108940. /**
  108941. * Gizmo that enables viewing a light
  108942. */
  108943. export class LightGizmo extends Gizmo {
  108944. private _lightMesh;
  108945. private _material;
  108946. private cachedPosition;
  108947. private cachedForward;
  108948. /**
  108949. * Creates a LightGizmo
  108950. * @param gizmoLayer The utility layer the gizmo will be added to
  108951. */
  108952. constructor(gizmoLayer?: UtilityLayerRenderer);
  108953. private _light;
  108954. /**
  108955. * The light that the gizmo is attached to
  108956. */
  108957. light: Nullable<Light>;
  108958. /**
  108959. * Gets the material used to render the light gizmo
  108960. */
  108961. readonly material: StandardMaterial;
  108962. /**
  108963. * @hidden
  108964. * Updates the gizmo to match the attached mesh's position/rotation
  108965. */
  108966. protected _update(): void;
  108967. private static _Scale;
  108968. /**
  108969. * Creates the lines for a light mesh
  108970. */
  108971. private static _createLightLines;
  108972. /**
  108973. * Disposes of the light gizmo
  108974. */
  108975. dispose(): void;
  108976. private static _CreateHemisphericLightMesh;
  108977. private static _CreatePointLightMesh;
  108978. private static _CreateSpotLightMesh;
  108979. private static _CreateDirectionalLightMesh;
  108980. }
  108981. }
  108982. declare module BABYLON {
  108983. /** @hidden */
  108984. export var backgroundFragmentDeclaration: {
  108985. name: string;
  108986. shader: string;
  108987. };
  108988. }
  108989. declare module BABYLON {
  108990. /** @hidden */
  108991. export var backgroundUboDeclaration: {
  108992. name: string;
  108993. shader: string;
  108994. };
  108995. }
  108996. declare module BABYLON {
  108997. /** @hidden */
  108998. export var backgroundPixelShader: {
  108999. name: string;
  109000. shader: string;
  109001. };
  109002. }
  109003. declare module BABYLON {
  109004. /** @hidden */
  109005. export var backgroundVertexDeclaration: {
  109006. name: string;
  109007. shader: string;
  109008. };
  109009. }
  109010. declare module BABYLON {
  109011. /** @hidden */
  109012. export var backgroundVertexShader: {
  109013. name: string;
  109014. shader: string;
  109015. };
  109016. }
  109017. declare module BABYLON {
  109018. /**
  109019. * Background material used to create an efficient environement around your scene.
  109020. */
  109021. export class BackgroundMaterial extends PushMaterial {
  109022. /**
  109023. * Standard reflectance value at parallel view angle.
  109024. */
  109025. static StandardReflectance0: number;
  109026. /**
  109027. * Standard reflectance value at grazing angle.
  109028. */
  109029. static StandardReflectance90: number;
  109030. protected _primaryColor: Color3;
  109031. /**
  109032. * Key light Color (multiply against the environement texture)
  109033. */
  109034. primaryColor: Color3;
  109035. protected __perceptualColor: Nullable<Color3>;
  109036. /**
  109037. * Experimental Internal Use Only.
  109038. *
  109039. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  109040. * This acts as a helper to set the primary color to a more "human friendly" value.
  109041. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  109042. * output color as close as possible from the chosen value.
  109043. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  109044. * part of lighting setup.)
  109045. */
  109046. _perceptualColor: Nullable<Color3>;
  109047. protected _primaryColorShadowLevel: float;
  109048. /**
  109049. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  109050. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  109051. */
  109052. primaryColorShadowLevel: float;
  109053. protected _primaryColorHighlightLevel: float;
  109054. /**
  109055. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  109056. * The primary color is used at the level chosen to define what the white area would look.
  109057. */
  109058. primaryColorHighlightLevel: float;
  109059. protected _reflectionTexture: Nullable<BaseTexture>;
  109060. /**
  109061. * Reflection Texture used in the material.
  109062. * Should be author in a specific way for the best result (refer to the documentation).
  109063. */
  109064. reflectionTexture: Nullable<BaseTexture>;
  109065. protected _reflectionBlur: float;
  109066. /**
  109067. * Reflection Texture level of blur.
  109068. *
  109069. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  109070. * texture twice.
  109071. */
  109072. reflectionBlur: float;
  109073. protected _diffuseTexture: Nullable<BaseTexture>;
  109074. /**
  109075. * Diffuse Texture used in the material.
  109076. * Should be author in a specific way for the best result (refer to the documentation).
  109077. */
  109078. diffuseTexture: Nullable<BaseTexture>;
  109079. protected _shadowLights: Nullable<IShadowLight[]>;
  109080. /**
  109081. * Specify the list of lights casting shadow on the material.
  109082. * All scene shadow lights will be included if null.
  109083. */
  109084. shadowLights: Nullable<IShadowLight[]>;
  109085. protected _shadowLevel: float;
  109086. /**
  109087. * Helps adjusting the shadow to a softer level if required.
  109088. * 0 means black shadows and 1 means no shadows.
  109089. */
  109090. shadowLevel: float;
  109091. protected _sceneCenter: Vector3;
  109092. /**
  109093. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  109094. * It is usually zero but might be interesting to modify according to your setup.
  109095. */
  109096. sceneCenter: Vector3;
  109097. protected _opacityFresnel: boolean;
  109098. /**
  109099. * This helps specifying that the material is falling off to the sky box at grazing angle.
  109100. * This helps ensuring a nice transition when the camera goes under the ground.
  109101. */
  109102. opacityFresnel: boolean;
  109103. protected _reflectionFresnel: boolean;
  109104. /**
  109105. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  109106. * This helps adding a mirror texture on the ground.
  109107. */
  109108. reflectionFresnel: boolean;
  109109. protected _reflectionFalloffDistance: number;
  109110. /**
  109111. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  109112. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  109113. */
  109114. reflectionFalloffDistance: number;
  109115. protected _reflectionAmount: number;
  109116. /**
  109117. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  109118. */
  109119. reflectionAmount: number;
  109120. protected _reflectionReflectance0: number;
  109121. /**
  109122. * This specifies the weight of the reflection at grazing angle.
  109123. */
  109124. reflectionReflectance0: number;
  109125. protected _reflectionReflectance90: number;
  109126. /**
  109127. * This specifies the weight of the reflection at a perpendicular point of view.
  109128. */
  109129. reflectionReflectance90: number;
  109130. /**
  109131. * Sets the reflection reflectance fresnel values according to the default standard
  109132. * empirically know to work well :-)
  109133. */
  109134. reflectionStandardFresnelWeight: number;
  109135. protected _useRGBColor: boolean;
  109136. /**
  109137. * Helps to directly use the maps channels instead of their level.
  109138. */
  109139. useRGBColor: boolean;
  109140. protected _enableNoise: boolean;
  109141. /**
  109142. * This helps reducing the banding effect that could occur on the background.
  109143. */
  109144. enableNoise: boolean;
  109145. /**
  109146. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109147. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  109148. * Recommended to be keep at 1.0 except for special cases.
  109149. */
  109150. fovMultiplier: number;
  109151. private _fovMultiplier;
  109152. /**
  109153. * Enable the FOV adjustment feature controlled by fovMultiplier.
  109154. */
  109155. useEquirectangularFOV: boolean;
  109156. private _maxSimultaneousLights;
  109157. /**
  109158. * Number of Simultaneous lights allowed on the material.
  109159. */
  109160. maxSimultaneousLights: int;
  109161. /**
  109162. * Default configuration related to image processing available in the Background Material.
  109163. */
  109164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109165. /**
  109166. * Keep track of the image processing observer to allow dispose and replace.
  109167. */
  109168. private _imageProcessingObserver;
  109169. /**
  109170. * Attaches a new image processing configuration to the PBR Material.
  109171. * @param configuration (if null the scene configuration will be use)
  109172. */
  109173. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109174. /**
  109175. * Gets the image processing configuration used either in this material.
  109176. */
  109177. /**
  109178. * Sets the Default image processing configuration used either in the this material.
  109179. *
  109180. * If sets to null, the scene one is in use.
  109181. */
  109182. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  109183. /**
  109184. * Gets wether the color curves effect is enabled.
  109185. */
  109186. /**
  109187. * Sets wether the color curves effect is enabled.
  109188. */
  109189. cameraColorCurvesEnabled: boolean;
  109190. /**
  109191. * Gets wether the color grading effect is enabled.
  109192. */
  109193. /**
  109194. * Gets wether the color grading effect is enabled.
  109195. */
  109196. cameraColorGradingEnabled: boolean;
  109197. /**
  109198. * Gets wether tonemapping is enabled or not.
  109199. */
  109200. /**
  109201. * Sets wether tonemapping is enabled or not
  109202. */
  109203. cameraToneMappingEnabled: boolean;
  109204. /**
  109205. * The camera exposure used on this material.
  109206. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109207. * This corresponds to a photographic exposure.
  109208. */
  109209. /**
  109210. * The camera exposure used on this material.
  109211. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109212. * This corresponds to a photographic exposure.
  109213. */
  109214. cameraExposure: float;
  109215. /**
  109216. * Gets The camera contrast used on this material.
  109217. */
  109218. /**
  109219. * Sets The camera contrast used on this material.
  109220. */
  109221. cameraContrast: float;
  109222. /**
  109223. * Gets the Color Grading 2D Lookup Texture.
  109224. */
  109225. /**
  109226. * Sets the Color Grading 2D Lookup Texture.
  109227. */
  109228. cameraColorGradingTexture: Nullable<BaseTexture>;
  109229. /**
  109230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109232. * 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;
  109233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109234. */
  109235. /**
  109236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109238. * 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;
  109239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109240. */
  109241. cameraColorCurves: Nullable<ColorCurves>;
  109242. /**
  109243. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  109244. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  109245. */
  109246. switchToBGR: boolean;
  109247. private _renderTargets;
  109248. private _reflectionControls;
  109249. private _white;
  109250. private _primaryShadowColor;
  109251. private _primaryHighlightColor;
  109252. /**
  109253. * Instantiates a Background Material in the given scene
  109254. * @param name The friendly name of the material
  109255. * @param scene The scene to add the material to
  109256. */
  109257. constructor(name: string, scene: Scene);
  109258. /**
  109259. * Gets a boolean indicating that current material needs to register RTT
  109260. */
  109261. readonly hasRenderTargetTextures: boolean;
  109262. /**
  109263. * The entire material has been created in order to prevent overdraw.
  109264. * @returns false
  109265. */
  109266. needAlphaTesting(): boolean;
  109267. /**
  109268. * The entire material has been created in order to prevent overdraw.
  109269. * @returns true if blending is enable
  109270. */
  109271. needAlphaBlending(): boolean;
  109272. /**
  109273. * Checks wether the material is ready to be rendered for a given mesh.
  109274. * @param mesh The mesh to render
  109275. * @param subMesh The submesh to check against
  109276. * @param useInstances Specify wether or not the material is used with instances
  109277. * @returns true if all the dependencies are ready (Textures, Effects...)
  109278. */
  109279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109280. /**
  109281. * Compute the primary color according to the chosen perceptual color.
  109282. */
  109283. private _computePrimaryColorFromPerceptualColor;
  109284. /**
  109285. * Compute the highlights and shadow colors according to their chosen levels.
  109286. */
  109287. private _computePrimaryColors;
  109288. /**
  109289. * Build the uniform buffer used in the material.
  109290. */
  109291. buildUniformLayout(): void;
  109292. /**
  109293. * Unbind the material.
  109294. */
  109295. unbind(): void;
  109296. /**
  109297. * Bind only the world matrix to the material.
  109298. * @param world The world matrix to bind.
  109299. */
  109300. bindOnlyWorldMatrix(world: Matrix): void;
  109301. /**
  109302. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  109303. * @param world The world matrix to bind.
  109304. * @param subMesh The submesh to bind for.
  109305. */
  109306. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109307. /**
  109308. * Dispose the material.
  109309. * @param forceDisposeEffect Force disposal of the associated effect.
  109310. * @param forceDisposeTextures Force disposal of the associated textures.
  109311. */
  109312. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109313. /**
  109314. * Clones the material.
  109315. * @param name The cloned name.
  109316. * @returns The cloned material.
  109317. */
  109318. clone(name: string): BackgroundMaterial;
  109319. /**
  109320. * Serializes the current material to its JSON representation.
  109321. * @returns The JSON representation.
  109322. */
  109323. serialize(): any;
  109324. /**
  109325. * Gets the class name of the material
  109326. * @returns "BackgroundMaterial"
  109327. */
  109328. getClassName(): string;
  109329. /**
  109330. * Parse a JSON input to create back a background material.
  109331. * @param source The JSON data to parse
  109332. * @param scene The scene to create the parsed material in
  109333. * @param rootUrl The root url of the assets the material depends upon
  109334. * @returns the instantiated BackgroundMaterial.
  109335. */
  109336. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  109337. }
  109338. }
  109339. declare module BABYLON {
  109340. /**
  109341. * Represents the different options available during the creation of
  109342. * a Environment helper.
  109343. *
  109344. * This can control the default ground, skybox and image processing setup of your scene.
  109345. */
  109346. export interface IEnvironmentHelperOptions {
  109347. /**
  109348. * Specifies wether or not to create a ground.
  109349. * True by default.
  109350. */
  109351. createGround: boolean;
  109352. /**
  109353. * Specifies the ground size.
  109354. * 15 by default.
  109355. */
  109356. groundSize: number;
  109357. /**
  109358. * The texture used on the ground for the main color.
  109359. * Comes from the BabylonJS CDN by default.
  109360. *
  109361. * Remarks: Can be either a texture or a url.
  109362. */
  109363. groundTexture: string | BaseTexture;
  109364. /**
  109365. * The color mixed in the ground texture by default.
  109366. * BabylonJS clearColor by default.
  109367. */
  109368. groundColor: Color3;
  109369. /**
  109370. * Specifies the ground opacity.
  109371. * 1 by default.
  109372. */
  109373. groundOpacity: number;
  109374. /**
  109375. * Enables the ground to receive shadows.
  109376. * True by default.
  109377. */
  109378. enableGroundShadow: boolean;
  109379. /**
  109380. * Helps preventing the shadow to be fully black on the ground.
  109381. * 0.5 by default.
  109382. */
  109383. groundShadowLevel: number;
  109384. /**
  109385. * Creates a mirror texture attach to the ground.
  109386. * false by default.
  109387. */
  109388. enableGroundMirror: boolean;
  109389. /**
  109390. * Specifies the ground mirror size ratio.
  109391. * 0.3 by default as the default kernel is 64.
  109392. */
  109393. groundMirrorSizeRatio: number;
  109394. /**
  109395. * Specifies the ground mirror blur kernel size.
  109396. * 64 by default.
  109397. */
  109398. groundMirrorBlurKernel: number;
  109399. /**
  109400. * Specifies the ground mirror visibility amount.
  109401. * 1 by default
  109402. */
  109403. groundMirrorAmount: number;
  109404. /**
  109405. * Specifies the ground mirror reflectance weight.
  109406. * This uses the standard weight of the background material to setup the fresnel effect
  109407. * of the mirror.
  109408. * 1 by default.
  109409. */
  109410. groundMirrorFresnelWeight: number;
  109411. /**
  109412. * Specifies the ground mirror Falloff distance.
  109413. * This can helps reducing the size of the reflection.
  109414. * 0 by Default.
  109415. */
  109416. groundMirrorFallOffDistance: number;
  109417. /**
  109418. * Specifies the ground mirror texture type.
  109419. * Unsigned Int by Default.
  109420. */
  109421. groundMirrorTextureType: number;
  109422. /**
  109423. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  109424. * the shown objects.
  109425. */
  109426. groundYBias: number;
  109427. /**
  109428. * Specifies wether or not to create a skybox.
  109429. * True by default.
  109430. */
  109431. createSkybox: boolean;
  109432. /**
  109433. * Specifies the skybox size.
  109434. * 20 by default.
  109435. */
  109436. skyboxSize: number;
  109437. /**
  109438. * The texture used on the skybox for the main color.
  109439. * Comes from the BabylonJS CDN by default.
  109440. *
  109441. * Remarks: Can be either a texture or a url.
  109442. */
  109443. skyboxTexture: string | BaseTexture;
  109444. /**
  109445. * The color mixed in the skybox texture by default.
  109446. * BabylonJS clearColor by default.
  109447. */
  109448. skyboxColor: Color3;
  109449. /**
  109450. * The background rotation around the Y axis of the scene.
  109451. * This helps aligning the key lights of your scene with the background.
  109452. * 0 by default.
  109453. */
  109454. backgroundYRotation: number;
  109455. /**
  109456. * Compute automatically the size of the elements to best fit with the scene.
  109457. */
  109458. sizeAuto: boolean;
  109459. /**
  109460. * Default position of the rootMesh if autoSize is not true.
  109461. */
  109462. rootPosition: Vector3;
  109463. /**
  109464. * Sets up the image processing in the scene.
  109465. * true by default.
  109466. */
  109467. setupImageProcessing: boolean;
  109468. /**
  109469. * The texture used as your environment texture in the scene.
  109470. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  109471. *
  109472. * Remarks: Can be either a texture or a url.
  109473. */
  109474. environmentTexture: string | BaseTexture;
  109475. /**
  109476. * The value of the exposure to apply to the scene.
  109477. * 0.6 by default if setupImageProcessing is true.
  109478. */
  109479. cameraExposure: number;
  109480. /**
  109481. * The value of the contrast to apply to the scene.
  109482. * 1.6 by default if setupImageProcessing is true.
  109483. */
  109484. cameraContrast: number;
  109485. /**
  109486. * Specifies wether or not tonemapping should be enabled in the scene.
  109487. * true by default if setupImageProcessing is true.
  109488. */
  109489. toneMappingEnabled: boolean;
  109490. }
  109491. /**
  109492. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  109493. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  109494. * It also helps with the default setup of your imageProcessing configuration.
  109495. */
  109496. export class EnvironmentHelper {
  109497. /**
  109498. * Default ground texture URL.
  109499. */
  109500. private static _groundTextureCDNUrl;
  109501. /**
  109502. * Default skybox texture URL.
  109503. */
  109504. private static _skyboxTextureCDNUrl;
  109505. /**
  109506. * Default environment texture URL.
  109507. */
  109508. private static _environmentTextureCDNUrl;
  109509. /**
  109510. * Creates the default options for the helper.
  109511. */
  109512. private static _getDefaultOptions;
  109513. private _rootMesh;
  109514. /**
  109515. * Gets the root mesh created by the helper.
  109516. */
  109517. readonly rootMesh: Mesh;
  109518. private _skybox;
  109519. /**
  109520. * Gets the skybox created by the helper.
  109521. */
  109522. readonly skybox: Nullable<Mesh>;
  109523. private _skyboxTexture;
  109524. /**
  109525. * Gets the skybox texture created by the helper.
  109526. */
  109527. readonly skyboxTexture: Nullable<BaseTexture>;
  109528. private _skyboxMaterial;
  109529. /**
  109530. * Gets the skybox material created by the helper.
  109531. */
  109532. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  109533. private _ground;
  109534. /**
  109535. * Gets the ground mesh created by the helper.
  109536. */
  109537. readonly ground: Nullable<Mesh>;
  109538. private _groundTexture;
  109539. /**
  109540. * Gets the ground texture created by the helper.
  109541. */
  109542. readonly groundTexture: Nullable<BaseTexture>;
  109543. private _groundMirror;
  109544. /**
  109545. * Gets the ground mirror created by the helper.
  109546. */
  109547. readonly groundMirror: Nullable<MirrorTexture>;
  109548. /**
  109549. * Gets the ground mirror render list to helps pushing the meshes
  109550. * you wish in the ground reflection.
  109551. */
  109552. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  109553. private _groundMaterial;
  109554. /**
  109555. * Gets the ground material created by the helper.
  109556. */
  109557. readonly groundMaterial: Nullable<BackgroundMaterial>;
  109558. /**
  109559. * Stores the creation options.
  109560. */
  109561. private readonly _scene;
  109562. private _options;
  109563. /**
  109564. * This observable will be notified with any error during the creation of the environment,
  109565. * mainly texture creation errors.
  109566. */
  109567. onErrorObservable: Observable<{
  109568. message?: string;
  109569. exception?: any;
  109570. }>;
  109571. /**
  109572. * constructor
  109573. * @param options Defines the options we want to customize the helper
  109574. * @param scene The scene to add the material to
  109575. */
  109576. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  109577. /**
  109578. * Updates the background according to the new options
  109579. * @param options
  109580. */
  109581. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  109582. /**
  109583. * Sets the primary color of all the available elements.
  109584. * @param color the main color to affect to the ground and the background
  109585. */
  109586. setMainColor(color: Color3): void;
  109587. /**
  109588. * Setup the image processing according to the specified options.
  109589. */
  109590. private _setupImageProcessing;
  109591. /**
  109592. * Setup the environment texture according to the specified options.
  109593. */
  109594. private _setupEnvironmentTexture;
  109595. /**
  109596. * Setup the background according to the specified options.
  109597. */
  109598. private _setupBackground;
  109599. /**
  109600. * Get the scene sizes according to the setup.
  109601. */
  109602. private _getSceneSize;
  109603. /**
  109604. * Setup the ground according to the specified options.
  109605. */
  109606. private _setupGround;
  109607. /**
  109608. * Setup the ground material according to the specified options.
  109609. */
  109610. private _setupGroundMaterial;
  109611. /**
  109612. * Setup the ground diffuse texture according to the specified options.
  109613. */
  109614. private _setupGroundDiffuseTexture;
  109615. /**
  109616. * Setup the ground mirror texture according to the specified options.
  109617. */
  109618. private _setupGroundMirrorTexture;
  109619. /**
  109620. * Setup the ground to receive the mirror texture.
  109621. */
  109622. private _setupMirrorInGroundMaterial;
  109623. /**
  109624. * Setup the skybox according to the specified options.
  109625. */
  109626. private _setupSkybox;
  109627. /**
  109628. * Setup the skybox material according to the specified options.
  109629. */
  109630. private _setupSkyboxMaterial;
  109631. /**
  109632. * Setup the skybox reflection texture according to the specified options.
  109633. */
  109634. private _setupSkyboxReflectionTexture;
  109635. private _errorHandler;
  109636. /**
  109637. * Dispose all the elements created by the Helper.
  109638. */
  109639. dispose(): void;
  109640. }
  109641. }
  109642. declare module BABYLON {
  109643. /**
  109644. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  109645. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  109646. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  109647. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109648. */
  109649. export class PhotoDome extends TransformNode {
  109650. /**
  109651. * Define the image as a Monoscopic panoramic 360 image.
  109652. */
  109653. static readonly MODE_MONOSCOPIC: number;
  109654. /**
  109655. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109656. */
  109657. static readonly MODE_TOPBOTTOM: number;
  109658. /**
  109659. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109660. */
  109661. static readonly MODE_SIDEBYSIDE: number;
  109662. private _useDirectMapping;
  109663. /**
  109664. * The texture being displayed on the sphere
  109665. */
  109666. protected _photoTexture: Texture;
  109667. /**
  109668. * Gets or sets the texture being displayed on the sphere
  109669. */
  109670. photoTexture: Texture;
  109671. /**
  109672. * Observable raised when an error occured while loading the 360 image
  109673. */
  109674. onLoadErrorObservable: Observable<string>;
  109675. /**
  109676. * The skybox material
  109677. */
  109678. protected _material: BackgroundMaterial;
  109679. /**
  109680. * The surface used for the skybox
  109681. */
  109682. protected _mesh: Mesh;
  109683. /**
  109684. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109685. * Also see the options.resolution property.
  109686. */
  109687. fovMultiplier: number;
  109688. private _imageMode;
  109689. /**
  109690. * Gets or set the current video mode for the video. It can be:
  109691. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  109692. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109693. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109694. */
  109695. imageMode: number;
  109696. /**
  109697. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  109698. * @param name Element's name, child elements will append suffixes for their own names.
  109699. * @param urlsOfPhoto defines the url of the photo to display
  109700. * @param options defines an object containing optional or exposed sub element properties
  109701. * @param onError defines a callback called when an error occured while loading the texture
  109702. */
  109703. constructor(name: string, urlOfPhoto: string, options: {
  109704. resolution?: number;
  109705. size?: number;
  109706. useDirectMapping?: boolean;
  109707. faceForward?: boolean;
  109708. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  109709. private _onBeforeCameraRenderObserver;
  109710. private _changeImageMode;
  109711. /**
  109712. * Releases resources associated with this node.
  109713. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109714. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109715. */
  109716. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109717. }
  109718. }
  109719. declare module BABYLON {
  109720. /** @hidden */
  109721. export var rgbdDecodePixelShader: {
  109722. name: string;
  109723. shader: string;
  109724. };
  109725. }
  109726. declare module BABYLON {
  109727. /**
  109728. * Class used to host texture specific utilities
  109729. */
  109730. export class BRDFTextureTools {
  109731. /**
  109732. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  109733. * @param texture the texture to expand.
  109734. */
  109735. private static _ExpandDefaultBRDFTexture;
  109736. /**
  109737. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  109738. * @param scene defines the hosting scene
  109739. * @returns the environment BRDF texture
  109740. */
  109741. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  109742. private static _environmentBRDFBase64Texture;
  109743. }
  109744. }
  109745. declare module BABYLON {
  109746. /**
  109747. * @hidden
  109748. */
  109749. export interface IMaterialClearCoatDefines {
  109750. CLEARCOAT: boolean;
  109751. CLEARCOAT_DEFAULTIOR: boolean;
  109752. CLEARCOAT_TEXTURE: boolean;
  109753. CLEARCOAT_TEXTUREDIRECTUV: number;
  109754. CLEARCOAT_BUMP: boolean;
  109755. CLEARCOAT_BUMPDIRECTUV: number;
  109756. CLEARCOAT_TINT: boolean;
  109757. CLEARCOAT_TINT_TEXTURE: boolean;
  109758. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109759. /** @hidden */
  109760. _areTexturesDirty: boolean;
  109761. }
  109762. /**
  109763. * Define the code related to the clear coat parameters of the pbr material.
  109764. */
  109765. export class PBRClearCoatConfiguration {
  109766. /**
  109767. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109768. * The default fits with a polyurethane material.
  109769. */
  109770. private static readonly _DefaultIndexOfRefraction;
  109771. private _isEnabled;
  109772. /**
  109773. * Defines if the clear coat is enabled in the material.
  109774. */
  109775. isEnabled: boolean;
  109776. /**
  109777. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  109778. */
  109779. intensity: number;
  109780. /**
  109781. * Defines the clear coat layer roughness.
  109782. */
  109783. roughness: number;
  109784. private _indexOfRefraction;
  109785. /**
  109786. * Defines the index of refraction of the clear coat.
  109787. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109788. * The default fits with a polyurethane material.
  109789. * Changing the default value is more performance intensive.
  109790. */
  109791. indexOfRefraction: number;
  109792. private _texture;
  109793. /**
  109794. * Stores the clear coat values in a texture.
  109795. */
  109796. texture: Nullable<BaseTexture>;
  109797. private _bumpTexture;
  109798. /**
  109799. * Define the clear coat specific bump texture.
  109800. */
  109801. bumpTexture: Nullable<BaseTexture>;
  109802. private _isTintEnabled;
  109803. /**
  109804. * Defines if the clear coat tint is enabled in the material.
  109805. */
  109806. isTintEnabled: boolean;
  109807. /**
  109808. * Defines the clear coat tint of the material.
  109809. * This is only use if tint is enabled
  109810. */
  109811. tintColor: Color3;
  109812. /**
  109813. * Defines the distance at which the tint color should be found in the
  109814. * clear coat media.
  109815. * This is only use if tint is enabled
  109816. */
  109817. tintColorAtDistance: number;
  109818. /**
  109819. * Defines the clear coat layer thickness.
  109820. * This is only use if tint is enabled
  109821. */
  109822. tintThickness: number;
  109823. private _tintTexture;
  109824. /**
  109825. * Stores the clear tint values in a texture.
  109826. * rgb is tint
  109827. * a is a thickness factor
  109828. */
  109829. tintTexture: Nullable<BaseTexture>;
  109830. /** @hidden */
  109831. private _internalMarkAllSubMeshesAsTexturesDirty;
  109832. /** @hidden */
  109833. _markAllSubMeshesAsTexturesDirty(): void;
  109834. /**
  109835. * Instantiate a new istance of clear coat configuration.
  109836. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109837. */
  109838. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109839. /**
  109840. * Gets wehter the submesh is ready to be used or not.
  109841. * @param defines the list of "defines" to update.
  109842. * @param scene defines the scene the material belongs to.
  109843. * @param engine defines the engine the material belongs to.
  109844. * @param disableBumpMap defines wether the material disables bump or not.
  109845. * @returns - boolean indicating that the submesh is ready or not.
  109846. */
  109847. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  109848. /**
  109849. * Checks to see if a texture is used in the material.
  109850. * @param defines the list of "defines" to update.
  109851. * @param scene defines the scene to the material belongs to.
  109852. */
  109853. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  109854. /**
  109855. * Binds the material data.
  109856. * @param uniformBuffer defines the Uniform buffer to fill in.
  109857. * @param scene defines the scene the material belongs to.
  109858. * @param engine defines the engine the material belongs to.
  109859. * @param disableBumpMap defines wether the material disables bump or not.
  109860. * @param isFrozen defines wether the material is frozen or not.
  109861. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  109862. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  109863. */
  109864. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  109865. /**
  109866. * Checks to see if a texture is used in the material.
  109867. * @param texture - Base texture to use.
  109868. * @returns - Boolean specifying if a texture is used in the material.
  109869. */
  109870. hasTexture(texture: BaseTexture): boolean;
  109871. /**
  109872. * Returns an array of the actively used textures.
  109873. * @param activeTextures Array of BaseTextures
  109874. */
  109875. getActiveTextures(activeTextures: BaseTexture[]): void;
  109876. /**
  109877. * Returns the animatable textures.
  109878. * @param animatables Array of animatable textures.
  109879. */
  109880. getAnimatables(animatables: IAnimatable[]): void;
  109881. /**
  109882. * Disposes the resources of the material.
  109883. * @param forceDisposeTextures - Forces the disposal of all textures.
  109884. */
  109885. dispose(forceDisposeTextures?: boolean): void;
  109886. /**
  109887. * Get the current class name of the texture useful for serialization or dynamic coding.
  109888. * @returns "PBRClearCoatConfiguration"
  109889. */
  109890. getClassName(): string;
  109891. /**
  109892. * Add fallbacks to the effect fallbacks list.
  109893. * @param defines defines the Base texture to use.
  109894. * @param fallbacks defines the current fallback list.
  109895. * @param currentRank defines the current fallback rank.
  109896. * @returns the new fallback rank.
  109897. */
  109898. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109899. /**
  109900. * Add the required uniforms to the current list.
  109901. * @param uniforms defines the current uniform list.
  109902. */
  109903. static AddUniforms(uniforms: string[]): void;
  109904. /**
  109905. * Add the required samplers to the current list.
  109906. * @param samplers defines the current sampler list.
  109907. */
  109908. static AddSamplers(samplers: string[]): void;
  109909. /**
  109910. * Add the required uniforms to the current buffer.
  109911. * @param uniformBuffer defines the current uniform buffer.
  109912. */
  109913. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109914. /**
  109915. * Makes a duplicate of the current configuration into another one.
  109916. * @param clearCoatConfiguration define the config where to copy the info
  109917. */
  109918. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  109919. /**
  109920. * Serializes this clear coat configuration.
  109921. * @returns - An object with the serialized config.
  109922. */
  109923. serialize(): any;
  109924. /**
  109925. * Parses a anisotropy Configuration from a serialized object.
  109926. * @param source - Serialized object.
  109927. * @param scene Defines the scene we are parsing for
  109928. * @param rootUrl Defines the rootUrl to load from
  109929. */
  109930. parse(source: any, scene: Scene, rootUrl: string): void;
  109931. }
  109932. }
  109933. declare module BABYLON {
  109934. /**
  109935. * @hidden
  109936. */
  109937. export interface IMaterialAnisotropicDefines {
  109938. ANISOTROPIC: boolean;
  109939. ANISOTROPIC_TEXTURE: boolean;
  109940. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109941. MAINUV1: boolean;
  109942. _areTexturesDirty: boolean;
  109943. _needUVs: boolean;
  109944. }
  109945. /**
  109946. * Define the code related to the anisotropic parameters of the pbr material.
  109947. */
  109948. export class PBRAnisotropicConfiguration {
  109949. private _isEnabled;
  109950. /**
  109951. * Defines if the anisotropy is enabled in the material.
  109952. */
  109953. isEnabled: boolean;
  109954. /**
  109955. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  109956. */
  109957. intensity: number;
  109958. /**
  109959. * Defines if the effect is along the tangents, bitangents or in between.
  109960. * By default, the effect is "strectching" the highlights along the tangents.
  109961. */
  109962. direction: Vector2;
  109963. private _texture;
  109964. /**
  109965. * Stores the anisotropy values in a texture.
  109966. * rg is direction (like normal from -1 to 1)
  109967. * b is a intensity
  109968. */
  109969. texture: Nullable<BaseTexture>;
  109970. /** @hidden */
  109971. private _internalMarkAllSubMeshesAsTexturesDirty;
  109972. /** @hidden */
  109973. _markAllSubMeshesAsTexturesDirty(): void;
  109974. /**
  109975. * Instantiate a new istance of anisotropy configuration.
  109976. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109977. */
  109978. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109979. /**
  109980. * Specifies that the submesh is ready to be used.
  109981. * @param defines the list of "defines" to update.
  109982. * @param scene defines the scene the material belongs to.
  109983. * @returns - boolean indicating that the submesh is ready or not.
  109984. */
  109985. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  109986. /**
  109987. * Checks to see if a texture is used in the material.
  109988. * @param defines the list of "defines" to update.
  109989. * @param mesh the mesh we are preparing the defines for.
  109990. * @param scene defines the scene the material belongs to.
  109991. */
  109992. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  109993. /**
  109994. * Binds the material data.
  109995. * @param uniformBuffer defines the Uniform buffer to fill in.
  109996. * @param scene defines the scene the material belongs to.
  109997. * @param isFrozen defines wether the material is frozen or not.
  109998. */
  109999. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110000. /**
  110001. * Checks to see if a texture is used in the material.
  110002. * @param texture - Base texture to use.
  110003. * @returns - Boolean specifying if a texture is used in the material.
  110004. */
  110005. hasTexture(texture: BaseTexture): boolean;
  110006. /**
  110007. * Returns an array of the actively used textures.
  110008. * @param activeTextures Array of BaseTextures
  110009. */
  110010. getActiveTextures(activeTextures: BaseTexture[]): void;
  110011. /**
  110012. * Returns the animatable textures.
  110013. * @param animatables Array of animatable textures.
  110014. */
  110015. getAnimatables(animatables: IAnimatable[]): void;
  110016. /**
  110017. * Disposes the resources of the material.
  110018. * @param forceDisposeTextures - Forces the disposal of all textures.
  110019. */
  110020. dispose(forceDisposeTextures?: boolean): void;
  110021. /**
  110022. * Get the current class name of the texture useful for serialization or dynamic coding.
  110023. * @returns "PBRAnisotropicConfiguration"
  110024. */
  110025. getClassName(): string;
  110026. /**
  110027. * Add fallbacks to the effect fallbacks list.
  110028. * @param defines defines the Base texture to use.
  110029. * @param fallbacks defines the current fallback list.
  110030. * @param currentRank defines the current fallback rank.
  110031. * @returns the new fallback rank.
  110032. */
  110033. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110034. /**
  110035. * Add the required uniforms to the current list.
  110036. * @param uniforms defines the current uniform list.
  110037. */
  110038. static AddUniforms(uniforms: string[]): void;
  110039. /**
  110040. * Add the required uniforms to the current buffer.
  110041. * @param uniformBuffer defines the current uniform buffer.
  110042. */
  110043. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110044. /**
  110045. * Add the required samplers to the current list.
  110046. * @param samplers defines the current sampler list.
  110047. */
  110048. static AddSamplers(samplers: string[]): void;
  110049. /**
  110050. * Makes a duplicate of the current configuration into another one.
  110051. * @param anisotropicConfiguration define the config where to copy the info
  110052. */
  110053. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  110054. /**
  110055. * Serializes this anisotropy configuration.
  110056. * @returns - An object with the serialized config.
  110057. */
  110058. serialize(): any;
  110059. /**
  110060. * Parses a anisotropy Configuration from a serialized object.
  110061. * @param source - Serialized object.
  110062. * @param scene Defines the scene we are parsing for
  110063. * @param rootUrl Defines the rootUrl to load from
  110064. */
  110065. parse(source: any, scene: Scene, rootUrl: string): void;
  110066. }
  110067. }
  110068. declare module BABYLON {
  110069. /**
  110070. * @hidden
  110071. */
  110072. export interface IMaterialBRDFDefines {
  110073. BRDF_V_HEIGHT_CORRELATED: boolean;
  110074. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110075. SPHERICAL_HARMONICS: boolean;
  110076. /** @hidden */
  110077. _areMiscDirty: boolean;
  110078. }
  110079. /**
  110080. * Define the code related to the BRDF parameters of the pbr material.
  110081. */
  110082. export class PBRBRDFConfiguration {
  110083. /**
  110084. * Default value used for the energy conservation.
  110085. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110086. */
  110087. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  110088. /**
  110089. * Default value used for the Smith Visibility Height Correlated mode.
  110090. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110091. */
  110092. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  110093. /**
  110094. * Default value used for the IBL diffuse part.
  110095. * This can help switching back to the polynomials mode globally which is a tiny bit
  110096. * less GPU intensive at the drawback of a lower quality.
  110097. */
  110098. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  110099. private _useEnergyConservation;
  110100. /**
  110101. * Defines if the material uses energy conservation.
  110102. */
  110103. useEnergyConservation: boolean;
  110104. private _useSmithVisibilityHeightCorrelated;
  110105. /**
  110106. * LEGACY Mode set to false
  110107. * Defines if the material uses height smith correlated visibility term.
  110108. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  110109. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  110110. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  110111. * Not relying on height correlated will also disable energy conservation.
  110112. */
  110113. useSmithVisibilityHeightCorrelated: boolean;
  110114. private _useSphericalHarmonics;
  110115. /**
  110116. * LEGACY Mode set to false
  110117. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  110118. * diffuse part of the IBL.
  110119. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  110120. * to the ground truth.
  110121. */
  110122. useSphericalHarmonics: boolean;
  110123. /** @hidden */
  110124. private _internalMarkAllSubMeshesAsMiscDirty;
  110125. /** @hidden */
  110126. _markAllSubMeshesAsMiscDirty(): void;
  110127. /**
  110128. * Instantiate a new istance of clear coat configuration.
  110129. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  110130. */
  110131. constructor(markAllSubMeshesAsMiscDirty: () => void);
  110132. /**
  110133. * Checks to see if a texture is used in the material.
  110134. * @param defines the list of "defines" to update.
  110135. */
  110136. prepareDefines(defines: IMaterialBRDFDefines): void;
  110137. /**
  110138. * Get the current class name of the texture useful for serialization or dynamic coding.
  110139. * @returns "PBRClearCoatConfiguration"
  110140. */
  110141. getClassName(): string;
  110142. /**
  110143. * Makes a duplicate of the current configuration into another one.
  110144. * @param brdfConfiguration define the config where to copy the info
  110145. */
  110146. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  110147. /**
  110148. * Serializes this BRDF configuration.
  110149. * @returns - An object with the serialized config.
  110150. */
  110151. serialize(): any;
  110152. /**
  110153. * Parses a anisotropy Configuration from a serialized object.
  110154. * @param source - Serialized object.
  110155. * @param scene Defines the scene we are parsing for
  110156. * @param rootUrl Defines the rootUrl to load from
  110157. */
  110158. parse(source: any, scene: Scene, rootUrl: string): void;
  110159. }
  110160. }
  110161. declare module BABYLON {
  110162. /**
  110163. * @hidden
  110164. */
  110165. export interface IMaterialSheenDefines {
  110166. SHEEN: boolean;
  110167. SHEEN_TEXTURE: boolean;
  110168. SHEEN_TEXTUREDIRECTUV: number;
  110169. SHEEN_LINKWITHALBEDO: boolean;
  110170. /** @hidden */
  110171. _areTexturesDirty: boolean;
  110172. }
  110173. /**
  110174. * Define the code related to the Sheen parameters of the pbr material.
  110175. */
  110176. export class PBRSheenConfiguration {
  110177. private _isEnabled;
  110178. /**
  110179. * Defines if the material uses sheen.
  110180. */
  110181. isEnabled: boolean;
  110182. private _linkSheenWithAlbedo;
  110183. /**
  110184. * Defines if the sheen is linked to the sheen color.
  110185. */
  110186. linkSheenWithAlbedo: boolean;
  110187. /**
  110188. * Defines the sheen intensity.
  110189. */
  110190. intensity: number;
  110191. /**
  110192. * Defines the sheen color.
  110193. */
  110194. color: Color3;
  110195. private _texture;
  110196. /**
  110197. * Stores the sheen tint values in a texture.
  110198. * rgb is tint
  110199. * a is a intensity
  110200. */
  110201. texture: Nullable<BaseTexture>;
  110202. /** @hidden */
  110203. private _internalMarkAllSubMeshesAsTexturesDirty;
  110204. /** @hidden */
  110205. _markAllSubMeshesAsTexturesDirty(): void;
  110206. /**
  110207. * Instantiate a new istance of clear coat configuration.
  110208. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110209. */
  110210. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110211. /**
  110212. * Specifies that the submesh is ready to be used.
  110213. * @param defines the list of "defines" to update.
  110214. * @param scene defines the scene the material belongs to.
  110215. * @returns - boolean indicating that the submesh is ready or not.
  110216. */
  110217. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  110218. /**
  110219. * Checks to see if a texture is used in the material.
  110220. * @param defines the list of "defines" to update.
  110221. * @param scene defines the scene the material belongs to.
  110222. */
  110223. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  110224. /**
  110225. * Binds the material data.
  110226. * @param uniformBuffer defines the Uniform buffer to fill in.
  110227. * @param scene defines the scene the material belongs to.
  110228. * @param isFrozen defines wether the material is frozen or not.
  110229. */
  110230. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110231. /**
  110232. * Checks to see if a texture is used in the material.
  110233. * @param texture - Base texture to use.
  110234. * @returns - Boolean specifying if a texture is used in the material.
  110235. */
  110236. hasTexture(texture: BaseTexture): boolean;
  110237. /**
  110238. * Returns an array of the actively used textures.
  110239. * @param activeTextures Array of BaseTextures
  110240. */
  110241. getActiveTextures(activeTextures: BaseTexture[]): void;
  110242. /**
  110243. * Returns the animatable textures.
  110244. * @param animatables Array of animatable textures.
  110245. */
  110246. getAnimatables(animatables: IAnimatable[]): void;
  110247. /**
  110248. * Disposes the resources of the material.
  110249. * @param forceDisposeTextures - Forces the disposal of all textures.
  110250. */
  110251. dispose(forceDisposeTextures?: boolean): void;
  110252. /**
  110253. * Get the current class name of the texture useful for serialization or dynamic coding.
  110254. * @returns "PBRSheenConfiguration"
  110255. */
  110256. getClassName(): string;
  110257. /**
  110258. * Add fallbacks to the effect fallbacks list.
  110259. * @param defines defines the Base texture to use.
  110260. * @param fallbacks defines the current fallback list.
  110261. * @param currentRank defines the current fallback rank.
  110262. * @returns the new fallback rank.
  110263. */
  110264. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110265. /**
  110266. * Add the required uniforms to the current list.
  110267. * @param uniforms defines the current uniform list.
  110268. */
  110269. static AddUniforms(uniforms: string[]): void;
  110270. /**
  110271. * Add the required uniforms to the current buffer.
  110272. * @param uniformBuffer defines the current uniform buffer.
  110273. */
  110274. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110275. /**
  110276. * Add the required samplers to the current list.
  110277. * @param samplers defines the current sampler list.
  110278. */
  110279. static AddSamplers(samplers: string[]): void;
  110280. /**
  110281. * Makes a duplicate of the current configuration into another one.
  110282. * @param sheenConfiguration define the config where to copy the info
  110283. */
  110284. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  110285. /**
  110286. * Serializes this BRDF configuration.
  110287. * @returns - An object with the serialized config.
  110288. */
  110289. serialize(): any;
  110290. /**
  110291. * Parses a anisotropy Configuration from a serialized object.
  110292. * @param source - Serialized object.
  110293. * @param scene Defines the scene we are parsing for
  110294. * @param rootUrl Defines the rootUrl to load from
  110295. */
  110296. parse(source: any, scene: Scene, rootUrl: string): void;
  110297. }
  110298. }
  110299. declare module BABYLON {
  110300. /**
  110301. * @hidden
  110302. */
  110303. export interface IMaterialSubSurfaceDefines {
  110304. SUBSURFACE: boolean;
  110305. SS_REFRACTION: boolean;
  110306. SS_TRANSLUCENCY: boolean;
  110307. SS_SCATERRING: boolean;
  110308. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110309. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110310. SS_REFRACTIONMAP_3D: boolean;
  110311. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110312. SS_LODINREFRACTIONALPHA: boolean;
  110313. SS_GAMMAREFRACTION: boolean;
  110314. SS_RGBDREFRACTION: boolean;
  110315. SS_LINEARSPECULARREFRACTION: boolean;
  110316. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110317. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110318. /** @hidden */
  110319. _areTexturesDirty: boolean;
  110320. }
  110321. /**
  110322. * Define the code related to the sub surface parameters of the pbr material.
  110323. */
  110324. export class PBRSubSurfaceConfiguration {
  110325. private _isRefractionEnabled;
  110326. /**
  110327. * Defines if the refraction is enabled in the material.
  110328. */
  110329. isRefractionEnabled: boolean;
  110330. private _isTranslucencyEnabled;
  110331. /**
  110332. * Defines if the translucency is enabled in the material.
  110333. */
  110334. isTranslucencyEnabled: boolean;
  110335. private _isScatteringEnabled;
  110336. /**
  110337. * Defines the refraction intensity of the material.
  110338. * The refraction when enabled replaces the Diffuse part of the material.
  110339. * The intensity helps transitionning between diffuse and refraction.
  110340. */
  110341. refractionIntensity: number;
  110342. /**
  110343. * Defines the translucency intensity of the material.
  110344. * When translucency has been enabled, this defines how much of the "translucency"
  110345. * is addded to the diffuse part of the material.
  110346. */
  110347. translucencyIntensity: number;
  110348. /**
  110349. * Defines the scattering intensity of the material.
  110350. * When scattering has been enabled, this defines how much of the "scattered light"
  110351. * is addded to the diffuse part of the material.
  110352. */
  110353. scatteringIntensity: number;
  110354. private _thicknessTexture;
  110355. /**
  110356. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  110357. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  110358. * 0 would mean minimumThickness
  110359. * 1 would mean maximumThickness
  110360. * The other channels might be use as a mask to vary the different effects intensity.
  110361. */
  110362. thicknessTexture: Nullable<BaseTexture>;
  110363. private _refractionTexture;
  110364. /**
  110365. * Defines the texture to use for refraction.
  110366. */
  110367. refractionTexture: Nullable<BaseTexture>;
  110368. private _indexOfRefraction;
  110369. /**
  110370. * Defines the index of refraction used in the material.
  110371. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  110372. */
  110373. indexOfRefraction: number;
  110374. private _invertRefractionY;
  110375. /**
  110376. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110377. */
  110378. invertRefractionY: boolean;
  110379. private _linkRefractionWithTransparency;
  110380. /**
  110381. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110382. * Materials half opaque for instance using refraction could benefit from this control.
  110383. */
  110384. linkRefractionWithTransparency: boolean;
  110385. /**
  110386. * Defines the minimum thickness stored in the thickness map.
  110387. * If no thickness map is defined, this value will be used to simulate thickness.
  110388. */
  110389. minimumThickness: number;
  110390. /**
  110391. * Defines the maximum thickness stored in the thickness map.
  110392. */
  110393. maximumThickness: number;
  110394. /**
  110395. * Defines the volume tint of the material.
  110396. * This is used for both translucency and scattering.
  110397. */
  110398. tintColor: Color3;
  110399. /**
  110400. * Defines the distance at which the tint color should be found in the media.
  110401. * This is used for refraction only.
  110402. */
  110403. tintColorAtDistance: number;
  110404. /**
  110405. * Defines how far each channel transmit through the media.
  110406. * It is defined as a color to simplify it selection.
  110407. */
  110408. diffusionDistance: Color3;
  110409. private _useMaskFromThicknessTexture;
  110410. /**
  110411. * Stores the intensity of the different subsurface effects in the thickness texture.
  110412. * * the green channel is the translucency intensity.
  110413. * * the blue channel is the scattering intensity.
  110414. * * the alpha channel is the refraction intensity.
  110415. */
  110416. useMaskFromThicknessTexture: boolean;
  110417. /** @hidden */
  110418. private _internalMarkAllSubMeshesAsTexturesDirty;
  110419. /** @hidden */
  110420. _markAllSubMeshesAsTexturesDirty(): void;
  110421. /**
  110422. * Instantiate a new istance of sub surface configuration.
  110423. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110424. */
  110425. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110426. /**
  110427. * Gets wehter the submesh is ready to be used or not.
  110428. * @param defines the list of "defines" to update.
  110429. * @param scene defines the scene the material belongs to.
  110430. * @returns - boolean indicating that the submesh is ready or not.
  110431. */
  110432. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  110433. /**
  110434. * Checks to see if a texture is used in the material.
  110435. * @param defines the list of "defines" to update.
  110436. * @param scene defines the scene to the material belongs to.
  110437. */
  110438. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  110439. /**
  110440. * Binds the material data.
  110441. * @param uniformBuffer defines the Uniform buffer to fill in.
  110442. * @param scene defines the scene the material belongs to.
  110443. * @param engine defines the engine the material belongs to.
  110444. * @param isFrozen defines wether the material is frozen or not.
  110445. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  110446. */
  110447. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  110448. /**
  110449. * Unbinds the material from the mesh.
  110450. * @param activeEffect defines the effect that should be unbound from.
  110451. * @returns true if unbound, otherwise false
  110452. */
  110453. unbind(activeEffect: Effect): boolean;
  110454. /**
  110455. * Returns the texture used for refraction or null if none is used.
  110456. * @param scene defines the scene the material belongs to.
  110457. * @returns - Refraction texture if present. If no refraction texture and refraction
  110458. * is linked with transparency, returns environment texture. Otherwise, returns null.
  110459. */
  110460. private _getRefractionTexture;
  110461. /**
  110462. * Returns true if alpha blending should be disabled.
  110463. */
  110464. readonly disableAlphaBlending: boolean;
  110465. /**
  110466. * Fills the list of render target textures.
  110467. * @param renderTargets the list of render targets to update
  110468. */
  110469. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  110470. /**
  110471. * Checks to see if a texture is used in the material.
  110472. * @param texture - Base texture to use.
  110473. * @returns - Boolean specifying if a texture is used in the material.
  110474. */
  110475. hasTexture(texture: BaseTexture): boolean;
  110476. /**
  110477. * Gets a boolean indicating that current material needs to register RTT
  110478. * @returns true if this uses a render target otherwise false.
  110479. */
  110480. hasRenderTargetTextures(): boolean;
  110481. /**
  110482. * Returns an array of the actively used textures.
  110483. * @param activeTextures Array of BaseTextures
  110484. */
  110485. getActiveTextures(activeTextures: BaseTexture[]): void;
  110486. /**
  110487. * Returns the animatable textures.
  110488. * @param animatables Array of animatable textures.
  110489. */
  110490. getAnimatables(animatables: IAnimatable[]): void;
  110491. /**
  110492. * Disposes the resources of the material.
  110493. * @param forceDisposeTextures - Forces the disposal of all textures.
  110494. */
  110495. dispose(forceDisposeTextures?: boolean): void;
  110496. /**
  110497. * Get the current class name of the texture useful for serialization or dynamic coding.
  110498. * @returns "PBRSubSurfaceConfiguration"
  110499. */
  110500. getClassName(): string;
  110501. /**
  110502. * Add fallbacks to the effect fallbacks list.
  110503. * @param defines defines the Base texture to use.
  110504. * @param fallbacks defines the current fallback list.
  110505. * @param currentRank defines the current fallback rank.
  110506. * @returns the new fallback rank.
  110507. */
  110508. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110509. /**
  110510. * Add the required uniforms to the current list.
  110511. * @param uniforms defines the current uniform list.
  110512. */
  110513. static AddUniforms(uniforms: string[]): void;
  110514. /**
  110515. * Add the required samplers to the current list.
  110516. * @param samplers defines the current sampler list.
  110517. */
  110518. static AddSamplers(samplers: string[]): void;
  110519. /**
  110520. * Add the required uniforms to the current buffer.
  110521. * @param uniformBuffer defines the current uniform buffer.
  110522. */
  110523. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110524. /**
  110525. * Makes a duplicate of the current configuration into another one.
  110526. * @param configuration define the config where to copy the info
  110527. */
  110528. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  110529. /**
  110530. * Serializes this Sub Surface configuration.
  110531. * @returns - An object with the serialized config.
  110532. */
  110533. serialize(): any;
  110534. /**
  110535. * Parses a anisotropy Configuration from a serialized object.
  110536. * @param source - Serialized object.
  110537. * @param scene Defines the scene we are parsing for
  110538. * @param rootUrl Defines the rootUrl to load from
  110539. */
  110540. parse(source: any, scene: Scene, rootUrl: string): void;
  110541. }
  110542. }
  110543. declare module BABYLON {
  110544. /** @hidden */
  110545. export var pbrFragmentDeclaration: {
  110546. name: string;
  110547. shader: string;
  110548. };
  110549. }
  110550. declare module BABYLON {
  110551. /** @hidden */
  110552. export var pbrUboDeclaration: {
  110553. name: string;
  110554. shader: string;
  110555. };
  110556. }
  110557. declare module BABYLON {
  110558. /** @hidden */
  110559. export var pbrFragmentExtraDeclaration: {
  110560. name: string;
  110561. shader: string;
  110562. };
  110563. }
  110564. declare module BABYLON {
  110565. /** @hidden */
  110566. export var pbrFragmentSamplersDeclaration: {
  110567. name: string;
  110568. shader: string;
  110569. };
  110570. }
  110571. declare module BABYLON {
  110572. /** @hidden */
  110573. export var pbrHelperFunctions: {
  110574. name: string;
  110575. shader: string;
  110576. };
  110577. }
  110578. declare module BABYLON {
  110579. /** @hidden */
  110580. export var harmonicsFunctions: {
  110581. name: string;
  110582. shader: string;
  110583. };
  110584. }
  110585. declare module BABYLON {
  110586. /** @hidden */
  110587. export var pbrDirectLightingSetupFunctions: {
  110588. name: string;
  110589. shader: string;
  110590. };
  110591. }
  110592. declare module BABYLON {
  110593. /** @hidden */
  110594. export var pbrDirectLightingFalloffFunctions: {
  110595. name: string;
  110596. shader: string;
  110597. };
  110598. }
  110599. declare module BABYLON {
  110600. /** @hidden */
  110601. export var pbrBRDFFunctions: {
  110602. name: string;
  110603. shader: string;
  110604. };
  110605. }
  110606. declare module BABYLON {
  110607. /** @hidden */
  110608. export var pbrDirectLightingFunctions: {
  110609. name: string;
  110610. shader: string;
  110611. };
  110612. }
  110613. declare module BABYLON {
  110614. /** @hidden */
  110615. export var pbrIBLFunctions: {
  110616. name: string;
  110617. shader: string;
  110618. };
  110619. }
  110620. declare module BABYLON {
  110621. /** @hidden */
  110622. export var pbrDebug: {
  110623. name: string;
  110624. shader: string;
  110625. };
  110626. }
  110627. declare module BABYLON {
  110628. /** @hidden */
  110629. export var pbrPixelShader: {
  110630. name: string;
  110631. shader: string;
  110632. };
  110633. }
  110634. declare module BABYLON {
  110635. /** @hidden */
  110636. export var pbrVertexDeclaration: {
  110637. name: string;
  110638. shader: string;
  110639. };
  110640. }
  110641. declare module BABYLON {
  110642. /** @hidden */
  110643. export var pbrVertexShader: {
  110644. name: string;
  110645. shader: string;
  110646. };
  110647. }
  110648. declare module BABYLON {
  110649. /**
  110650. * Manages the defines for the PBR Material.
  110651. * @hidden
  110652. */
  110653. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  110654. PBR: boolean;
  110655. MAINUV1: boolean;
  110656. MAINUV2: boolean;
  110657. UV1: boolean;
  110658. UV2: boolean;
  110659. ALBEDO: boolean;
  110660. ALBEDODIRECTUV: number;
  110661. VERTEXCOLOR: boolean;
  110662. AMBIENT: boolean;
  110663. AMBIENTDIRECTUV: number;
  110664. AMBIENTINGRAYSCALE: boolean;
  110665. OPACITY: boolean;
  110666. VERTEXALPHA: boolean;
  110667. OPACITYDIRECTUV: number;
  110668. OPACITYRGB: boolean;
  110669. ALPHATEST: boolean;
  110670. DEPTHPREPASS: boolean;
  110671. ALPHABLEND: boolean;
  110672. ALPHAFROMALBEDO: boolean;
  110673. ALPHATESTVALUE: string;
  110674. SPECULAROVERALPHA: boolean;
  110675. RADIANCEOVERALPHA: boolean;
  110676. ALPHAFRESNEL: boolean;
  110677. LINEARALPHAFRESNEL: boolean;
  110678. PREMULTIPLYALPHA: boolean;
  110679. EMISSIVE: boolean;
  110680. EMISSIVEDIRECTUV: number;
  110681. REFLECTIVITY: boolean;
  110682. REFLECTIVITYDIRECTUV: number;
  110683. SPECULARTERM: boolean;
  110684. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  110685. MICROSURFACEAUTOMATIC: boolean;
  110686. LODBASEDMICROSFURACE: boolean;
  110687. MICROSURFACEMAP: boolean;
  110688. MICROSURFACEMAPDIRECTUV: number;
  110689. METALLICWORKFLOW: boolean;
  110690. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  110691. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  110692. METALLNESSSTOREINMETALMAPBLUE: boolean;
  110693. AOSTOREINMETALMAPRED: boolean;
  110694. ENVIRONMENTBRDF: boolean;
  110695. ENVIRONMENTBRDF_RGBD: boolean;
  110696. NORMAL: boolean;
  110697. TANGENT: boolean;
  110698. BUMP: boolean;
  110699. BUMPDIRECTUV: number;
  110700. OBJECTSPACE_NORMALMAP: boolean;
  110701. PARALLAX: boolean;
  110702. PARALLAXOCCLUSION: boolean;
  110703. NORMALXYSCALE: boolean;
  110704. LIGHTMAP: boolean;
  110705. LIGHTMAPDIRECTUV: number;
  110706. USELIGHTMAPASSHADOWMAP: boolean;
  110707. GAMMALIGHTMAP: boolean;
  110708. REFLECTION: boolean;
  110709. REFLECTIONMAP_3D: boolean;
  110710. REFLECTIONMAP_SPHERICAL: boolean;
  110711. REFLECTIONMAP_PLANAR: boolean;
  110712. REFLECTIONMAP_CUBIC: boolean;
  110713. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110714. REFLECTIONMAP_PROJECTION: boolean;
  110715. REFLECTIONMAP_SKYBOX: boolean;
  110716. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  110717. REFLECTIONMAP_EXPLICIT: boolean;
  110718. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110719. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110720. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110721. INVERTCUBICMAP: boolean;
  110722. USESPHERICALFROMREFLECTIONMAP: boolean;
  110723. USEIRRADIANCEMAP: boolean;
  110724. SPHERICAL_HARMONICS: boolean;
  110725. USESPHERICALINVERTEX: boolean;
  110726. REFLECTIONMAP_OPPOSITEZ: boolean;
  110727. LODINREFLECTIONALPHA: boolean;
  110728. GAMMAREFLECTION: boolean;
  110729. RGBDREFLECTION: boolean;
  110730. LINEARSPECULARREFLECTION: boolean;
  110731. RADIANCEOCCLUSION: boolean;
  110732. HORIZONOCCLUSION: boolean;
  110733. INSTANCES: boolean;
  110734. NUM_BONE_INFLUENCERS: number;
  110735. BonesPerMesh: number;
  110736. BONETEXTURE: boolean;
  110737. NONUNIFORMSCALING: boolean;
  110738. MORPHTARGETS: boolean;
  110739. MORPHTARGETS_NORMAL: boolean;
  110740. MORPHTARGETS_TANGENT: boolean;
  110741. MORPHTARGETS_UV: boolean;
  110742. NUM_MORPH_INFLUENCERS: number;
  110743. IMAGEPROCESSING: boolean;
  110744. VIGNETTE: boolean;
  110745. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110746. VIGNETTEBLENDMODEOPAQUE: boolean;
  110747. TONEMAPPING: boolean;
  110748. TONEMAPPING_ACES: boolean;
  110749. CONTRAST: boolean;
  110750. COLORCURVES: boolean;
  110751. COLORGRADING: boolean;
  110752. COLORGRADING3D: boolean;
  110753. SAMPLER3DGREENDEPTH: boolean;
  110754. SAMPLER3DBGRMAP: boolean;
  110755. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110756. EXPOSURE: boolean;
  110757. MULTIVIEW: boolean;
  110758. USEPHYSICALLIGHTFALLOFF: boolean;
  110759. USEGLTFLIGHTFALLOFF: boolean;
  110760. TWOSIDEDLIGHTING: boolean;
  110761. SHADOWFLOAT: boolean;
  110762. CLIPPLANE: boolean;
  110763. CLIPPLANE2: boolean;
  110764. CLIPPLANE3: boolean;
  110765. CLIPPLANE4: boolean;
  110766. POINTSIZE: boolean;
  110767. FOG: boolean;
  110768. LOGARITHMICDEPTH: boolean;
  110769. FORCENORMALFORWARD: boolean;
  110770. SPECULARAA: boolean;
  110771. CLEARCOAT: boolean;
  110772. CLEARCOAT_DEFAULTIOR: boolean;
  110773. CLEARCOAT_TEXTURE: boolean;
  110774. CLEARCOAT_TEXTUREDIRECTUV: number;
  110775. CLEARCOAT_BUMP: boolean;
  110776. CLEARCOAT_BUMPDIRECTUV: number;
  110777. CLEARCOAT_TINT: boolean;
  110778. CLEARCOAT_TINT_TEXTURE: boolean;
  110779. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110780. ANISOTROPIC: boolean;
  110781. ANISOTROPIC_TEXTURE: boolean;
  110782. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110783. BRDF_V_HEIGHT_CORRELATED: boolean;
  110784. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110785. SHEEN: boolean;
  110786. SHEEN_TEXTURE: boolean;
  110787. SHEEN_TEXTUREDIRECTUV: number;
  110788. SHEEN_LINKWITHALBEDO: boolean;
  110789. SUBSURFACE: boolean;
  110790. SS_REFRACTION: boolean;
  110791. SS_TRANSLUCENCY: boolean;
  110792. SS_SCATERRING: boolean;
  110793. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110794. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110795. SS_REFRACTIONMAP_3D: boolean;
  110796. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110797. SS_LODINREFRACTIONALPHA: boolean;
  110798. SS_GAMMAREFRACTION: boolean;
  110799. SS_RGBDREFRACTION: boolean;
  110800. SS_LINEARSPECULARREFRACTION: boolean;
  110801. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110802. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110803. UNLIT: boolean;
  110804. DEBUGMODE: number;
  110805. /**
  110806. * Initializes the PBR Material defines.
  110807. */
  110808. constructor();
  110809. /**
  110810. * Resets the PBR Material defines.
  110811. */
  110812. reset(): void;
  110813. }
  110814. /**
  110815. * The Physically based material base class of BJS.
  110816. *
  110817. * This offers the main features of a standard PBR material.
  110818. * For more information, please refer to the documentation :
  110819. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110820. */
  110821. export abstract class PBRBaseMaterial extends PushMaterial {
  110822. /**
  110823. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110824. */
  110825. static readonly PBRMATERIAL_OPAQUE: number;
  110826. /**
  110827. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110828. */
  110829. static readonly PBRMATERIAL_ALPHATEST: number;
  110830. /**
  110831. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110832. */
  110833. static readonly PBRMATERIAL_ALPHABLEND: number;
  110834. /**
  110835. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110836. * They are also discarded below the alpha cutoff threshold to improve performances.
  110837. */
  110838. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110839. /**
  110840. * Defines the default value of how much AO map is occluding the analytical lights
  110841. * (point spot...).
  110842. */
  110843. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110844. /**
  110845. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  110846. */
  110847. static readonly LIGHTFALLOFF_PHYSICAL: number;
  110848. /**
  110849. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  110850. * to enhance interoperability with other engines.
  110851. */
  110852. static readonly LIGHTFALLOFF_GLTF: number;
  110853. /**
  110854. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  110855. * to enhance interoperability with other materials.
  110856. */
  110857. static readonly LIGHTFALLOFF_STANDARD: number;
  110858. /**
  110859. * Intensity of the direct lights e.g. the four lights available in your scene.
  110860. * This impacts both the direct diffuse and specular highlights.
  110861. */
  110862. protected _directIntensity: number;
  110863. /**
  110864. * Intensity of the emissive part of the material.
  110865. * This helps controlling the emissive effect without modifying the emissive color.
  110866. */
  110867. protected _emissiveIntensity: number;
  110868. /**
  110869. * Intensity of the environment e.g. how much the environment will light the object
  110870. * either through harmonics for rough material or through the refelction for shiny ones.
  110871. */
  110872. protected _environmentIntensity: number;
  110873. /**
  110874. * This is a special control allowing the reduction of the specular highlights coming from the
  110875. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110876. */
  110877. protected _specularIntensity: number;
  110878. /**
  110879. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  110880. */
  110881. private _lightingInfos;
  110882. /**
  110883. * Debug Control allowing disabling the bump map on this material.
  110884. */
  110885. protected _disableBumpMap: boolean;
  110886. /**
  110887. * AKA Diffuse Texture in standard nomenclature.
  110888. */
  110889. protected _albedoTexture: Nullable<BaseTexture>;
  110890. /**
  110891. * AKA Occlusion Texture in other nomenclature.
  110892. */
  110893. protected _ambientTexture: Nullable<BaseTexture>;
  110894. /**
  110895. * AKA Occlusion Texture Intensity in other nomenclature.
  110896. */
  110897. protected _ambientTextureStrength: number;
  110898. /**
  110899. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110900. * 1 means it completely occludes it
  110901. * 0 mean it has no impact
  110902. */
  110903. protected _ambientTextureImpactOnAnalyticalLights: number;
  110904. /**
  110905. * Stores the alpha values in a texture.
  110906. */
  110907. protected _opacityTexture: Nullable<BaseTexture>;
  110908. /**
  110909. * Stores the reflection values in a texture.
  110910. */
  110911. protected _reflectionTexture: Nullable<BaseTexture>;
  110912. /**
  110913. * Stores the emissive values in a texture.
  110914. */
  110915. protected _emissiveTexture: Nullable<BaseTexture>;
  110916. /**
  110917. * AKA Specular texture in other nomenclature.
  110918. */
  110919. protected _reflectivityTexture: Nullable<BaseTexture>;
  110920. /**
  110921. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110922. */
  110923. protected _metallicTexture: Nullable<BaseTexture>;
  110924. /**
  110925. * Specifies the metallic scalar of the metallic/roughness workflow.
  110926. * Can also be used to scale the metalness values of the metallic texture.
  110927. */
  110928. protected _metallic: Nullable<number>;
  110929. /**
  110930. * Specifies the roughness scalar of the metallic/roughness workflow.
  110931. * Can also be used to scale the roughness values of the metallic texture.
  110932. */
  110933. protected _roughness: Nullable<number>;
  110934. /**
  110935. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110936. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110937. */
  110938. protected _microSurfaceTexture: Nullable<BaseTexture>;
  110939. /**
  110940. * Stores surface normal data used to displace a mesh in a texture.
  110941. */
  110942. protected _bumpTexture: Nullable<BaseTexture>;
  110943. /**
  110944. * Stores the pre-calculated light information of a mesh in a texture.
  110945. */
  110946. protected _lightmapTexture: Nullable<BaseTexture>;
  110947. /**
  110948. * The color of a material in ambient lighting.
  110949. */
  110950. protected _ambientColor: Color3;
  110951. /**
  110952. * AKA Diffuse Color in other nomenclature.
  110953. */
  110954. protected _albedoColor: Color3;
  110955. /**
  110956. * AKA Specular Color in other nomenclature.
  110957. */
  110958. protected _reflectivityColor: Color3;
  110959. /**
  110960. * The color applied when light is reflected from a material.
  110961. */
  110962. protected _reflectionColor: Color3;
  110963. /**
  110964. * The color applied when light is emitted from a material.
  110965. */
  110966. protected _emissiveColor: Color3;
  110967. /**
  110968. * AKA Glossiness in other nomenclature.
  110969. */
  110970. protected _microSurface: number;
  110971. /**
  110972. * Specifies that the material will use the light map as a show map.
  110973. */
  110974. protected _useLightmapAsShadowmap: boolean;
  110975. /**
  110976. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110977. * makes the reflect vector face the model (under horizon).
  110978. */
  110979. protected _useHorizonOcclusion: boolean;
  110980. /**
  110981. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110982. * too much the area relying on ambient texture to define their ambient occlusion.
  110983. */
  110984. protected _useRadianceOcclusion: boolean;
  110985. /**
  110986. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110987. */
  110988. protected _useAlphaFromAlbedoTexture: boolean;
  110989. /**
  110990. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  110991. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110992. */
  110993. protected _useSpecularOverAlpha: boolean;
  110994. /**
  110995. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110996. */
  110997. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110998. /**
  110999. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111000. */
  111001. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  111002. /**
  111003. * Specifies if the metallic texture contains the roughness information in its green channel.
  111004. */
  111005. protected _useRoughnessFromMetallicTextureGreen: boolean;
  111006. /**
  111007. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111008. */
  111009. protected _useMetallnessFromMetallicTextureBlue: boolean;
  111010. /**
  111011. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111012. */
  111013. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  111014. /**
  111015. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111016. */
  111017. protected _useAmbientInGrayScale: boolean;
  111018. /**
  111019. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111020. * The material will try to infer what glossiness each pixel should be.
  111021. */
  111022. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  111023. /**
  111024. * Defines the falloff type used in this material.
  111025. * It by default is Physical.
  111026. */
  111027. protected _lightFalloff: number;
  111028. /**
  111029. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111030. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111031. */
  111032. protected _useRadianceOverAlpha: boolean;
  111033. /**
  111034. * Allows using an object space normal map (instead of tangent space).
  111035. */
  111036. protected _useObjectSpaceNormalMap: boolean;
  111037. /**
  111038. * Allows using the bump map in parallax mode.
  111039. */
  111040. protected _useParallax: boolean;
  111041. /**
  111042. * Allows using the bump map in parallax occlusion mode.
  111043. */
  111044. protected _useParallaxOcclusion: boolean;
  111045. /**
  111046. * Controls the scale bias of the parallax mode.
  111047. */
  111048. protected _parallaxScaleBias: number;
  111049. /**
  111050. * If sets to true, disables all the lights affecting the material.
  111051. */
  111052. protected _disableLighting: boolean;
  111053. /**
  111054. * Number of Simultaneous lights allowed on the material.
  111055. */
  111056. protected _maxSimultaneousLights: number;
  111057. /**
  111058. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111059. */
  111060. protected _invertNormalMapX: boolean;
  111061. /**
  111062. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111063. */
  111064. protected _invertNormalMapY: boolean;
  111065. /**
  111066. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111067. */
  111068. protected _twoSidedLighting: boolean;
  111069. /**
  111070. * Defines the alpha limits in alpha test mode.
  111071. */
  111072. protected _alphaCutOff: number;
  111073. /**
  111074. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111075. */
  111076. protected _forceAlphaTest: boolean;
  111077. /**
  111078. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111079. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111080. */
  111081. protected _useAlphaFresnel: boolean;
  111082. /**
  111083. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111084. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111085. */
  111086. protected _useLinearAlphaFresnel: boolean;
  111087. /**
  111088. * The transparency mode of the material.
  111089. */
  111090. protected _transparencyMode: Nullable<number>;
  111091. /**
  111092. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  111093. * from cos thetav and roughness:
  111094. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  111095. */
  111096. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  111097. /**
  111098. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111099. */
  111100. protected _forceIrradianceInFragment: boolean;
  111101. /**
  111102. * Force normal to face away from face.
  111103. */
  111104. protected _forceNormalForward: boolean;
  111105. /**
  111106. * Enables specular anti aliasing in the PBR shader.
  111107. * It will both interacts on the Geometry for analytical and IBL lighting.
  111108. * It also prefilter the roughness map based on the bump values.
  111109. */
  111110. protected _enableSpecularAntiAliasing: boolean;
  111111. /**
  111112. * Default configuration related to image processing available in the PBR Material.
  111113. */
  111114. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111115. /**
  111116. * Keep track of the image processing observer to allow dispose and replace.
  111117. */
  111118. private _imageProcessingObserver;
  111119. /**
  111120. * Attaches a new image processing configuration to the PBR Material.
  111121. * @param configuration
  111122. */
  111123. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111124. /**
  111125. * Stores the available render targets.
  111126. */
  111127. private _renderTargets;
  111128. /**
  111129. * Sets the global ambient color for the material used in lighting calculations.
  111130. */
  111131. private _globalAmbientColor;
  111132. /**
  111133. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  111134. */
  111135. private _useLogarithmicDepth;
  111136. /**
  111137. * If set to true, no lighting calculations will be applied.
  111138. */
  111139. private _unlit;
  111140. private _debugMode;
  111141. /**
  111142. * @hidden
  111143. * This is reserved for the inspector.
  111144. * Defines the material debug mode.
  111145. * It helps seeing only some components of the material while troubleshooting.
  111146. */
  111147. debugMode: number;
  111148. /**
  111149. * @hidden
  111150. * This is reserved for the inspector.
  111151. * Specify from where on screen the debug mode should start.
  111152. * The value goes from -1 (full screen) to 1 (not visible)
  111153. * It helps with side by side comparison against the final render
  111154. * This defaults to -1
  111155. */
  111156. private debugLimit;
  111157. /**
  111158. * @hidden
  111159. * This is reserved for the inspector.
  111160. * As the default viewing range might not be enough (if the ambient is really small for instance)
  111161. * You can use the factor to better multiply the final value.
  111162. */
  111163. private debugFactor;
  111164. /**
  111165. * Defines the clear coat layer parameters for the material.
  111166. */
  111167. readonly clearCoat: PBRClearCoatConfiguration;
  111168. /**
  111169. * Defines the anisotropic parameters for the material.
  111170. */
  111171. readonly anisotropy: PBRAnisotropicConfiguration;
  111172. /**
  111173. * Defines the BRDF parameters for the material.
  111174. */
  111175. readonly brdf: PBRBRDFConfiguration;
  111176. /**
  111177. * Defines the Sheen parameters for the material.
  111178. */
  111179. readonly sheen: PBRSheenConfiguration;
  111180. /**
  111181. * Defines the SubSurface parameters for the material.
  111182. */
  111183. readonly subSurface: PBRSubSurfaceConfiguration;
  111184. /**
  111185. * Custom callback helping to override the default shader used in the material.
  111186. */
  111187. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  111188. /**
  111189. * Instantiates a new PBRMaterial instance.
  111190. *
  111191. * @param name The material name
  111192. * @param scene The scene the material will be use in.
  111193. */
  111194. constructor(name: string, scene: Scene);
  111195. /**
  111196. * Gets a boolean indicating that current material needs to register RTT
  111197. */
  111198. readonly hasRenderTargetTextures: boolean;
  111199. /**
  111200. * Gets the name of the material class.
  111201. */
  111202. getClassName(): string;
  111203. /**
  111204. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111205. */
  111206. /**
  111207. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111208. */
  111209. useLogarithmicDepth: boolean;
  111210. /**
  111211. * Gets the current transparency mode.
  111212. */
  111213. /**
  111214. * Sets the transparency mode of the material.
  111215. *
  111216. * | Value | Type | Description |
  111217. * | ----- | ----------------------------------- | ----------- |
  111218. * | 0 | OPAQUE | |
  111219. * | 1 | ALPHATEST | |
  111220. * | 2 | ALPHABLEND | |
  111221. * | 3 | ALPHATESTANDBLEND | |
  111222. *
  111223. */
  111224. transparencyMode: Nullable<number>;
  111225. /**
  111226. * Returns true if alpha blending should be disabled.
  111227. */
  111228. private readonly _disableAlphaBlending;
  111229. /**
  111230. * Specifies whether or not this material should be rendered in alpha blend mode.
  111231. */
  111232. needAlphaBlending(): boolean;
  111233. /**
  111234. * Specifies if the mesh will require alpha blending.
  111235. * @param mesh - BJS mesh.
  111236. */
  111237. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111238. /**
  111239. * Specifies whether or not this material should be rendered in alpha test mode.
  111240. */
  111241. needAlphaTesting(): boolean;
  111242. /**
  111243. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  111244. */
  111245. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  111246. /**
  111247. * Gets the texture used for the alpha test.
  111248. */
  111249. getAlphaTestTexture(): Nullable<BaseTexture>;
  111250. /**
  111251. * Specifies that the submesh is ready to be used.
  111252. * @param mesh - BJS mesh.
  111253. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  111254. * @param useInstances - Specifies that instances should be used.
  111255. * @returns - boolean indicating that the submesh is ready or not.
  111256. */
  111257. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111258. /**
  111259. * Specifies if the material uses metallic roughness workflow.
  111260. * @returns boolean specifiying if the material uses metallic roughness workflow.
  111261. */
  111262. isMetallicWorkflow(): boolean;
  111263. private _prepareEffect;
  111264. private _prepareDefines;
  111265. /**
  111266. * Force shader compilation
  111267. */
  111268. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  111269. clipPlane: boolean;
  111270. }>): void;
  111271. /**
  111272. * Initializes the uniform buffer layout for the shader.
  111273. */
  111274. buildUniformLayout(): void;
  111275. /**
  111276. * Unbinds the material from the mesh
  111277. */
  111278. unbind(): void;
  111279. /**
  111280. * Binds the submesh data.
  111281. * @param world - The world matrix.
  111282. * @param mesh - The BJS mesh.
  111283. * @param subMesh - A submesh of the BJS mesh.
  111284. */
  111285. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111286. /**
  111287. * Returns the animatable textures.
  111288. * @returns - Array of animatable textures.
  111289. */
  111290. getAnimatables(): IAnimatable[];
  111291. /**
  111292. * Returns the texture used for reflections.
  111293. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  111294. */
  111295. private _getReflectionTexture;
  111296. /**
  111297. * Returns an array of the actively used textures.
  111298. * @returns - Array of BaseTextures
  111299. */
  111300. getActiveTextures(): BaseTexture[];
  111301. /**
  111302. * Checks to see if a texture is used in the material.
  111303. * @param texture - Base texture to use.
  111304. * @returns - Boolean specifying if a texture is used in the material.
  111305. */
  111306. hasTexture(texture: BaseTexture): boolean;
  111307. /**
  111308. * Disposes the resources of the material.
  111309. * @param forceDisposeEffect - Forces the disposal of effects.
  111310. * @param forceDisposeTextures - Forces the disposal of all textures.
  111311. */
  111312. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111313. }
  111314. }
  111315. declare module BABYLON {
  111316. /**
  111317. * The Physically based material of BJS.
  111318. *
  111319. * This offers the main features of a standard PBR material.
  111320. * For more information, please refer to the documentation :
  111321. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111322. */
  111323. export class PBRMaterial extends PBRBaseMaterial {
  111324. /**
  111325. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111326. */
  111327. static readonly PBRMATERIAL_OPAQUE: number;
  111328. /**
  111329. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111330. */
  111331. static readonly PBRMATERIAL_ALPHATEST: number;
  111332. /**
  111333. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111334. */
  111335. static readonly PBRMATERIAL_ALPHABLEND: number;
  111336. /**
  111337. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111338. * They are also discarded below the alpha cutoff threshold to improve performances.
  111339. */
  111340. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111341. /**
  111342. * Defines the default value of how much AO map is occluding the analytical lights
  111343. * (point spot...).
  111344. */
  111345. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111346. /**
  111347. * Intensity of the direct lights e.g. the four lights available in your scene.
  111348. * This impacts both the direct diffuse and specular highlights.
  111349. */
  111350. directIntensity: number;
  111351. /**
  111352. * Intensity of the emissive part of the material.
  111353. * This helps controlling the emissive effect without modifying the emissive color.
  111354. */
  111355. emissiveIntensity: number;
  111356. /**
  111357. * Intensity of the environment e.g. how much the environment will light the object
  111358. * either through harmonics for rough material or through the refelction for shiny ones.
  111359. */
  111360. environmentIntensity: number;
  111361. /**
  111362. * This is a special control allowing the reduction of the specular highlights coming from the
  111363. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111364. */
  111365. specularIntensity: number;
  111366. /**
  111367. * Debug Control allowing disabling the bump map on this material.
  111368. */
  111369. disableBumpMap: boolean;
  111370. /**
  111371. * AKA Diffuse Texture in standard nomenclature.
  111372. */
  111373. albedoTexture: BaseTexture;
  111374. /**
  111375. * AKA Occlusion Texture in other nomenclature.
  111376. */
  111377. ambientTexture: BaseTexture;
  111378. /**
  111379. * AKA Occlusion Texture Intensity in other nomenclature.
  111380. */
  111381. ambientTextureStrength: number;
  111382. /**
  111383. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111384. * 1 means it completely occludes it
  111385. * 0 mean it has no impact
  111386. */
  111387. ambientTextureImpactOnAnalyticalLights: number;
  111388. /**
  111389. * Stores the alpha values in a texture.
  111390. */
  111391. opacityTexture: BaseTexture;
  111392. /**
  111393. * Stores the reflection values in a texture.
  111394. */
  111395. reflectionTexture: Nullable<BaseTexture>;
  111396. /**
  111397. * Stores the emissive values in a texture.
  111398. */
  111399. emissiveTexture: BaseTexture;
  111400. /**
  111401. * AKA Specular texture in other nomenclature.
  111402. */
  111403. reflectivityTexture: BaseTexture;
  111404. /**
  111405. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111406. */
  111407. metallicTexture: BaseTexture;
  111408. /**
  111409. * Specifies the metallic scalar of the metallic/roughness workflow.
  111410. * Can also be used to scale the metalness values of the metallic texture.
  111411. */
  111412. metallic: Nullable<number>;
  111413. /**
  111414. * Specifies the roughness scalar of the metallic/roughness workflow.
  111415. * Can also be used to scale the roughness values of the metallic texture.
  111416. */
  111417. roughness: Nullable<number>;
  111418. /**
  111419. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111420. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111421. */
  111422. microSurfaceTexture: BaseTexture;
  111423. /**
  111424. * Stores surface normal data used to displace a mesh in a texture.
  111425. */
  111426. bumpTexture: BaseTexture;
  111427. /**
  111428. * Stores the pre-calculated light information of a mesh in a texture.
  111429. */
  111430. lightmapTexture: BaseTexture;
  111431. /**
  111432. * Stores the refracted light information in a texture.
  111433. */
  111434. refractionTexture: Nullable<BaseTexture>;
  111435. /**
  111436. * The color of a material in ambient lighting.
  111437. */
  111438. ambientColor: Color3;
  111439. /**
  111440. * AKA Diffuse Color in other nomenclature.
  111441. */
  111442. albedoColor: Color3;
  111443. /**
  111444. * AKA Specular Color in other nomenclature.
  111445. */
  111446. reflectivityColor: Color3;
  111447. /**
  111448. * The color reflected from the material.
  111449. */
  111450. reflectionColor: Color3;
  111451. /**
  111452. * The color emitted from the material.
  111453. */
  111454. emissiveColor: Color3;
  111455. /**
  111456. * AKA Glossiness in other nomenclature.
  111457. */
  111458. microSurface: number;
  111459. /**
  111460. * source material index of refraction (IOR)' / 'destination material IOR.
  111461. */
  111462. indexOfRefraction: number;
  111463. /**
  111464. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  111465. */
  111466. invertRefractionY: boolean;
  111467. /**
  111468. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  111469. * Materials half opaque for instance using refraction could benefit from this control.
  111470. */
  111471. linkRefractionWithTransparency: boolean;
  111472. /**
  111473. * If true, the light map contains occlusion information instead of lighting info.
  111474. */
  111475. useLightmapAsShadowmap: boolean;
  111476. /**
  111477. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111478. */
  111479. useAlphaFromAlbedoTexture: boolean;
  111480. /**
  111481. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111482. */
  111483. forceAlphaTest: boolean;
  111484. /**
  111485. * Defines the alpha limits in alpha test mode.
  111486. */
  111487. alphaCutOff: number;
  111488. /**
  111489. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111490. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111491. */
  111492. useSpecularOverAlpha: boolean;
  111493. /**
  111494. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111495. */
  111496. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111497. /**
  111498. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111499. */
  111500. useRoughnessFromMetallicTextureAlpha: boolean;
  111501. /**
  111502. * Specifies if the metallic texture contains the roughness information in its green channel.
  111503. */
  111504. useRoughnessFromMetallicTextureGreen: boolean;
  111505. /**
  111506. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111507. */
  111508. useMetallnessFromMetallicTextureBlue: boolean;
  111509. /**
  111510. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111511. */
  111512. useAmbientOcclusionFromMetallicTextureRed: boolean;
  111513. /**
  111514. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111515. */
  111516. useAmbientInGrayScale: boolean;
  111517. /**
  111518. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111519. * The material will try to infer what glossiness each pixel should be.
  111520. */
  111521. useAutoMicroSurfaceFromReflectivityMap: boolean;
  111522. /**
  111523. * BJS is using an harcoded light falloff based on a manually sets up range.
  111524. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111525. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111526. */
  111527. /**
  111528. * BJS is using an harcoded light falloff based on a manually sets up range.
  111529. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111530. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111531. */
  111532. usePhysicalLightFalloff: boolean;
  111533. /**
  111534. * In order to support the falloff compatibility with gltf, a special mode has been added
  111535. * to reproduce the gltf light falloff.
  111536. */
  111537. /**
  111538. * In order to support the falloff compatibility with gltf, a special mode has been added
  111539. * to reproduce the gltf light falloff.
  111540. */
  111541. useGLTFLightFalloff: boolean;
  111542. /**
  111543. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111544. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111545. */
  111546. useRadianceOverAlpha: boolean;
  111547. /**
  111548. * Allows using an object space normal map (instead of tangent space).
  111549. */
  111550. useObjectSpaceNormalMap: boolean;
  111551. /**
  111552. * Allows using the bump map in parallax mode.
  111553. */
  111554. useParallax: boolean;
  111555. /**
  111556. * Allows using the bump map in parallax occlusion mode.
  111557. */
  111558. useParallaxOcclusion: boolean;
  111559. /**
  111560. * Controls the scale bias of the parallax mode.
  111561. */
  111562. parallaxScaleBias: number;
  111563. /**
  111564. * If sets to true, disables all the lights affecting the material.
  111565. */
  111566. disableLighting: boolean;
  111567. /**
  111568. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111569. */
  111570. forceIrradianceInFragment: boolean;
  111571. /**
  111572. * Number of Simultaneous lights allowed on the material.
  111573. */
  111574. maxSimultaneousLights: number;
  111575. /**
  111576. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111577. */
  111578. invertNormalMapX: boolean;
  111579. /**
  111580. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111581. */
  111582. invertNormalMapY: boolean;
  111583. /**
  111584. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111585. */
  111586. twoSidedLighting: boolean;
  111587. /**
  111588. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111589. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111590. */
  111591. useAlphaFresnel: boolean;
  111592. /**
  111593. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111594. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111595. */
  111596. useLinearAlphaFresnel: boolean;
  111597. /**
  111598. * Let user defines the brdf lookup texture used for IBL.
  111599. * A default 8bit version is embedded but you could point at :
  111600. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  111601. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111602. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  111603. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111604. */
  111605. environmentBRDFTexture: Nullable<BaseTexture>;
  111606. /**
  111607. * Force normal to face away from face.
  111608. */
  111609. forceNormalForward: boolean;
  111610. /**
  111611. * Enables specular anti aliasing in the PBR shader.
  111612. * It will both interacts on the Geometry for analytical and IBL lighting.
  111613. * It also prefilter the roughness map based on the bump values.
  111614. */
  111615. enableSpecularAntiAliasing: boolean;
  111616. /**
  111617. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111618. * makes the reflect vector face the model (under horizon).
  111619. */
  111620. useHorizonOcclusion: boolean;
  111621. /**
  111622. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111623. * too much the area relying on ambient texture to define their ambient occlusion.
  111624. */
  111625. useRadianceOcclusion: boolean;
  111626. /**
  111627. * If set to true, no lighting calculations will be applied.
  111628. */
  111629. unlit: boolean;
  111630. /**
  111631. * Gets the image processing configuration used either in this material.
  111632. */
  111633. /**
  111634. * Sets the Default image processing configuration used either in the this material.
  111635. *
  111636. * If sets to null, the scene one is in use.
  111637. */
  111638. imageProcessingConfiguration: ImageProcessingConfiguration;
  111639. /**
  111640. * Gets wether the color curves effect is enabled.
  111641. */
  111642. /**
  111643. * Sets wether the color curves effect is enabled.
  111644. */
  111645. cameraColorCurvesEnabled: boolean;
  111646. /**
  111647. * Gets wether the color grading effect is enabled.
  111648. */
  111649. /**
  111650. * Gets wether the color grading effect is enabled.
  111651. */
  111652. cameraColorGradingEnabled: boolean;
  111653. /**
  111654. * Gets wether tonemapping is enabled or not.
  111655. */
  111656. /**
  111657. * Sets wether tonemapping is enabled or not
  111658. */
  111659. cameraToneMappingEnabled: boolean;
  111660. /**
  111661. * The camera exposure used on this material.
  111662. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111663. * This corresponds to a photographic exposure.
  111664. */
  111665. /**
  111666. * The camera exposure used on this material.
  111667. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111668. * This corresponds to a photographic exposure.
  111669. */
  111670. cameraExposure: number;
  111671. /**
  111672. * Gets The camera contrast used on this material.
  111673. */
  111674. /**
  111675. * Sets The camera contrast used on this material.
  111676. */
  111677. cameraContrast: number;
  111678. /**
  111679. * Gets the Color Grading 2D Lookup Texture.
  111680. */
  111681. /**
  111682. * Sets the Color Grading 2D Lookup Texture.
  111683. */
  111684. cameraColorGradingTexture: Nullable<BaseTexture>;
  111685. /**
  111686. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111687. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111688. * 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;
  111689. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111690. */
  111691. /**
  111692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111694. * 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;
  111695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111696. */
  111697. cameraColorCurves: Nullable<ColorCurves>;
  111698. /**
  111699. * Instantiates a new PBRMaterial instance.
  111700. *
  111701. * @param name The material name
  111702. * @param scene The scene the material will be use in.
  111703. */
  111704. constructor(name: string, scene: Scene);
  111705. /**
  111706. * Returns the name of this material class.
  111707. */
  111708. getClassName(): string;
  111709. /**
  111710. * Makes a duplicate of the current material.
  111711. * @param name - name to use for the new material.
  111712. */
  111713. clone(name: string): PBRMaterial;
  111714. /**
  111715. * Serializes this PBR Material.
  111716. * @returns - An object with the serialized material.
  111717. */
  111718. serialize(): any;
  111719. /**
  111720. * Parses a PBR Material from a serialized object.
  111721. * @param source - Serialized object.
  111722. * @param scene - BJS scene instance.
  111723. * @param rootUrl - url for the scene object
  111724. * @returns - PBRMaterial
  111725. */
  111726. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  111727. }
  111728. }
  111729. declare module BABYLON {
  111730. /**
  111731. * Direct draw surface info
  111732. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  111733. */
  111734. export interface DDSInfo {
  111735. /**
  111736. * Width of the texture
  111737. */
  111738. width: number;
  111739. /**
  111740. * Width of the texture
  111741. */
  111742. height: number;
  111743. /**
  111744. * Number of Mipmaps for the texture
  111745. * @see https://en.wikipedia.org/wiki/Mipmap
  111746. */
  111747. mipmapCount: number;
  111748. /**
  111749. * If the textures format is a known fourCC format
  111750. * @see https://www.fourcc.org/
  111751. */
  111752. isFourCC: boolean;
  111753. /**
  111754. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  111755. */
  111756. isRGB: boolean;
  111757. /**
  111758. * If the texture is a lumincance format
  111759. */
  111760. isLuminance: boolean;
  111761. /**
  111762. * If this is a cube texture
  111763. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  111764. */
  111765. isCube: boolean;
  111766. /**
  111767. * If the texture is a compressed format eg. FOURCC_DXT1
  111768. */
  111769. isCompressed: boolean;
  111770. /**
  111771. * The dxgiFormat of the texture
  111772. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  111773. */
  111774. dxgiFormat: number;
  111775. /**
  111776. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  111777. */
  111778. textureType: number;
  111779. /**
  111780. * Sphericle polynomial created for the dds texture
  111781. */
  111782. sphericalPolynomial?: SphericalPolynomial;
  111783. }
  111784. /**
  111785. * Class used to provide DDS decompression tools
  111786. */
  111787. export class DDSTools {
  111788. /**
  111789. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  111790. */
  111791. static StoreLODInAlphaChannel: boolean;
  111792. /**
  111793. * Gets DDS information from an array buffer
  111794. * @param arrayBuffer defines the array buffer to read data from
  111795. * @returns the DDS information
  111796. */
  111797. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  111798. private static _FloatView;
  111799. private static _Int32View;
  111800. private static _ToHalfFloat;
  111801. private static _FromHalfFloat;
  111802. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  111803. private static _GetHalfFloatRGBAArrayBuffer;
  111804. private static _GetFloatRGBAArrayBuffer;
  111805. private static _GetFloatAsUIntRGBAArrayBuffer;
  111806. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  111807. private static _GetRGBAArrayBuffer;
  111808. private static _ExtractLongWordOrder;
  111809. private static _GetRGBArrayBuffer;
  111810. private static _GetLuminanceArrayBuffer;
  111811. /**
  111812. * Uploads DDS Levels to a Babylon Texture
  111813. * @hidden
  111814. */
  111815. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  111816. }
  111817. interface Engine {
  111818. /**
  111819. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  111820. * @param rootUrl defines the url where the file to load is located
  111821. * @param scene defines the current scene
  111822. * @param lodScale defines scale to apply to the mip map selection
  111823. * @param lodOffset defines offset to apply to the mip map selection
  111824. * @param onLoad defines an optional callback raised when the texture is loaded
  111825. * @param onError defines an optional callback raised if there is an issue to load the texture
  111826. * @param format defines the format of the data
  111827. * @param forcedExtension defines the extension to use to pick the right loader
  111828. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  111829. * @returns the cube texture as an InternalTexture
  111830. */
  111831. 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;
  111832. }
  111833. }
  111834. declare module BABYLON {
  111835. /**
  111836. * Implementation of the DDS Texture Loader.
  111837. * @hidden
  111838. */
  111839. export class _DDSTextureLoader implements IInternalTextureLoader {
  111840. /**
  111841. * Defines wether the loader supports cascade loading the different faces.
  111842. */
  111843. readonly supportCascades: boolean;
  111844. /**
  111845. * This returns if the loader support the current file information.
  111846. * @param extension defines the file extension of the file being loaded
  111847. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111848. * @param fallback defines the fallback internal texture if any
  111849. * @param isBase64 defines whether the texture is encoded as a base64
  111850. * @param isBuffer defines whether the texture data are stored as a buffer
  111851. * @returns true if the loader can load the specified file
  111852. */
  111853. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111854. /**
  111855. * Transform the url before loading if required.
  111856. * @param rootUrl the url of the texture
  111857. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111858. * @returns the transformed texture
  111859. */
  111860. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111861. /**
  111862. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111863. * @param rootUrl the url of the texture
  111864. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111865. * @returns the fallback texture
  111866. */
  111867. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111868. /**
  111869. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111870. * @param data contains the texture data
  111871. * @param texture defines the BabylonJS internal texture
  111872. * @param createPolynomials will be true if polynomials have been requested
  111873. * @param onLoad defines the callback to trigger once the texture is ready
  111874. * @param onError defines the callback to trigger in case of error
  111875. */
  111876. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111877. /**
  111878. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111879. * @param data contains the texture data
  111880. * @param texture defines the BabylonJS internal texture
  111881. * @param callback defines the method to call once ready to upload
  111882. */
  111883. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111884. }
  111885. }
  111886. declare module BABYLON {
  111887. /** @hidden */
  111888. export var rgbdEncodePixelShader: {
  111889. name: string;
  111890. shader: string;
  111891. };
  111892. }
  111893. declare module BABYLON {
  111894. /**
  111895. * Raw texture data and descriptor sufficient for WebGL texture upload
  111896. */
  111897. export interface EnvironmentTextureInfo {
  111898. /**
  111899. * Version of the environment map
  111900. */
  111901. version: number;
  111902. /**
  111903. * Width of image
  111904. */
  111905. width: number;
  111906. /**
  111907. * Irradiance information stored in the file.
  111908. */
  111909. irradiance: any;
  111910. /**
  111911. * Specular information stored in the file.
  111912. */
  111913. specular: any;
  111914. }
  111915. /**
  111916. * Sets of helpers addressing the serialization and deserialization of environment texture
  111917. * stored in a BabylonJS env file.
  111918. * Those files are usually stored as .env files.
  111919. */
  111920. export class EnvironmentTextureTools {
  111921. /**
  111922. * Magic number identifying the env file.
  111923. */
  111924. private static _MagicBytes;
  111925. /**
  111926. * Gets the environment info from an env file.
  111927. * @param data The array buffer containing the .env bytes.
  111928. * @returns the environment file info (the json header) if successfully parsed.
  111929. */
  111930. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111931. /**
  111932. * Creates an environment texture from a loaded cube texture.
  111933. * @param texture defines the cube texture to convert in env file
  111934. * @return a promise containing the environment data if succesfull.
  111935. */
  111936. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111937. /**
  111938. * Creates a JSON representation of the spherical data.
  111939. * @param texture defines the texture containing the polynomials
  111940. * @return the JSON representation of the spherical info
  111941. */
  111942. private static _CreateEnvTextureIrradiance;
  111943. /**
  111944. * Uploads the texture info contained in the env file to the GPU.
  111945. * @param texture defines the internal texture to upload to
  111946. * @param arrayBuffer defines the buffer cotaining the data to load
  111947. * @param info defines the texture info retrieved through the GetEnvInfo method
  111948. * @returns a promise
  111949. */
  111950. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111951. /**
  111952. * Uploads the levels of image data to the GPU.
  111953. * @param texture defines the internal texture to upload to
  111954. * @param imageData defines the array buffer views of image data [mipmap][face]
  111955. * @returns a promise
  111956. */
  111957. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111958. /**
  111959. * Uploads spherical polynomials information to the texture.
  111960. * @param texture defines the texture we are trying to upload the information to
  111961. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111962. */
  111963. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111964. /** @hidden */
  111965. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111966. }
  111967. }
  111968. declare module BABYLON {
  111969. /**
  111970. * Implementation of the ENV Texture Loader.
  111971. * @hidden
  111972. */
  111973. export class _ENVTextureLoader implements IInternalTextureLoader {
  111974. /**
  111975. * Defines wether the loader supports cascade loading the different faces.
  111976. */
  111977. readonly supportCascades: boolean;
  111978. /**
  111979. * This returns if the loader support the current file information.
  111980. * @param extension defines the file extension of the file being loaded
  111981. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111982. * @param fallback defines the fallback internal texture if any
  111983. * @param isBase64 defines whether the texture is encoded as a base64
  111984. * @param isBuffer defines whether the texture data are stored as a buffer
  111985. * @returns true if the loader can load the specified file
  111986. */
  111987. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111988. /**
  111989. * Transform the url before loading if required.
  111990. * @param rootUrl the url of the texture
  111991. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111992. * @returns the transformed texture
  111993. */
  111994. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111995. /**
  111996. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111997. * @param rootUrl the url of the texture
  111998. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111999. * @returns the fallback texture
  112000. */
  112001. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112002. /**
  112003. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112004. * @param data contains the texture data
  112005. * @param texture defines the BabylonJS internal texture
  112006. * @param createPolynomials will be true if polynomials have been requested
  112007. * @param onLoad defines the callback to trigger once the texture is ready
  112008. * @param onError defines the callback to trigger in case of error
  112009. */
  112010. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112011. /**
  112012. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112013. * @param data contains the texture data
  112014. * @param texture defines the BabylonJS internal texture
  112015. * @param callback defines the method to call once ready to upload
  112016. */
  112017. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112018. }
  112019. }
  112020. declare module BABYLON {
  112021. /**
  112022. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  112023. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  112024. */
  112025. export class KhronosTextureContainer {
  112026. /** contents of the KTX container file */
  112027. arrayBuffer: any;
  112028. private static HEADER_LEN;
  112029. private static COMPRESSED_2D;
  112030. private static COMPRESSED_3D;
  112031. private static TEX_2D;
  112032. private static TEX_3D;
  112033. /**
  112034. * Gets the openGL type
  112035. */
  112036. glType: number;
  112037. /**
  112038. * Gets the openGL type size
  112039. */
  112040. glTypeSize: number;
  112041. /**
  112042. * Gets the openGL format
  112043. */
  112044. glFormat: number;
  112045. /**
  112046. * Gets the openGL internal format
  112047. */
  112048. glInternalFormat: number;
  112049. /**
  112050. * Gets the base internal format
  112051. */
  112052. glBaseInternalFormat: number;
  112053. /**
  112054. * Gets image width in pixel
  112055. */
  112056. pixelWidth: number;
  112057. /**
  112058. * Gets image height in pixel
  112059. */
  112060. pixelHeight: number;
  112061. /**
  112062. * Gets image depth in pixels
  112063. */
  112064. pixelDepth: number;
  112065. /**
  112066. * Gets the number of array elements
  112067. */
  112068. numberOfArrayElements: number;
  112069. /**
  112070. * Gets the number of faces
  112071. */
  112072. numberOfFaces: number;
  112073. /**
  112074. * Gets the number of mipmap levels
  112075. */
  112076. numberOfMipmapLevels: number;
  112077. /**
  112078. * Gets the bytes of key value data
  112079. */
  112080. bytesOfKeyValueData: number;
  112081. /**
  112082. * Gets the load type
  112083. */
  112084. loadType: number;
  112085. /**
  112086. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  112087. */
  112088. isInvalid: boolean;
  112089. /**
  112090. * Creates a new KhronosTextureContainer
  112091. * @param arrayBuffer contents of the KTX container file
  112092. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  112093. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  112094. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  112095. */
  112096. constructor(
  112097. /** contents of the KTX container file */
  112098. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  112099. /**
  112100. * Uploads KTX content to a Babylon Texture.
  112101. * It is assumed that the texture has already been created & is currently bound
  112102. * @hidden
  112103. */
  112104. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  112105. private _upload2DCompressedLevels;
  112106. }
  112107. }
  112108. declare module BABYLON {
  112109. /**
  112110. * Implementation of the KTX Texture Loader.
  112111. * @hidden
  112112. */
  112113. export class _KTXTextureLoader implements IInternalTextureLoader {
  112114. /**
  112115. * Defines wether the loader supports cascade loading the different faces.
  112116. */
  112117. readonly supportCascades: boolean;
  112118. /**
  112119. * This returns if the loader support the current file information.
  112120. * @param extension defines the file extension of the file being loaded
  112121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112122. * @param fallback defines the fallback internal texture if any
  112123. * @param isBase64 defines whether the texture is encoded as a base64
  112124. * @param isBuffer defines whether the texture data are stored as a buffer
  112125. * @returns true if the loader can load the specified file
  112126. */
  112127. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112128. /**
  112129. * Transform the url before loading if required.
  112130. * @param rootUrl the url of the texture
  112131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112132. * @returns the transformed texture
  112133. */
  112134. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112135. /**
  112136. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112137. * @param rootUrl the url of the texture
  112138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112139. * @returns the fallback texture
  112140. */
  112141. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112142. /**
  112143. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112144. * @param data contains the texture data
  112145. * @param texture defines the BabylonJS internal texture
  112146. * @param createPolynomials will be true if polynomials have been requested
  112147. * @param onLoad defines the callback to trigger once the texture is ready
  112148. * @param onError defines the callback to trigger in case of error
  112149. */
  112150. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112151. /**
  112152. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112153. * @param data contains the texture data
  112154. * @param texture defines the BabylonJS internal texture
  112155. * @param callback defines the method to call once ready to upload
  112156. */
  112157. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  112158. }
  112159. }
  112160. declare module BABYLON {
  112161. /**
  112162. * Options for the default xr helper
  112163. */
  112164. export class WebXRDefaultExperienceOptions {
  112165. /**
  112166. * Floor meshes that should be used for teleporting
  112167. */
  112168. floorMeshes: Array<AbstractMesh>;
  112169. }
  112170. /**
  112171. * Default experience which provides a similar setup to the previous webVRExperience
  112172. */
  112173. export class WebXRDefaultExperience {
  112174. /**
  112175. * Base experience
  112176. */
  112177. baseExperience: WebXRExperienceHelper;
  112178. /**
  112179. * Input experience extension
  112180. */
  112181. input: WebXRInput;
  112182. /**
  112183. * Loads the controller models
  112184. */
  112185. controllerModelLoader: WebXRControllerModelLoader;
  112186. /**
  112187. * Enables laser pointer and selection
  112188. */
  112189. pointerSelection: WebXRControllerPointerSelection;
  112190. /**
  112191. * Enables teleportation
  112192. */
  112193. teleportation: WebXRControllerTeleportation;
  112194. /**
  112195. * Enables ui for enetering/exiting xr
  112196. */
  112197. enterExitUI: WebXREnterExitUI;
  112198. /**
  112199. * Default output canvas xr should render to
  112200. */
  112201. outputCanvas: WebXRManagedOutputCanvas;
  112202. /**
  112203. * Creates the default xr experience
  112204. * @param scene scene
  112205. * @param options options for basic configuration
  112206. * @returns resulting WebXRDefaultExperience
  112207. */
  112208. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112209. private constructor();
  112210. /**
  112211. * DIsposes of the experience helper
  112212. */
  112213. dispose(): void;
  112214. }
  112215. }
  112216. declare module BABYLON {
  112217. /** @hidden */
  112218. export var _forceSceneHelpersToBundle: boolean;
  112219. interface Scene {
  112220. /**
  112221. * Creates a default light for the scene.
  112222. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  112223. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  112224. */
  112225. createDefaultLight(replace?: boolean): void;
  112226. /**
  112227. * Creates a default camera for the scene.
  112228. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  112229. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112230. * @param replace has default false, when true replaces the active camera in the scene
  112231. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  112232. */
  112233. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112234. /**
  112235. * Creates a default camera and a default light.
  112236. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  112237. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112238. * @param replace has the default false, when true replaces the active camera/light in the scene
  112239. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  112240. */
  112241. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112242. /**
  112243. * Creates a new sky box
  112244. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  112245. * @param environmentTexture defines the texture to use as environment texture
  112246. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  112247. * @param scale defines the overall scale of the skybox
  112248. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  112249. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  112250. * @returns a new mesh holding the sky box
  112251. */
  112252. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  112253. /**
  112254. * Creates a new environment
  112255. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  112256. * @param options defines the options you can use to configure the environment
  112257. * @returns the new EnvironmentHelper
  112258. */
  112259. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  112260. /**
  112261. * Creates a new VREXperienceHelper
  112262. * @see http://doc.babylonjs.com/how_to/webvr_helper
  112263. * @param webVROptions defines the options used to create the new VREXperienceHelper
  112264. * @returns a new VREXperienceHelper
  112265. */
  112266. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  112267. /**
  112268. * Creates a new WebXRDefaultExperience
  112269. * @see http://doc.babylonjs.com/how_to/webxr
  112270. * @param options experience options
  112271. * @returns a promise for a new WebXRDefaultExperience
  112272. */
  112273. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112274. }
  112275. }
  112276. declare module BABYLON {
  112277. /**
  112278. * Contains position and normal vectors for a vertex
  112279. */
  112280. export class PositionNormalVertex {
  112281. /** the position of the vertex (defaut: 0,0,0) */
  112282. position: Vector3;
  112283. /** the normal of the vertex (defaut: 0,1,0) */
  112284. normal: Vector3;
  112285. /**
  112286. * Creates a PositionNormalVertex
  112287. * @param position the position of the vertex (defaut: 0,0,0)
  112288. * @param normal the normal of the vertex (defaut: 0,1,0)
  112289. */
  112290. constructor(
  112291. /** the position of the vertex (defaut: 0,0,0) */
  112292. position?: Vector3,
  112293. /** the normal of the vertex (defaut: 0,1,0) */
  112294. normal?: Vector3);
  112295. /**
  112296. * Clones the PositionNormalVertex
  112297. * @returns the cloned PositionNormalVertex
  112298. */
  112299. clone(): PositionNormalVertex;
  112300. }
  112301. /**
  112302. * Contains position, normal and uv vectors for a vertex
  112303. */
  112304. export class PositionNormalTextureVertex {
  112305. /** the position of the vertex (defaut: 0,0,0) */
  112306. position: Vector3;
  112307. /** the normal of the vertex (defaut: 0,1,0) */
  112308. normal: Vector3;
  112309. /** the uv of the vertex (default: 0,0) */
  112310. uv: Vector2;
  112311. /**
  112312. * Creates a PositionNormalTextureVertex
  112313. * @param position the position of the vertex (defaut: 0,0,0)
  112314. * @param normal the normal of the vertex (defaut: 0,1,0)
  112315. * @param uv the uv of the vertex (default: 0,0)
  112316. */
  112317. constructor(
  112318. /** the position of the vertex (defaut: 0,0,0) */
  112319. position?: Vector3,
  112320. /** the normal of the vertex (defaut: 0,1,0) */
  112321. normal?: Vector3,
  112322. /** the uv of the vertex (default: 0,0) */
  112323. uv?: Vector2);
  112324. /**
  112325. * Clones the PositionNormalTextureVertex
  112326. * @returns the cloned PositionNormalTextureVertex
  112327. */
  112328. clone(): PositionNormalTextureVertex;
  112329. }
  112330. }
  112331. declare module BABYLON {
  112332. /**
  112333. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  112334. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  112335. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  112336. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112337. */
  112338. export class VideoDome extends TransformNode {
  112339. /**
  112340. * Define the video source as a Monoscopic panoramic 360 video.
  112341. */
  112342. static readonly MODE_MONOSCOPIC: number;
  112343. /**
  112344. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112345. */
  112346. static readonly MODE_TOPBOTTOM: number;
  112347. /**
  112348. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112349. */
  112350. static readonly MODE_SIDEBYSIDE: number;
  112351. private _halfDome;
  112352. private _useDirectMapping;
  112353. /**
  112354. * The video texture being displayed on the sphere
  112355. */
  112356. protected _videoTexture: VideoTexture;
  112357. /**
  112358. * Gets the video texture being displayed on the sphere
  112359. */
  112360. readonly videoTexture: VideoTexture;
  112361. /**
  112362. * The skybox material
  112363. */
  112364. protected _material: BackgroundMaterial;
  112365. /**
  112366. * The surface used for the skybox
  112367. */
  112368. protected _mesh: Mesh;
  112369. /**
  112370. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  112371. */
  112372. private _halfDomeMask;
  112373. /**
  112374. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112375. * Also see the options.resolution property.
  112376. */
  112377. fovMultiplier: number;
  112378. private _videoMode;
  112379. /**
  112380. * Gets or set the current video mode for the video. It can be:
  112381. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  112382. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112383. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112384. */
  112385. videoMode: number;
  112386. /**
  112387. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  112388. *
  112389. */
  112390. /**
  112391. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  112392. */
  112393. halfDome: boolean;
  112394. /**
  112395. * Oberserver used in Stereoscopic VR Mode.
  112396. */
  112397. private _onBeforeCameraRenderObserver;
  112398. /**
  112399. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  112400. * @param name Element's name, child elements will append suffixes for their own names.
  112401. * @param urlsOrVideo defines the url(s) or the video element to use
  112402. * @param options An object containing optional or exposed sub element properties
  112403. */
  112404. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  112405. resolution?: number;
  112406. clickToPlay?: boolean;
  112407. autoPlay?: boolean;
  112408. loop?: boolean;
  112409. size?: number;
  112410. poster?: string;
  112411. faceForward?: boolean;
  112412. useDirectMapping?: boolean;
  112413. halfDomeMode?: boolean;
  112414. }, scene: Scene);
  112415. private _changeVideoMode;
  112416. /**
  112417. * Releases resources associated with this node.
  112418. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112419. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112420. */
  112421. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112422. }
  112423. }
  112424. declare module BABYLON {
  112425. /**
  112426. * This class can be used to get instrumentation data from a Babylon engine
  112427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112428. */
  112429. export class EngineInstrumentation implements IDisposable {
  112430. /**
  112431. * Define the instrumented engine.
  112432. */
  112433. engine: Engine;
  112434. private _captureGPUFrameTime;
  112435. private _gpuFrameTimeToken;
  112436. private _gpuFrameTime;
  112437. private _captureShaderCompilationTime;
  112438. private _shaderCompilationTime;
  112439. private _onBeginFrameObserver;
  112440. private _onEndFrameObserver;
  112441. private _onBeforeShaderCompilationObserver;
  112442. private _onAfterShaderCompilationObserver;
  112443. /**
  112444. * Gets the perf counter used for GPU frame time
  112445. */
  112446. readonly gpuFrameTimeCounter: PerfCounter;
  112447. /**
  112448. * Gets the GPU frame time capture status
  112449. */
  112450. /**
  112451. * Enable or disable the GPU frame time capture
  112452. */
  112453. captureGPUFrameTime: boolean;
  112454. /**
  112455. * Gets the perf counter used for shader compilation time
  112456. */
  112457. readonly shaderCompilationTimeCounter: PerfCounter;
  112458. /**
  112459. * Gets the shader compilation time capture status
  112460. */
  112461. /**
  112462. * Enable or disable the shader compilation time capture
  112463. */
  112464. captureShaderCompilationTime: boolean;
  112465. /**
  112466. * Instantiates a new engine instrumentation.
  112467. * This class can be used to get instrumentation data from a Babylon engine
  112468. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112469. * @param engine Defines the engine to instrument
  112470. */
  112471. constructor(
  112472. /**
  112473. * Define the instrumented engine.
  112474. */
  112475. engine: Engine);
  112476. /**
  112477. * Dispose and release associated resources.
  112478. */
  112479. dispose(): void;
  112480. }
  112481. }
  112482. declare module BABYLON {
  112483. /**
  112484. * This class can be used to get instrumentation data from a Babylon engine
  112485. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112486. */
  112487. export class SceneInstrumentation implements IDisposable {
  112488. /**
  112489. * Defines the scene to instrument
  112490. */
  112491. scene: Scene;
  112492. private _captureActiveMeshesEvaluationTime;
  112493. private _activeMeshesEvaluationTime;
  112494. private _captureRenderTargetsRenderTime;
  112495. private _renderTargetsRenderTime;
  112496. private _captureFrameTime;
  112497. private _frameTime;
  112498. private _captureRenderTime;
  112499. private _renderTime;
  112500. private _captureInterFrameTime;
  112501. private _interFrameTime;
  112502. private _captureParticlesRenderTime;
  112503. private _particlesRenderTime;
  112504. private _captureSpritesRenderTime;
  112505. private _spritesRenderTime;
  112506. private _capturePhysicsTime;
  112507. private _physicsTime;
  112508. private _captureAnimationsTime;
  112509. private _animationsTime;
  112510. private _captureCameraRenderTime;
  112511. private _cameraRenderTime;
  112512. private _onBeforeActiveMeshesEvaluationObserver;
  112513. private _onAfterActiveMeshesEvaluationObserver;
  112514. private _onBeforeRenderTargetsRenderObserver;
  112515. private _onAfterRenderTargetsRenderObserver;
  112516. private _onAfterRenderObserver;
  112517. private _onBeforeDrawPhaseObserver;
  112518. private _onAfterDrawPhaseObserver;
  112519. private _onBeforeAnimationsObserver;
  112520. private _onBeforeParticlesRenderingObserver;
  112521. private _onAfterParticlesRenderingObserver;
  112522. private _onBeforeSpritesRenderingObserver;
  112523. private _onAfterSpritesRenderingObserver;
  112524. private _onBeforePhysicsObserver;
  112525. private _onAfterPhysicsObserver;
  112526. private _onAfterAnimationsObserver;
  112527. private _onBeforeCameraRenderObserver;
  112528. private _onAfterCameraRenderObserver;
  112529. /**
  112530. * Gets the perf counter used for active meshes evaluation time
  112531. */
  112532. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  112533. /**
  112534. * Gets the active meshes evaluation time capture status
  112535. */
  112536. /**
  112537. * Enable or disable the active meshes evaluation time capture
  112538. */
  112539. captureActiveMeshesEvaluationTime: boolean;
  112540. /**
  112541. * Gets the perf counter used for render targets render time
  112542. */
  112543. readonly renderTargetsRenderTimeCounter: PerfCounter;
  112544. /**
  112545. * Gets the render targets render time capture status
  112546. */
  112547. /**
  112548. * Enable or disable the render targets render time capture
  112549. */
  112550. captureRenderTargetsRenderTime: boolean;
  112551. /**
  112552. * Gets the perf counter used for particles render time
  112553. */
  112554. readonly particlesRenderTimeCounter: PerfCounter;
  112555. /**
  112556. * Gets the particles render time capture status
  112557. */
  112558. /**
  112559. * Enable or disable the particles render time capture
  112560. */
  112561. captureParticlesRenderTime: boolean;
  112562. /**
  112563. * Gets the perf counter used for sprites render time
  112564. */
  112565. readonly spritesRenderTimeCounter: PerfCounter;
  112566. /**
  112567. * Gets the sprites render time capture status
  112568. */
  112569. /**
  112570. * Enable or disable the sprites render time capture
  112571. */
  112572. captureSpritesRenderTime: boolean;
  112573. /**
  112574. * Gets the perf counter used for physics time
  112575. */
  112576. readonly physicsTimeCounter: PerfCounter;
  112577. /**
  112578. * Gets the physics time capture status
  112579. */
  112580. /**
  112581. * Enable or disable the physics time capture
  112582. */
  112583. capturePhysicsTime: boolean;
  112584. /**
  112585. * Gets the perf counter used for animations time
  112586. */
  112587. readonly animationsTimeCounter: PerfCounter;
  112588. /**
  112589. * Gets the animations time capture status
  112590. */
  112591. /**
  112592. * Enable or disable the animations time capture
  112593. */
  112594. captureAnimationsTime: boolean;
  112595. /**
  112596. * Gets the perf counter used for frame time capture
  112597. */
  112598. readonly frameTimeCounter: PerfCounter;
  112599. /**
  112600. * Gets the frame time capture status
  112601. */
  112602. /**
  112603. * Enable or disable the frame time capture
  112604. */
  112605. captureFrameTime: boolean;
  112606. /**
  112607. * Gets the perf counter used for inter-frames time capture
  112608. */
  112609. readonly interFrameTimeCounter: PerfCounter;
  112610. /**
  112611. * Gets the inter-frames time capture status
  112612. */
  112613. /**
  112614. * Enable or disable the inter-frames time capture
  112615. */
  112616. captureInterFrameTime: boolean;
  112617. /**
  112618. * Gets the perf counter used for render time capture
  112619. */
  112620. readonly renderTimeCounter: PerfCounter;
  112621. /**
  112622. * Gets the render time capture status
  112623. */
  112624. /**
  112625. * Enable or disable the render time capture
  112626. */
  112627. captureRenderTime: boolean;
  112628. /**
  112629. * Gets the perf counter used for camera render time capture
  112630. */
  112631. readonly cameraRenderTimeCounter: PerfCounter;
  112632. /**
  112633. * Gets the camera render time capture status
  112634. */
  112635. /**
  112636. * Enable or disable the camera render time capture
  112637. */
  112638. captureCameraRenderTime: boolean;
  112639. /**
  112640. * Gets the perf counter used for draw calls
  112641. */
  112642. readonly drawCallsCounter: PerfCounter;
  112643. /**
  112644. * Instantiates a new scene instrumentation.
  112645. * This class can be used to get instrumentation data from a Babylon engine
  112646. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112647. * @param scene Defines the scene to instrument
  112648. */
  112649. constructor(
  112650. /**
  112651. * Defines the scene to instrument
  112652. */
  112653. scene: Scene);
  112654. /**
  112655. * Dispose and release associated resources.
  112656. */
  112657. dispose(): void;
  112658. }
  112659. }
  112660. declare module BABYLON {
  112661. /** @hidden */
  112662. export var glowMapGenerationPixelShader: {
  112663. name: string;
  112664. shader: string;
  112665. };
  112666. }
  112667. declare module BABYLON {
  112668. /** @hidden */
  112669. export var glowMapGenerationVertexShader: {
  112670. name: string;
  112671. shader: string;
  112672. };
  112673. }
  112674. declare module BABYLON {
  112675. /**
  112676. * Effect layer options. This helps customizing the behaviour
  112677. * of the effect layer.
  112678. */
  112679. export interface IEffectLayerOptions {
  112680. /**
  112681. * Multiplication factor apply to the canvas size to compute the render target size
  112682. * used to generated the objects (the smaller the faster).
  112683. */
  112684. mainTextureRatio: number;
  112685. /**
  112686. * Enforces a fixed size texture to ensure effect stability across devices.
  112687. */
  112688. mainTextureFixedSize?: number;
  112689. /**
  112690. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  112691. */
  112692. alphaBlendingMode: number;
  112693. /**
  112694. * The camera attached to the layer.
  112695. */
  112696. camera: Nullable<Camera>;
  112697. /**
  112698. * The rendering group to draw the layer in.
  112699. */
  112700. renderingGroupId: number;
  112701. }
  112702. /**
  112703. * The effect layer Helps adding post process effect blended with the main pass.
  112704. *
  112705. * This can be for instance use to generate glow or higlight effects on the scene.
  112706. *
  112707. * The effect layer class can not be used directly and is intented to inherited from to be
  112708. * customized per effects.
  112709. */
  112710. export abstract class EffectLayer {
  112711. private _vertexBuffers;
  112712. private _indexBuffer;
  112713. private _cachedDefines;
  112714. private _effectLayerMapGenerationEffect;
  112715. private _effectLayerOptions;
  112716. private _mergeEffect;
  112717. protected _scene: Scene;
  112718. protected _engine: Engine;
  112719. protected _maxSize: number;
  112720. protected _mainTextureDesiredSize: ISize;
  112721. protected _mainTexture: RenderTargetTexture;
  112722. protected _shouldRender: boolean;
  112723. protected _postProcesses: PostProcess[];
  112724. protected _textures: BaseTexture[];
  112725. protected _emissiveTextureAndColor: {
  112726. texture: Nullable<BaseTexture>;
  112727. color: Color4;
  112728. };
  112729. /**
  112730. * The name of the layer
  112731. */
  112732. name: string;
  112733. /**
  112734. * The clear color of the texture used to generate the glow map.
  112735. */
  112736. neutralColor: Color4;
  112737. /**
  112738. * Specifies wether the highlight layer is enabled or not.
  112739. */
  112740. isEnabled: boolean;
  112741. /**
  112742. * Gets the camera attached to the layer.
  112743. */
  112744. readonly camera: Nullable<Camera>;
  112745. /**
  112746. * Gets the rendering group id the layer should render in.
  112747. */
  112748. renderingGroupId: number;
  112749. /**
  112750. * An event triggered when the effect layer has been disposed.
  112751. */
  112752. onDisposeObservable: Observable<EffectLayer>;
  112753. /**
  112754. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  112755. */
  112756. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  112757. /**
  112758. * An event triggered when the generated texture is being merged in the scene.
  112759. */
  112760. onBeforeComposeObservable: Observable<EffectLayer>;
  112761. /**
  112762. * An event triggered when the generated texture has been merged in the scene.
  112763. */
  112764. onAfterComposeObservable: Observable<EffectLayer>;
  112765. /**
  112766. * An event triggered when the efffect layer changes its size.
  112767. */
  112768. onSizeChangedObservable: Observable<EffectLayer>;
  112769. /** @hidden */
  112770. static _SceneComponentInitialization: (scene: Scene) => void;
  112771. /**
  112772. * Instantiates a new effect Layer and references it in the scene.
  112773. * @param name The name of the layer
  112774. * @param scene The scene to use the layer in
  112775. */
  112776. constructor(
  112777. /** The Friendly of the effect in the scene */
  112778. name: string, scene: Scene);
  112779. /**
  112780. * Get the effect name of the layer.
  112781. * @return The effect name
  112782. */
  112783. abstract getEffectName(): string;
  112784. /**
  112785. * Checks for the readiness of the element composing the layer.
  112786. * @param subMesh the mesh to check for
  112787. * @param useInstances specify wether or not to use instances to render the mesh
  112788. * @return true if ready otherwise, false
  112789. */
  112790. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112791. /**
  112792. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112793. * @returns true if the effect requires stencil during the main canvas render pass.
  112794. */
  112795. abstract needStencil(): boolean;
  112796. /**
  112797. * Create the merge effect. This is the shader use to blit the information back
  112798. * to the main canvas at the end of the scene rendering.
  112799. * @returns The effect containing the shader used to merge the effect on the main canvas
  112800. */
  112801. protected abstract _createMergeEffect(): Effect;
  112802. /**
  112803. * Creates the render target textures and post processes used in the effect layer.
  112804. */
  112805. protected abstract _createTextureAndPostProcesses(): void;
  112806. /**
  112807. * Implementation specific of rendering the generating effect on the main canvas.
  112808. * @param effect The effect used to render through
  112809. */
  112810. protected abstract _internalRender(effect: Effect): void;
  112811. /**
  112812. * Sets the required values for both the emissive texture and and the main color.
  112813. */
  112814. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112815. /**
  112816. * Free any resources and references associated to a mesh.
  112817. * Internal use
  112818. * @param mesh The mesh to free.
  112819. */
  112820. abstract _disposeMesh(mesh: Mesh): void;
  112821. /**
  112822. * Serializes this layer (Glow or Highlight for example)
  112823. * @returns a serialized layer object
  112824. */
  112825. abstract serialize?(): any;
  112826. /**
  112827. * Initializes the effect layer with the required options.
  112828. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  112829. */
  112830. protected _init(options: Partial<IEffectLayerOptions>): void;
  112831. /**
  112832. * Generates the index buffer of the full screen quad blending to the main canvas.
  112833. */
  112834. private _generateIndexBuffer;
  112835. /**
  112836. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  112837. */
  112838. private _generateVertexBuffer;
  112839. /**
  112840. * Sets the main texture desired size which is the closest power of two
  112841. * of the engine canvas size.
  112842. */
  112843. private _setMainTextureSize;
  112844. /**
  112845. * Creates the main texture for the effect layer.
  112846. */
  112847. protected _createMainTexture(): void;
  112848. /**
  112849. * Adds specific effects defines.
  112850. * @param defines The defines to add specifics to.
  112851. */
  112852. protected _addCustomEffectDefines(defines: string[]): void;
  112853. /**
  112854. * Checks for the readiness of the element composing the layer.
  112855. * @param subMesh the mesh to check for
  112856. * @param useInstances specify wether or not to use instances to render the mesh
  112857. * @param emissiveTexture the associated emissive texture used to generate the glow
  112858. * @return true if ready otherwise, false
  112859. */
  112860. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  112861. /**
  112862. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  112863. */
  112864. render(): void;
  112865. /**
  112866. * Determine if a given mesh will be used in the current effect.
  112867. * @param mesh mesh to test
  112868. * @returns true if the mesh will be used
  112869. */
  112870. hasMesh(mesh: AbstractMesh): boolean;
  112871. /**
  112872. * Returns true if the layer contains information to display, otherwise false.
  112873. * @returns true if the glow layer should be rendered
  112874. */
  112875. shouldRender(): boolean;
  112876. /**
  112877. * Returns true if the mesh should render, otherwise false.
  112878. * @param mesh The mesh to render
  112879. * @returns true if it should render otherwise false
  112880. */
  112881. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  112882. /**
  112883. * Returns true if the mesh can be rendered, otherwise false.
  112884. * @param mesh The mesh to render
  112885. * @param material The material used on the mesh
  112886. * @returns true if it can be rendered otherwise false
  112887. */
  112888. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112889. /**
  112890. * Returns true if the mesh should render, otherwise false.
  112891. * @param mesh The mesh to render
  112892. * @returns true if it should render otherwise false
  112893. */
  112894. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  112895. /**
  112896. * Renders the submesh passed in parameter to the generation map.
  112897. */
  112898. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  112899. /**
  112900. * Rebuild the required buffers.
  112901. * @hidden Internal use only.
  112902. */
  112903. _rebuild(): void;
  112904. /**
  112905. * Dispose only the render target textures and post process.
  112906. */
  112907. private _disposeTextureAndPostProcesses;
  112908. /**
  112909. * Dispose the highlight layer and free resources.
  112910. */
  112911. dispose(): void;
  112912. /**
  112913. * Gets the class name of the effect layer
  112914. * @returns the string with the class name of the effect layer
  112915. */
  112916. getClassName(): string;
  112917. /**
  112918. * Creates an effect layer from parsed effect layer data
  112919. * @param parsedEffectLayer defines effect layer data
  112920. * @param scene defines the current scene
  112921. * @param rootUrl defines the root URL containing the effect layer information
  112922. * @returns a parsed effect Layer
  112923. */
  112924. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  112925. }
  112926. }
  112927. declare module BABYLON {
  112928. interface AbstractScene {
  112929. /**
  112930. * The list of effect layers (highlights/glow) added to the scene
  112931. * @see http://doc.babylonjs.com/how_to/highlight_layer
  112932. * @see http://doc.babylonjs.com/how_to/glow_layer
  112933. */
  112934. effectLayers: Array<EffectLayer>;
  112935. /**
  112936. * Removes the given effect layer from this scene.
  112937. * @param toRemove defines the effect layer to remove
  112938. * @returns the index of the removed effect layer
  112939. */
  112940. removeEffectLayer(toRemove: EffectLayer): number;
  112941. /**
  112942. * Adds the given effect layer to this scene
  112943. * @param newEffectLayer defines the effect layer to add
  112944. */
  112945. addEffectLayer(newEffectLayer: EffectLayer): void;
  112946. }
  112947. /**
  112948. * Defines the layer scene component responsible to manage any effect layers
  112949. * in a given scene.
  112950. */
  112951. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  112952. /**
  112953. * The component name helpfull to identify the component in the list of scene components.
  112954. */
  112955. readonly name: string;
  112956. /**
  112957. * The scene the component belongs to.
  112958. */
  112959. scene: Scene;
  112960. private _engine;
  112961. private _renderEffects;
  112962. private _needStencil;
  112963. private _previousStencilState;
  112964. /**
  112965. * Creates a new instance of the component for the given scene
  112966. * @param scene Defines the scene to register the component in
  112967. */
  112968. constructor(scene: Scene);
  112969. /**
  112970. * Registers the component in a given scene
  112971. */
  112972. register(): void;
  112973. /**
  112974. * Rebuilds the elements related to this component in case of
  112975. * context lost for instance.
  112976. */
  112977. rebuild(): void;
  112978. /**
  112979. * Serializes the component data to the specified json object
  112980. * @param serializationObject The object to serialize to
  112981. */
  112982. serialize(serializationObject: any): void;
  112983. /**
  112984. * Adds all the elements from the container to the scene
  112985. * @param container the container holding the elements
  112986. */
  112987. addFromContainer(container: AbstractScene): void;
  112988. /**
  112989. * Removes all the elements in the container from the scene
  112990. * @param container contains the elements to remove
  112991. * @param dispose if the removed element should be disposed (default: false)
  112992. */
  112993. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112994. /**
  112995. * Disposes the component and the associated ressources.
  112996. */
  112997. dispose(): void;
  112998. private _isReadyForMesh;
  112999. private _renderMainTexture;
  113000. private _setStencil;
  113001. private _setStencilBack;
  113002. private _draw;
  113003. private _drawCamera;
  113004. private _drawRenderingGroup;
  113005. }
  113006. }
  113007. declare module BABYLON {
  113008. /** @hidden */
  113009. export var glowMapMergePixelShader: {
  113010. name: string;
  113011. shader: string;
  113012. };
  113013. }
  113014. declare module BABYLON {
  113015. /** @hidden */
  113016. export var glowMapMergeVertexShader: {
  113017. name: string;
  113018. shader: string;
  113019. };
  113020. }
  113021. declare module BABYLON {
  113022. interface AbstractScene {
  113023. /**
  113024. * Return a the first highlight layer of the scene with a given name.
  113025. * @param name The name of the highlight layer to look for.
  113026. * @return The highlight layer if found otherwise null.
  113027. */
  113028. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  113029. }
  113030. /**
  113031. * Glow layer options. This helps customizing the behaviour
  113032. * of the glow layer.
  113033. */
  113034. export interface IGlowLayerOptions {
  113035. /**
  113036. * Multiplication factor apply to the canvas size to compute the render target size
  113037. * used to generated the glowing objects (the smaller the faster).
  113038. */
  113039. mainTextureRatio: number;
  113040. /**
  113041. * Enforces a fixed size texture to ensure resize independant blur.
  113042. */
  113043. mainTextureFixedSize?: number;
  113044. /**
  113045. * How big is the kernel of the blur texture.
  113046. */
  113047. blurKernelSize: number;
  113048. /**
  113049. * The camera attached to the layer.
  113050. */
  113051. camera: Nullable<Camera>;
  113052. /**
  113053. * Enable MSAA by chosing the number of samples.
  113054. */
  113055. mainTextureSamples?: number;
  113056. /**
  113057. * The rendering group to draw the layer in.
  113058. */
  113059. renderingGroupId: number;
  113060. }
  113061. /**
  113062. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  113063. *
  113064. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113065. * glowy meshes to your scene.
  113066. *
  113067. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  113068. */
  113069. export class GlowLayer extends EffectLayer {
  113070. /**
  113071. * Effect Name of the layer.
  113072. */
  113073. static readonly EffectName: string;
  113074. /**
  113075. * The default blur kernel size used for the glow.
  113076. */
  113077. static DefaultBlurKernelSize: number;
  113078. /**
  113079. * The default texture size ratio used for the glow.
  113080. */
  113081. static DefaultTextureRatio: number;
  113082. /**
  113083. * Sets the kernel size of the blur.
  113084. */
  113085. /**
  113086. * Gets the kernel size of the blur.
  113087. */
  113088. blurKernelSize: number;
  113089. /**
  113090. * Sets the glow intensity.
  113091. */
  113092. /**
  113093. * Gets the glow intensity.
  113094. */
  113095. intensity: number;
  113096. private _options;
  113097. private _intensity;
  113098. private _horizontalBlurPostprocess1;
  113099. private _verticalBlurPostprocess1;
  113100. private _horizontalBlurPostprocess2;
  113101. private _verticalBlurPostprocess2;
  113102. private _blurTexture1;
  113103. private _blurTexture2;
  113104. private _postProcesses1;
  113105. private _postProcesses2;
  113106. private _includedOnlyMeshes;
  113107. private _excludedMeshes;
  113108. /**
  113109. * Callback used to let the user override the color selection on a per mesh basis
  113110. */
  113111. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  113112. /**
  113113. * Callback used to let the user override the texture selection on a per mesh basis
  113114. */
  113115. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  113116. /**
  113117. * Instantiates a new glow Layer and references it to the scene.
  113118. * @param name The name of the layer
  113119. * @param scene The scene to use the layer in
  113120. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  113121. */
  113122. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  113123. /**
  113124. * Get the effect name of the layer.
  113125. * @return The effect name
  113126. */
  113127. getEffectName(): string;
  113128. /**
  113129. * Create the merge effect. This is the shader use to blit the information back
  113130. * to the main canvas at the end of the scene rendering.
  113131. */
  113132. protected _createMergeEffect(): Effect;
  113133. /**
  113134. * Creates the render target textures and post processes used in the glow layer.
  113135. */
  113136. protected _createTextureAndPostProcesses(): void;
  113137. /**
  113138. * Checks for the readiness of the element composing the layer.
  113139. * @param subMesh the mesh to check for
  113140. * @param useInstances specify wether or not to use instances to render the mesh
  113141. * @param emissiveTexture the associated emissive texture used to generate the glow
  113142. * @return true if ready otherwise, false
  113143. */
  113144. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113145. /**
  113146. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113147. */
  113148. needStencil(): boolean;
  113149. /**
  113150. * Returns true if the mesh can be rendered, otherwise false.
  113151. * @param mesh The mesh to render
  113152. * @param material The material used on the mesh
  113153. * @returns true if it can be rendered otherwise false
  113154. */
  113155. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113156. /**
  113157. * Implementation specific of rendering the generating effect on the main canvas.
  113158. * @param effect The effect used to render through
  113159. */
  113160. protected _internalRender(effect: Effect): void;
  113161. /**
  113162. * Sets the required values for both the emissive texture and and the main color.
  113163. */
  113164. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113165. /**
  113166. * Returns true if the mesh should render, otherwise false.
  113167. * @param mesh The mesh to render
  113168. * @returns true if it should render otherwise false
  113169. */
  113170. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113171. /**
  113172. * Adds specific effects defines.
  113173. * @param defines The defines to add specifics to.
  113174. */
  113175. protected _addCustomEffectDefines(defines: string[]): void;
  113176. /**
  113177. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  113178. * @param mesh The mesh to exclude from the glow layer
  113179. */
  113180. addExcludedMesh(mesh: Mesh): void;
  113181. /**
  113182. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  113183. * @param mesh The mesh to remove
  113184. */
  113185. removeExcludedMesh(mesh: Mesh): void;
  113186. /**
  113187. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  113188. * @param mesh The mesh to include in the glow layer
  113189. */
  113190. addIncludedOnlyMesh(mesh: Mesh): void;
  113191. /**
  113192. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  113193. * @param mesh The mesh to remove
  113194. */
  113195. removeIncludedOnlyMesh(mesh: Mesh): void;
  113196. /**
  113197. * Determine if a given mesh will be used in the glow layer
  113198. * @param mesh The mesh to test
  113199. * @returns true if the mesh will be highlighted by the current glow layer
  113200. */
  113201. hasMesh(mesh: AbstractMesh): boolean;
  113202. /**
  113203. * Free any resources and references associated to a mesh.
  113204. * Internal use
  113205. * @param mesh The mesh to free.
  113206. * @hidden
  113207. */
  113208. _disposeMesh(mesh: Mesh): void;
  113209. /**
  113210. * Gets the class name of the effect layer
  113211. * @returns the string with the class name of the effect layer
  113212. */
  113213. getClassName(): string;
  113214. /**
  113215. * Serializes this glow layer
  113216. * @returns a serialized glow layer object
  113217. */
  113218. serialize(): any;
  113219. /**
  113220. * Creates a Glow Layer from parsed glow layer data
  113221. * @param parsedGlowLayer defines glow layer data
  113222. * @param scene defines the current scene
  113223. * @param rootUrl defines the root URL containing the glow layer information
  113224. * @returns a parsed Glow Layer
  113225. */
  113226. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  113227. }
  113228. }
  113229. declare module BABYLON {
  113230. /** @hidden */
  113231. export var glowBlurPostProcessPixelShader: {
  113232. name: string;
  113233. shader: string;
  113234. };
  113235. }
  113236. declare module BABYLON {
  113237. interface AbstractScene {
  113238. /**
  113239. * Return a the first highlight layer of the scene with a given name.
  113240. * @param name The name of the highlight layer to look for.
  113241. * @return The highlight layer if found otherwise null.
  113242. */
  113243. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  113244. }
  113245. /**
  113246. * Highlight layer options. This helps customizing the behaviour
  113247. * of the highlight layer.
  113248. */
  113249. export interface IHighlightLayerOptions {
  113250. /**
  113251. * Multiplication factor apply to the canvas size to compute the render target size
  113252. * used to generated the glowing objects (the smaller the faster).
  113253. */
  113254. mainTextureRatio: number;
  113255. /**
  113256. * Enforces a fixed size texture to ensure resize independant blur.
  113257. */
  113258. mainTextureFixedSize?: number;
  113259. /**
  113260. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  113261. * of the picture to blur (the smaller the faster).
  113262. */
  113263. blurTextureSizeRatio: number;
  113264. /**
  113265. * How big in texel of the blur texture is the vertical blur.
  113266. */
  113267. blurVerticalSize: number;
  113268. /**
  113269. * How big in texel of the blur texture is the horizontal blur.
  113270. */
  113271. blurHorizontalSize: number;
  113272. /**
  113273. * Alpha blending mode used to apply the blur. Default is combine.
  113274. */
  113275. alphaBlendingMode: number;
  113276. /**
  113277. * The camera attached to the layer.
  113278. */
  113279. camera: Nullable<Camera>;
  113280. /**
  113281. * Should we display highlight as a solid stroke?
  113282. */
  113283. isStroke?: boolean;
  113284. /**
  113285. * The rendering group to draw the layer in.
  113286. */
  113287. renderingGroupId: number;
  113288. }
  113289. /**
  113290. * The highlight layer Helps adding a glow effect around a mesh.
  113291. *
  113292. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113293. * glowy meshes to your scene.
  113294. *
  113295. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  113296. */
  113297. export class HighlightLayer extends EffectLayer {
  113298. name: string;
  113299. /**
  113300. * Effect Name of the highlight layer.
  113301. */
  113302. static readonly EffectName: string;
  113303. /**
  113304. * The neutral color used during the preparation of the glow effect.
  113305. * This is black by default as the blend operation is a blend operation.
  113306. */
  113307. static NeutralColor: Color4;
  113308. /**
  113309. * Stencil value used for glowing meshes.
  113310. */
  113311. static GlowingMeshStencilReference: number;
  113312. /**
  113313. * Stencil value used for the other meshes in the scene.
  113314. */
  113315. static NormalMeshStencilReference: number;
  113316. /**
  113317. * Specifies whether or not the inner glow is ACTIVE in the layer.
  113318. */
  113319. innerGlow: boolean;
  113320. /**
  113321. * Specifies whether or not the outer glow is ACTIVE in the layer.
  113322. */
  113323. outerGlow: boolean;
  113324. /**
  113325. * Specifies the horizontal size of the blur.
  113326. */
  113327. /**
  113328. * Gets the horizontal size of the blur.
  113329. */
  113330. blurHorizontalSize: number;
  113331. /**
  113332. * Specifies the vertical size of the blur.
  113333. */
  113334. /**
  113335. * Gets the vertical size of the blur.
  113336. */
  113337. blurVerticalSize: number;
  113338. /**
  113339. * An event triggered when the highlight layer is being blurred.
  113340. */
  113341. onBeforeBlurObservable: Observable<HighlightLayer>;
  113342. /**
  113343. * An event triggered when the highlight layer has been blurred.
  113344. */
  113345. onAfterBlurObservable: Observable<HighlightLayer>;
  113346. private _instanceGlowingMeshStencilReference;
  113347. private _options;
  113348. private _downSamplePostprocess;
  113349. private _horizontalBlurPostprocess;
  113350. private _verticalBlurPostprocess;
  113351. private _blurTexture;
  113352. private _meshes;
  113353. private _excludedMeshes;
  113354. /**
  113355. * Instantiates a new highlight Layer and references it to the scene..
  113356. * @param name The name of the layer
  113357. * @param scene The scene to use the layer in
  113358. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  113359. */
  113360. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  113361. /**
  113362. * Get the effect name of the layer.
  113363. * @return The effect name
  113364. */
  113365. getEffectName(): string;
  113366. /**
  113367. * Create the merge effect. This is the shader use to blit the information back
  113368. * to the main canvas at the end of the scene rendering.
  113369. */
  113370. protected _createMergeEffect(): Effect;
  113371. /**
  113372. * Creates the render target textures and post processes used in the highlight layer.
  113373. */
  113374. protected _createTextureAndPostProcesses(): void;
  113375. /**
  113376. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113377. */
  113378. needStencil(): boolean;
  113379. /**
  113380. * Checks for the readiness of the element composing the layer.
  113381. * @param subMesh the mesh to check for
  113382. * @param useInstances specify wether or not to use instances to render the mesh
  113383. * @param emissiveTexture the associated emissive texture used to generate the glow
  113384. * @return true if ready otherwise, false
  113385. */
  113386. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113387. /**
  113388. * Implementation specific of rendering the generating effect on the main canvas.
  113389. * @param effect The effect used to render through
  113390. */
  113391. protected _internalRender(effect: Effect): void;
  113392. /**
  113393. * Returns true if the layer contains information to display, otherwise false.
  113394. */
  113395. shouldRender(): boolean;
  113396. /**
  113397. * Returns true if the mesh should render, otherwise false.
  113398. * @param mesh The mesh to render
  113399. * @returns true if it should render otherwise false
  113400. */
  113401. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113402. /**
  113403. * Sets the required values for both the emissive texture and and the main color.
  113404. */
  113405. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113406. /**
  113407. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  113408. * @param mesh The mesh to exclude from the highlight layer
  113409. */
  113410. addExcludedMesh(mesh: Mesh): void;
  113411. /**
  113412. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  113413. * @param mesh The mesh to highlight
  113414. */
  113415. removeExcludedMesh(mesh: Mesh): void;
  113416. /**
  113417. * Determine if a given mesh will be highlighted by the current HighlightLayer
  113418. * @param mesh mesh to test
  113419. * @returns true if the mesh will be highlighted by the current HighlightLayer
  113420. */
  113421. hasMesh(mesh: AbstractMesh): boolean;
  113422. /**
  113423. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  113424. * @param mesh The mesh to highlight
  113425. * @param color The color of the highlight
  113426. * @param glowEmissiveOnly Extract the glow from the emissive texture
  113427. */
  113428. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  113429. /**
  113430. * Remove a mesh from the highlight layer in order to make it stop glowing.
  113431. * @param mesh The mesh to highlight
  113432. */
  113433. removeMesh(mesh: Mesh): void;
  113434. /**
  113435. * Force the stencil to the normal expected value for none glowing parts
  113436. */
  113437. private _defaultStencilReference;
  113438. /**
  113439. * Free any resources and references associated to a mesh.
  113440. * Internal use
  113441. * @param mesh The mesh to free.
  113442. * @hidden
  113443. */
  113444. _disposeMesh(mesh: Mesh): void;
  113445. /**
  113446. * Dispose the highlight layer and free resources.
  113447. */
  113448. dispose(): void;
  113449. /**
  113450. * Gets the class name of the effect layer
  113451. * @returns the string with the class name of the effect layer
  113452. */
  113453. getClassName(): string;
  113454. /**
  113455. * Serializes this Highlight layer
  113456. * @returns a serialized Highlight layer object
  113457. */
  113458. serialize(): any;
  113459. /**
  113460. * Creates a Highlight layer from parsed Highlight layer data
  113461. * @param parsedHightlightLayer defines the Highlight layer data
  113462. * @param scene defines the current scene
  113463. * @param rootUrl defines the root URL containing the Highlight layer information
  113464. * @returns a parsed Highlight layer
  113465. */
  113466. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  113467. }
  113468. }
  113469. declare module BABYLON {
  113470. interface AbstractScene {
  113471. /**
  113472. * The list of layers (background and foreground) of the scene
  113473. */
  113474. layers: Array<Layer>;
  113475. }
  113476. /**
  113477. * Defines the layer scene component responsible to manage any layers
  113478. * in a given scene.
  113479. */
  113480. export class LayerSceneComponent implements ISceneComponent {
  113481. /**
  113482. * The component name helpfull to identify the component in the list of scene components.
  113483. */
  113484. readonly name: string;
  113485. /**
  113486. * The scene the component belongs to.
  113487. */
  113488. scene: Scene;
  113489. private _engine;
  113490. /**
  113491. * Creates a new instance of the component for the given scene
  113492. * @param scene Defines the scene to register the component in
  113493. */
  113494. constructor(scene: Scene);
  113495. /**
  113496. * Registers the component in a given scene
  113497. */
  113498. register(): void;
  113499. /**
  113500. * Rebuilds the elements related to this component in case of
  113501. * context lost for instance.
  113502. */
  113503. rebuild(): void;
  113504. /**
  113505. * Disposes the component and the associated ressources.
  113506. */
  113507. dispose(): void;
  113508. private _draw;
  113509. private _drawCameraPredicate;
  113510. private _drawCameraBackground;
  113511. private _drawCameraForeground;
  113512. private _drawRenderTargetPredicate;
  113513. private _drawRenderTargetBackground;
  113514. private _drawRenderTargetForeground;
  113515. /**
  113516. * Adds all the elements from the container to the scene
  113517. * @param container the container holding the elements
  113518. */
  113519. addFromContainer(container: AbstractScene): void;
  113520. /**
  113521. * Removes all the elements in the container from the scene
  113522. * @param container contains the elements to remove
  113523. * @param dispose if the removed element should be disposed (default: false)
  113524. */
  113525. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113526. }
  113527. }
  113528. declare module BABYLON {
  113529. /** @hidden */
  113530. export var layerPixelShader: {
  113531. name: string;
  113532. shader: string;
  113533. };
  113534. }
  113535. declare module BABYLON {
  113536. /** @hidden */
  113537. export var layerVertexShader: {
  113538. name: string;
  113539. shader: string;
  113540. };
  113541. }
  113542. declare module BABYLON {
  113543. /**
  113544. * This represents a full screen 2d layer.
  113545. * This can be useful to display a picture in the background of your scene for instance.
  113546. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113547. */
  113548. export class Layer {
  113549. /**
  113550. * Define the name of the layer.
  113551. */
  113552. name: string;
  113553. /**
  113554. * Define the texture the layer should display.
  113555. */
  113556. texture: Nullable<Texture>;
  113557. /**
  113558. * Is the layer in background or foreground.
  113559. */
  113560. isBackground: boolean;
  113561. /**
  113562. * Define the color of the layer (instead of texture).
  113563. */
  113564. color: Color4;
  113565. /**
  113566. * Define the scale of the layer in order to zoom in out of the texture.
  113567. */
  113568. scale: Vector2;
  113569. /**
  113570. * Define an offset for the layer in order to shift the texture.
  113571. */
  113572. offset: Vector2;
  113573. /**
  113574. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  113575. */
  113576. alphaBlendingMode: number;
  113577. /**
  113578. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  113579. * Alpha test will not mix with the background color in case of transparency.
  113580. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  113581. */
  113582. alphaTest: boolean;
  113583. /**
  113584. * Define a mask to restrict the layer to only some of the scene cameras.
  113585. */
  113586. layerMask: number;
  113587. /**
  113588. * Define the list of render target the layer is visible into.
  113589. */
  113590. renderTargetTextures: RenderTargetTexture[];
  113591. /**
  113592. * Define if the layer is only used in renderTarget or if it also
  113593. * renders in the main frame buffer of the canvas.
  113594. */
  113595. renderOnlyInRenderTargetTextures: boolean;
  113596. private _scene;
  113597. private _vertexBuffers;
  113598. private _indexBuffer;
  113599. private _effect;
  113600. private _alphaTestEffect;
  113601. /**
  113602. * An event triggered when the layer is disposed.
  113603. */
  113604. onDisposeObservable: Observable<Layer>;
  113605. private _onDisposeObserver;
  113606. /**
  113607. * Back compatibility with callback before the onDisposeObservable existed.
  113608. * The set callback will be triggered when the layer has been disposed.
  113609. */
  113610. onDispose: () => void;
  113611. /**
  113612. * An event triggered before rendering the scene
  113613. */
  113614. onBeforeRenderObservable: Observable<Layer>;
  113615. private _onBeforeRenderObserver;
  113616. /**
  113617. * Back compatibility with callback before the onBeforeRenderObservable existed.
  113618. * The set callback will be triggered just before rendering the layer.
  113619. */
  113620. onBeforeRender: () => void;
  113621. /**
  113622. * An event triggered after rendering the scene
  113623. */
  113624. onAfterRenderObservable: Observable<Layer>;
  113625. private _onAfterRenderObserver;
  113626. /**
  113627. * Back compatibility with callback before the onAfterRenderObservable existed.
  113628. * The set callback will be triggered just after rendering the layer.
  113629. */
  113630. onAfterRender: () => void;
  113631. /**
  113632. * Instantiates a new layer.
  113633. * This represents a full screen 2d layer.
  113634. * This can be useful to display a picture in the background of your scene for instance.
  113635. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113636. * @param name Define the name of the layer in the scene
  113637. * @param imgUrl Define the url of the texture to display in the layer
  113638. * @param scene Define the scene the layer belongs to
  113639. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  113640. * @param color Defines a color for the layer
  113641. */
  113642. constructor(
  113643. /**
  113644. * Define the name of the layer.
  113645. */
  113646. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  113647. private _createIndexBuffer;
  113648. /** @hidden */
  113649. _rebuild(): void;
  113650. /**
  113651. * Renders the layer in the scene.
  113652. */
  113653. render(): void;
  113654. /**
  113655. * Disposes and releases the associated ressources.
  113656. */
  113657. dispose(): void;
  113658. }
  113659. }
  113660. declare module BABYLON {
  113661. /** @hidden */
  113662. export var lensFlarePixelShader: {
  113663. name: string;
  113664. shader: string;
  113665. };
  113666. }
  113667. declare module BABYLON {
  113668. /** @hidden */
  113669. export var lensFlareVertexShader: {
  113670. name: string;
  113671. shader: string;
  113672. };
  113673. }
  113674. declare module BABYLON {
  113675. /**
  113676. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  113677. * It is usually composed of several `lensFlare`.
  113678. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113679. */
  113680. export class LensFlareSystem {
  113681. /**
  113682. * Define the name of the lens flare system
  113683. */
  113684. name: string;
  113685. /**
  113686. * List of lens flares used in this system.
  113687. */
  113688. lensFlares: LensFlare[];
  113689. /**
  113690. * Define a limit from the border the lens flare can be visible.
  113691. */
  113692. borderLimit: number;
  113693. /**
  113694. * Define a viewport border we do not want to see the lens flare in.
  113695. */
  113696. viewportBorder: number;
  113697. /**
  113698. * Define a predicate which could limit the list of meshes able to occlude the effect.
  113699. */
  113700. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  113701. /**
  113702. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  113703. */
  113704. layerMask: number;
  113705. /**
  113706. * Define the id of the lens flare system in the scene.
  113707. * (equal to name by default)
  113708. */
  113709. id: string;
  113710. private _scene;
  113711. private _emitter;
  113712. private _vertexBuffers;
  113713. private _indexBuffer;
  113714. private _effect;
  113715. private _positionX;
  113716. private _positionY;
  113717. private _isEnabled;
  113718. /** @hidden */
  113719. static _SceneComponentInitialization: (scene: Scene) => void;
  113720. /**
  113721. * Instantiates a lens flare system.
  113722. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  113723. * It is usually composed of several `lensFlare`.
  113724. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113725. * @param name Define the name of the lens flare system in the scene
  113726. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  113727. * @param scene Define the scene the lens flare system belongs to
  113728. */
  113729. constructor(
  113730. /**
  113731. * Define the name of the lens flare system
  113732. */
  113733. name: string, emitter: any, scene: Scene);
  113734. /**
  113735. * Define if the lens flare system is enabled.
  113736. */
  113737. isEnabled: boolean;
  113738. /**
  113739. * Get the scene the effects belongs to.
  113740. * @returns the scene holding the lens flare system
  113741. */
  113742. getScene(): Scene;
  113743. /**
  113744. * Get the emitter of the lens flare system.
  113745. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113746. * @returns the emitter of the lens flare system
  113747. */
  113748. getEmitter(): any;
  113749. /**
  113750. * Set the emitter of the lens flare system.
  113751. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113752. * @param newEmitter Define the new emitter of the system
  113753. */
  113754. setEmitter(newEmitter: any): void;
  113755. /**
  113756. * Get the lens flare system emitter position.
  113757. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  113758. * @returns the position
  113759. */
  113760. getEmitterPosition(): Vector3;
  113761. /**
  113762. * @hidden
  113763. */
  113764. computeEffectivePosition(globalViewport: Viewport): boolean;
  113765. /** @hidden */
  113766. _isVisible(): boolean;
  113767. /**
  113768. * @hidden
  113769. */
  113770. render(): boolean;
  113771. /**
  113772. * Dispose and release the lens flare with its associated resources.
  113773. */
  113774. dispose(): void;
  113775. /**
  113776. * Parse a lens flare system from a JSON repressentation
  113777. * @param parsedLensFlareSystem Define the JSON to parse
  113778. * @param scene Define the scene the parsed system should be instantiated in
  113779. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  113780. * @returns the parsed system
  113781. */
  113782. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  113783. /**
  113784. * Serialize the current Lens Flare System into a JSON representation.
  113785. * @returns the serialized JSON
  113786. */
  113787. serialize(): any;
  113788. }
  113789. }
  113790. declare module BABYLON {
  113791. /**
  113792. * This represents one of the lens effect in a `lensFlareSystem`.
  113793. * It controls one of the indiviual texture used in the effect.
  113794. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113795. */
  113796. export class LensFlare {
  113797. /**
  113798. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113799. */
  113800. size: number;
  113801. /**
  113802. * 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.
  113803. */
  113804. position: number;
  113805. /**
  113806. * Define the lens color.
  113807. */
  113808. color: Color3;
  113809. /**
  113810. * Define the lens texture.
  113811. */
  113812. texture: Nullable<Texture>;
  113813. /**
  113814. * Define the alpha mode to render this particular lens.
  113815. */
  113816. alphaMode: number;
  113817. private _system;
  113818. /**
  113819. * Creates a new Lens Flare.
  113820. * This represents one of the lens effect in a `lensFlareSystem`.
  113821. * It controls one of the indiviual texture used in the effect.
  113822. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113823. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  113824. * @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.
  113825. * @param color Define the lens color
  113826. * @param imgUrl Define the lens texture url
  113827. * @param system Define the `lensFlareSystem` this flare is part of
  113828. * @returns The newly created Lens Flare
  113829. */
  113830. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  113831. /**
  113832. * Instantiates a new Lens Flare.
  113833. * This represents one of the lens effect in a `lensFlareSystem`.
  113834. * It controls one of the indiviual texture used in the effect.
  113835. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113836. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  113837. * @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.
  113838. * @param color Define the lens color
  113839. * @param imgUrl Define the lens texture url
  113840. * @param system Define the `lensFlareSystem` this flare is part of
  113841. */
  113842. constructor(
  113843. /**
  113844. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113845. */
  113846. size: number,
  113847. /**
  113848. * 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.
  113849. */
  113850. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  113851. /**
  113852. * Dispose and release the lens flare with its associated resources.
  113853. */
  113854. dispose(): void;
  113855. }
  113856. }
  113857. declare module BABYLON {
  113858. interface AbstractScene {
  113859. /**
  113860. * The list of lens flare system added to the scene
  113861. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113862. */
  113863. lensFlareSystems: Array<LensFlareSystem>;
  113864. /**
  113865. * Removes the given lens flare system from this scene.
  113866. * @param toRemove The lens flare system to remove
  113867. * @returns The index of the removed lens flare system
  113868. */
  113869. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  113870. /**
  113871. * Adds the given lens flare system to this scene
  113872. * @param newLensFlareSystem The lens flare system to add
  113873. */
  113874. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  113875. /**
  113876. * Gets a lens flare system using its name
  113877. * @param name defines the name to look for
  113878. * @returns the lens flare system or null if not found
  113879. */
  113880. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  113881. /**
  113882. * Gets a lens flare system using its id
  113883. * @param id defines the id to look for
  113884. * @returns the lens flare system or null if not found
  113885. */
  113886. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  113887. }
  113888. /**
  113889. * Defines the lens flare scene component responsible to manage any lens flares
  113890. * in a given scene.
  113891. */
  113892. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  113893. /**
  113894. * The component name helpfull to identify the component in the list of scene components.
  113895. */
  113896. readonly name: string;
  113897. /**
  113898. * The scene the component belongs to.
  113899. */
  113900. scene: Scene;
  113901. /**
  113902. * Creates a new instance of the component for the given scene
  113903. * @param scene Defines the scene to register the component in
  113904. */
  113905. constructor(scene: Scene);
  113906. /**
  113907. * Registers the component in a given scene
  113908. */
  113909. register(): void;
  113910. /**
  113911. * Rebuilds the elements related to this component in case of
  113912. * context lost for instance.
  113913. */
  113914. rebuild(): void;
  113915. /**
  113916. * Adds all the elements from the container to the scene
  113917. * @param container the container holding the elements
  113918. */
  113919. addFromContainer(container: AbstractScene): void;
  113920. /**
  113921. * Removes all the elements in the container from the scene
  113922. * @param container contains the elements to remove
  113923. * @param dispose if the removed element should be disposed (default: false)
  113924. */
  113925. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113926. /**
  113927. * Serializes the component data to the specified json object
  113928. * @param serializationObject The object to serialize to
  113929. */
  113930. serialize(serializationObject: any): void;
  113931. /**
  113932. * Disposes the component and the associated ressources.
  113933. */
  113934. dispose(): void;
  113935. private _draw;
  113936. }
  113937. }
  113938. declare module BABYLON {
  113939. /**
  113940. * Defines the shadow generator component responsible to manage any shadow generators
  113941. * in a given scene.
  113942. */
  113943. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  113944. /**
  113945. * The component name helpfull to identify the component in the list of scene components.
  113946. */
  113947. readonly name: string;
  113948. /**
  113949. * The scene the component belongs to.
  113950. */
  113951. scene: Scene;
  113952. /**
  113953. * Creates a new instance of the component for the given scene
  113954. * @param scene Defines the scene to register the component in
  113955. */
  113956. constructor(scene: Scene);
  113957. /**
  113958. * Registers the component in a given scene
  113959. */
  113960. register(): void;
  113961. /**
  113962. * Rebuilds the elements related to this component in case of
  113963. * context lost for instance.
  113964. */
  113965. rebuild(): void;
  113966. /**
  113967. * Serializes the component data to the specified json object
  113968. * @param serializationObject The object to serialize to
  113969. */
  113970. serialize(serializationObject: any): void;
  113971. /**
  113972. * Adds all the elements from the container to the scene
  113973. * @param container the container holding the elements
  113974. */
  113975. addFromContainer(container: AbstractScene): void;
  113976. /**
  113977. * Removes all the elements in the container from the scene
  113978. * @param container contains the elements to remove
  113979. * @param dispose if the removed element should be disposed (default: false)
  113980. */
  113981. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113982. /**
  113983. * Rebuilds the elements related to this component in case of
  113984. * context lost for instance.
  113985. */
  113986. dispose(): void;
  113987. private _gatherRenderTargets;
  113988. }
  113989. }
  113990. declare module BABYLON {
  113991. /**
  113992. * A point light is a light defined by an unique point in world space.
  113993. * The light is emitted in every direction from this point.
  113994. * A good example of a point light is a standard light bulb.
  113995. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113996. */
  113997. export class PointLight extends ShadowLight {
  113998. private _shadowAngle;
  113999. /**
  114000. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114001. * This specifies what angle the shadow will use to be created.
  114002. *
  114003. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114004. */
  114005. /**
  114006. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114007. * This specifies what angle the shadow will use to be created.
  114008. *
  114009. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114010. */
  114011. shadowAngle: number;
  114012. /**
  114013. * Gets the direction if it has been set.
  114014. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114015. */
  114016. /**
  114017. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114018. */
  114019. direction: Vector3;
  114020. /**
  114021. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  114022. * A PointLight emits the light in every direction.
  114023. * It can cast shadows.
  114024. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  114025. * ```javascript
  114026. * var pointLight = new PointLight("pl", camera.position, scene);
  114027. * ```
  114028. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114029. * @param name The light friendly name
  114030. * @param position The position of the point light in the scene
  114031. * @param scene The scene the lights belongs to
  114032. */
  114033. constructor(name: string, position: Vector3, scene: Scene);
  114034. /**
  114035. * Returns the string "PointLight"
  114036. * @returns the class name
  114037. */
  114038. getClassName(): string;
  114039. /**
  114040. * Returns the integer 0.
  114041. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114042. */
  114043. getTypeID(): number;
  114044. /**
  114045. * Specifies wether or not the shadowmap should be a cube texture.
  114046. * @returns true if the shadowmap needs to be a cube texture.
  114047. */
  114048. needCube(): boolean;
  114049. /**
  114050. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  114051. * @param faceIndex The index of the face we are computed the direction to generate shadow
  114052. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  114053. */
  114054. getShadowDirection(faceIndex?: number): Vector3;
  114055. /**
  114056. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  114057. * - fov = PI / 2
  114058. * - aspect ratio : 1.0
  114059. * - z-near and far equal to the active camera minZ and maxZ.
  114060. * Returns the PointLight.
  114061. */
  114062. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114063. protected _buildUniformLayout(): void;
  114064. /**
  114065. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  114066. * @param effect The effect to update
  114067. * @param lightIndex The index of the light in the effect to update
  114068. * @returns The point light
  114069. */
  114070. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  114071. /**
  114072. * Prepares the list of defines specific to the light type.
  114073. * @param defines the list of defines
  114074. * @param lightIndex defines the index of the light for the effect
  114075. */
  114076. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114077. }
  114078. }
  114079. declare module BABYLON {
  114080. /**
  114081. * Header information of HDR texture files.
  114082. */
  114083. export interface HDRInfo {
  114084. /**
  114085. * The height of the texture in pixels.
  114086. */
  114087. height: number;
  114088. /**
  114089. * The width of the texture in pixels.
  114090. */
  114091. width: number;
  114092. /**
  114093. * The index of the beginning of the data in the binary file.
  114094. */
  114095. dataPosition: number;
  114096. }
  114097. /**
  114098. * This groups tools to convert HDR texture to native colors array.
  114099. */
  114100. export class HDRTools {
  114101. private static Ldexp;
  114102. private static Rgbe2float;
  114103. private static readStringLine;
  114104. /**
  114105. * Reads header information from an RGBE texture stored in a native array.
  114106. * More information on this format are available here:
  114107. * https://en.wikipedia.org/wiki/RGBE_image_format
  114108. *
  114109. * @param uint8array The binary file stored in native array.
  114110. * @return The header information.
  114111. */
  114112. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  114113. /**
  114114. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  114115. * This RGBE texture needs to store the information as a panorama.
  114116. *
  114117. * More information on this format are available here:
  114118. * https://en.wikipedia.org/wiki/RGBE_image_format
  114119. *
  114120. * @param buffer The binary file stored in an array buffer.
  114121. * @param size The expected size of the extracted cubemap.
  114122. * @return The Cube Map information.
  114123. */
  114124. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  114125. /**
  114126. * Returns the pixels data extracted from an RGBE texture.
  114127. * This pixels will be stored left to right up to down in the R G B order in one array.
  114128. *
  114129. * More information on this format are available here:
  114130. * https://en.wikipedia.org/wiki/RGBE_image_format
  114131. *
  114132. * @param uint8array The binary file stored in an array buffer.
  114133. * @param hdrInfo The header information of the file.
  114134. * @return The pixels data in RGB right to left up to down order.
  114135. */
  114136. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  114137. private static RGBE_ReadPixels_RLE;
  114138. }
  114139. }
  114140. declare module BABYLON {
  114141. /**
  114142. * This represents a texture coming from an HDR input.
  114143. *
  114144. * The only supported format is currently panorama picture stored in RGBE format.
  114145. * Example of such files can be found on HDRLib: http://hdrlib.com/
  114146. */
  114147. export class HDRCubeTexture extends BaseTexture {
  114148. private static _facesMapping;
  114149. private _generateHarmonics;
  114150. private _noMipmap;
  114151. private _textureMatrix;
  114152. private _size;
  114153. private _onLoad;
  114154. private _onError;
  114155. /**
  114156. * The texture URL.
  114157. */
  114158. url: string;
  114159. /**
  114160. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  114161. */
  114162. coordinatesMode: number;
  114163. protected _isBlocking: boolean;
  114164. /**
  114165. * Sets wether or not the texture is blocking during loading.
  114166. */
  114167. /**
  114168. * Gets wether or not the texture is blocking during loading.
  114169. */
  114170. isBlocking: boolean;
  114171. protected _rotationY: number;
  114172. /**
  114173. * Sets texture matrix rotation angle around Y axis in radians.
  114174. */
  114175. /**
  114176. * Gets texture matrix rotation angle around Y axis radians.
  114177. */
  114178. rotationY: number;
  114179. /**
  114180. * Gets or sets the center of the bounding box associated with the cube texture
  114181. * It must define where the camera used to render the texture was set
  114182. */
  114183. boundingBoxPosition: Vector3;
  114184. private _boundingBoxSize;
  114185. /**
  114186. * Gets or sets the size of the bounding box associated with the cube texture
  114187. * When defined, the cubemap will switch to local mode
  114188. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  114189. * @example https://www.babylonjs-playground.com/#RNASML
  114190. */
  114191. boundingBoxSize: Vector3;
  114192. /**
  114193. * Instantiates an HDRTexture from the following parameters.
  114194. *
  114195. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  114196. * @param scene The scene the texture will be used in
  114197. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114198. * @param noMipmap Forces to not generate the mipmap if true
  114199. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  114200. * @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)
  114201. * @param reserved Reserved flag for internal use.
  114202. */
  114203. 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>);
  114204. /**
  114205. * Get the current class name of the texture useful for serialization or dynamic coding.
  114206. * @returns "HDRCubeTexture"
  114207. */
  114208. getClassName(): string;
  114209. /**
  114210. * Occurs when the file is raw .hdr file.
  114211. */
  114212. private loadTexture;
  114213. clone(): HDRCubeTexture;
  114214. delayLoad(): void;
  114215. /**
  114216. * Get the texture reflection matrix used to rotate/transform the reflection.
  114217. * @returns the reflection matrix
  114218. */
  114219. getReflectionTextureMatrix(): Matrix;
  114220. /**
  114221. * Set the texture reflection matrix used to rotate/transform the reflection.
  114222. * @param value Define the reflection matrix to set
  114223. */
  114224. setReflectionTextureMatrix(value: Matrix): void;
  114225. /**
  114226. * Parses a JSON representation of an HDR Texture in order to create the texture
  114227. * @param parsedTexture Define the JSON representation
  114228. * @param scene Define the scene the texture should be created in
  114229. * @param rootUrl Define the root url in case we need to load relative dependencies
  114230. * @returns the newly created texture after parsing
  114231. */
  114232. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  114233. serialize(): any;
  114234. }
  114235. }
  114236. declare module BABYLON {
  114237. /**
  114238. * Class used to control physics engine
  114239. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  114240. */
  114241. export class PhysicsEngine implements IPhysicsEngine {
  114242. private _physicsPlugin;
  114243. /**
  114244. * Global value used to control the smallest number supported by the simulation
  114245. */
  114246. static Epsilon: number;
  114247. private _impostors;
  114248. private _joints;
  114249. /**
  114250. * Gets the gravity vector used by the simulation
  114251. */
  114252. gravity: Vector3;
  114253. /**
  114254. * Factory used to create the default physics plugin.
  114255. * @returns The default physics plugin
  114256. */
  114257. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  114258. /**
  114259. * Creates a new Physics Engine
  114260. * @param gravity defines the gravity vector used by the simulation
  114261. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  114262. */
  114263. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  114264. /**
  114265. * Sets the gravity vector used by the simulation
  114266. * @param gravity defines the gravity vector to use
  114267. */
  114268. setGravity(gravity: Vector3): void;
  114269. /**
  114270. * Set the time step of the physics engine.
  114271. * Default is 1/60.
  114272. * To slow it down, enter 1/600 for example.
  114273. * To speed it up, 1/30
  114274. * @param newTimeStep defines the new timestep to apply to this world.
  114275. */
  114276. setTimeStep(newTimeStep?: number): void;
  114277. /**
  114278. * Get the time step of the physics engine.
  114279. * @returns the current time step
  114280. */
  114281. getTimeStep(): number;
  114282. /**
  114283. * Release all resources
  114284. */
  114285. dispose(): void;
  114286. /**
  114287. * Gets the name of the current physics plugin
  114288. * @returns the name of the plugin
  114289. */
  114290. getPhysicsPluginName(): string;
  114291. /**
  114292. * Adding a new impostor for the impostor tracking.
  114293. * This will be done by the impostor itself.
  114294. * @param impostor the impostor to add
  114295. */
  114296. addImpostor(impostor: PhysicsImpostor): void;
  114297. /**
  114298. * Remove an impostor from the engine.
  114299. * This impostor and its mesh will not longer be updated by the physics engine.
  114300. * @param impostor the impostor to remove
  114301. */
  114302. removeImpostor(impostor: PhysicsImpostor): void;
  114303. /**
  114304. * Add a joint to the physics engine
  114305. * @param mainImpostor defines the main impostor to which the joint is added.
  114306. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  114307. * @param joint defines the joint that will connect both impostors.
  114308. */
  114309. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114310. /**
  114311. * Removes a joint from the simulation
  114312. * @param mainImpostor defines the impostor used with the joint
  114313. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  114314. * @param joint defines the joint to remove
  114315. */
  114316. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114317. /**
  114318. * Called by the scene. No need to call it.
  114319. * @param delta defines the timespam between frames
  114320. */
  114321. _step(delta: number): void;
  114322. /**
  114323. * Gets the current plugin used to run the simulation
  114324. * @returns current plugin
  114325. */
  114326. getPhysicsPlugin(): IPhysicsEnginePlugin;
  114327. /**
  114328. * Gets the list of physic impostors
  114329. * @returns an array of PhysicsImpostor
  114330. */
  114331. getImpostors(): Array<PhysicsImpostor>;
  114332. /**
  114333. * Gets the impostor for a physics enabled object
  114334. * @param object defines the object impersonated by the impostor
  114335. * @returns the PhysicsImpostor or null if not found
  114336. */
  114337. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  114338. /**
  114339. * Gets the impostor for a physics body object
  114340. * @param body defines physics body used by the impostor
  114341. * @returns the PhysicsImpostor or null if not found
  114342. */
  114343. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  114344. /**
  114345. * Does a raycast in the physics world
  114346. * @param from when should the ray start?
  114347. * @param to when should the ray end?
  114348. * @returns PhysicsRaycastResult
  114349. */
  114350. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114351. }
  114352. }
  114353. declare module BABYLON {
  114354. /** @hidden */
  114355. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  114356. private _useDeltaForWorldStep;
  114357. world: any;
  114358. name: string;
  114359. private _physicsMaterials;
  114360. private _fixedTimeStep;
  114361. private _cannonRaycastResult;
  114362. private _raycastResult;
  114363. private _physicsBodysToRemoveAfterStep;
  114364. BJSCANNON: any;
  114365. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  114366. setGravity(gravity: Vector3): void;
  114367. setTimeStep(timeStep: number): void;
  114368. getTimeStep(): number;
  114369. executeStep(delta: number): void;
  114370. private _removeMarkedPhysicsBodiesFromWorld;
  114371. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114372. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114373. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114374. private _processChildMeshes;
  114375. removePhysicsBody(impostor: PhysicsImpostor): void;
  114376. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114377. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114378. private _addMaterial;
  114379. private _checkWithEpsilon;
  114380. private _createShape;
  114381. private _createHeightmap;
  114382. private _minus90X;
  114383. private _plus90X;
  114384. private _tmpPosition;
  114385. private _tmpDeltaPosition;
  114386. private _tmpUnityRotation;
  114387. private _updatePhysicsBodyTransformation;
  114388. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114389. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114390. isSupported(): boolean;
  114391. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114392. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114393. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114394. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114395. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114396. getBodyMass(impostor: PhysicsImpostor): number;
  114397. getBodyFriction(impostor: PhysicsImpostor): number;
  114398. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114399. getBodyRestitution(impostor: PhysicsImpostor): number;
  114400. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114401. sleepBody(impostor: PhysicsImpostor): void;
  114402. wakeUpBody(impostor: PhysicsImpostor): void;
  114403. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  114404. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114405. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114406. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114407. getRadius(impostor: PhysicsImpostor): number;
  114408. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114409. dispose(): void;
  114410. private _extendNamespace;
  114411. /**
  114412. * Does a raycast in the physics world
  114413. * @param from when should the ray start?
  114414. * @param to when should the ray end?
  114415. * @returns PhysicsRaycastResult
  114416. */
  114417. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114418. }
  114419. }
  114420. declare module BABYLON {
  114421. /** @hidden */
  114422. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  114423. world: any;
  114424. name: string;
  114425. BJSOIMO: any;
  114426. private _raycastResult;
  114427. constructor(iterations?: number, oimoInjection?: any);
  114428. setGravity(gravity: Vector3): void;
  114429. setTimeStep(timeStep: number): void;
  114430. getTimeStep(): number;
  114431. private _tmpImpostorsArray;
  114432. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114433. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114434. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114435. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114436. private _tmpPositionVector;
  114437. removePhysicsBody(impostor: PhysicsImpostor): void;
  114438. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114439. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114440. isSupported(): boolean;
  114441. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114442. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114443. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114444. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114445. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114446. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114447. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114448. getBodyMass(impostor: PhysicsImpostor): number;
  114449. getBodyFriction(impostor: PhysicsImpostor): number;
  114450. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114451. getBodyRestitution(impostor: PhysicsImpostor): number;
  114452. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114453. sleepBody(impostor: PhysicsImpostor): void;
  114454. wakeUpBody(impostor: PhysicsImpostor): void;
  114455. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114456. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  114457. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  114458. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114459. getRadius(impostor: PhysicsImpostor): number;
  114460. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114461. dispose(): void;
  114462. /**
  114463. * Does a raycast in the physics world
  114464. * @param from when should the ray start?
  114465. * @param to when should the ray end?
  114466. * @returns PhysicsRaycastResult
  114467. */
  114468. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114469. }
  114470. }
  114471. declare module BABYLON {
  114472. /**
  114473. * Class containing static functions to help procedurally build meshes
  114474. */
  114475. export class RibbonBuilder {
  114476. /**
  114477. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114478. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114479. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114480. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114481. * * 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
  114482. * * 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
  114483. * * 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
  114484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114486. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114487. * * 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
  114488. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  114489. * * 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
  114490. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  114491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114492. * @param name defines the name of the mesh
  114493. * @param options defines the options used to create the mesh
  114494. * @param scene defines the hosting scene
  114495. * @returns the ribbon mesh
  114496. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  114497. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114498. */
  114499. static CreateRibbon(name: string, options: {
  114500. pathArray: Vector3[][];
  114501. closeArray?: boolean;
  114502. closePath?: boolean;
  114503. offset?: number;
  114504. updatable?: boolean;
  114505. sideOrientation?: number;
  114506. frontUVs?: Vector4;
  114507. backUVs?: Vector4;
  114508. instance?: Mesh;
  114509. invertUV?: boolean;
  114510. uvs?: Vector2[];
  114511. colors?: Color4[];
  114512. }, scene?: Nullable<Scene>): Mesh;
  114513. }
  114514. }
  114515. declare module BABYLON {
  114516. /**
  114517. * Class containing static functions to help procedurally build meshes
  114518. */
  114519. export class ShapeBuilder {
  114520. /**
  114521. * 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.
  114522. * * 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.
  114523. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114524. * * 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.
  114525. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  114526. * * 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
  114527. * * 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
  114528. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  114529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114531. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  114532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114533. * @param name defines the name of the mesh
  114534. * @param options defines the options used to create the mesh
  114535. * @param scene defines the hosting scene
  114536. * @returns the extruded shape mesh
  114537. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114539. */
  114540. static ExtrudeShape(name: string, options: {
  114541. shape: Vector3[];
  114542. path: Vector3[];
  114543. scale?: number;
  114544. rotation?: number;
  114545. cap?: number;
  114546. updatable?: boolean;
  114547. sideOrientation?: number;
  114548. frontUVs?: Vector4;
  114549. backUVs?: Vector4;
  114550. instance?: Mesh;
  114551. invertUV?: boolean;
  114552. }, scene?: Nullable<Scene>): Mesh;
  114553. /**
  114554. * Creates an custom extruded shape mesh.
  114555. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  114556. * * 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.
  114557. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114558. * * 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
  114559. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  114560. * * 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
  114561. * * It must returns a float value that will be the scale value applied to the shape on each path point
  114562. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114563. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  114564. * * 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
  114565. * * 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
  114566. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  114567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114569. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114571. * @param name defines the name of the mesh
  114572. * @param options defines the options used to create the mesh
  114573. * @param scene defines the hosting scene
  114574. * @returns the custom extruded shape mesh
  114575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  114576. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114577. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114578. */
  114579. static ExtrudeShapeCustom(name: string, options: {
  114580. shape: Vector3[];
  114581. path: Vector3[];
  114582. scaleFunction?: any;
  114583. rotationFunction?: any;
  114584. ribbonCloseArray?: boolean;
  114585. ribbonClosePath?: boolean;
  114586. cap?: number;
  114587. updatable?: boolean;
  114588. sideOrientation?: number;
  114589. frontUVs?: Vector4;
  114590. backUVs?: Vector4;
  114591. instance?: Mesh;
  114592. invertUV?: boolean;
  114593. }, scene?: Nullable<Scene>): Mesh;
  114594. private static _ExtrudeShapeGeneric;
  114595. }
  114596. }
  114597. declare module BABYLON {
  114598. /**
  114599. * AmmoJS Physics plugin
  114600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114601. * @see https://github.com/kripken/ammo.js/
  114602. */
  114603. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  114604. private _useDeltaForWorldStep;
  114605. /**
  114606. * Reference to the Ammo library
  114607. */
  114608. bjsAMMO: any;
  114609. /**
  114610. * Created ammoJS world which physics bodies are added to
  114611. */
  114612. world: any;
  114613. /**
  114614. * Name of the plugin
  114615. */
  114616. name: string;
  114617. private _timeStep;
  114618. private _fixedTimeStep;
  114619. private _maxSteps;
  114620. private _tmpQuaternion;
  114621. private _tmpAmmoTransform;
  114622. private _tmpAmmoQuaternion;
  114623. private _tmpAmmoConcreteContactResultCallback;
  114624. private _collisionConfiguration;
  114625. private _dispatcher;
  114626. private _overlappingPairCache;
  114627. private _solver;
  114628. private _softBodySolver;
  114629. private _tmpAmmoVectorA;
  114630. private _tmpAmmoVectorB;
  114631. private _tmpAmmoVectorC;
  114632. private _tmpAmmoVectorD;
  114633. private _tmpContactCallbackResult;
  114634. private _tmpAmmoVectorRCA;
  114635. private _tmpAmmoVectorRCB;
  114636. private _raycastResult;
  114637. private static readonly DISABLE_COLLISION_FLAG;
  114638. private static readonly KINEMATIC_FLAG;
  114639. private static readonly DISABLE_DEACTIVATION_FLAG;
  114640. /**
  114641. * Initializes the ammoJS plugin
  114642. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  114643. * @param ammoInjection can be used to inject your own ammo reference
  114644. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  114645. */
  114646. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  114647. /**
  114648. * Sets the gravity of the physics world (m/(s^2))
  114649. * @param gravity Gravity to set
  114650. */
  114651. setGravity(gravity: Vector3): void;
  114652. /**
  114653. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  114654. * @param timeStep timestep to use in seconds
  114655. */
  114656. setTimeStep(timeStep: number): void;
  114657. /**
  114658. * 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)
  114659. * @param fixedTimeStep fixedTimeStep to use in seconds
  114660. */
  114661. setFixedTimeStep(fixedTimeStep: number): void;
  114662. /**
  114663. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  114664. * @param maxSteps the maximum number of steps by the physics engine per frame
  114665. */
  114666. setMaxSteps(maxSteps: number): void;
  114667. /**
  114668. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  114669. * @returns the current timestep in seconds
  114670. */
  114671. getTimeStep(): number;
  114672. private _isImpostorInContact;
  114673. private _isImpostorPairInContact;
  114674. private _stepSimulation;
  114675. /**
  114676. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  114677. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  114678. * After the step the babylon meshes are set to the position of the physics imposters
  114679. * @param delta amount of time to step forward
  114680. * @param impostors array of imposters to update before/after the step
  114681. */
  114682. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114683. /**
  114684. * Update babylon mesh to match physics world object
  114685. * @param impostor imposter to match
  114686. */
  114687. private _afterSoftStep;
  114688. /**
  114689. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114690. * @param impostor imposter to match
  114691. */
  114692. private _ropeStep;
  114693. /**
  114694. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114695. * @param impostor imposter to match
  114696. */
  114697. private _softbodyOrClothStep;
  114698. private _tmpVector;
  114699. private _tmpMatrix;
  114700. /**
  114701. * Applies an impulse on the imposter
  114702. * @param impostor imposter to apply impulse to
  114703. * @param force amount of force to be applied to the imposter
  114704. * @param contactPoint the location to apply the impulse on the imposter
  114705. */
  114706. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114707. /**
  114708. * Applies a force on the imposter
  114709. * @param impostor imposter to apply force
  114710. * @param force amount of force to be applied to the imposter
  114711. * @param contactPoint the location to apply the force on the imposter
  114712. */
  114713. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114714. /**
  114715. * Creates a physics body using the plugin
  114716. * @param impostor the imposter to create the physics body on
  114717. */
  114718. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114719. /**
  114720. * Removes the physics body from the imposter and disposes of the body's memory
  114721. * @param impostor imposter to remove the physics body from
  114722. */
  114723. removePhysicsBody(impostor: PhysicsImpostor): void;
  114724. /**
  114725. * Generates a joint
  114726. * @param impostorJoint the imposter joint to create the joint with
  114727. */
  114728. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114729. /**
  114730. * Removes a joint
  114731. * @param impostorJoint the imposter joint to remove the joint from
  114732. */
  114733. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114734. private _addMeshVerts;
  114735. /**
  114736. * Initialise the soft body vertices to match its object's (mesh) vertices
  114737. * Softbody vertices (nodes) are in world space and to match this
  114738. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  114739. * @param impostor to create the softbody for
  114740. */
  114741. private _softVertexData;
  114742. /**
  114743. * Create an impostor's soft body
  114744. * @param impostor to create the softbody for
  114745. */
  114746. private _createSoftbody;
  114747. /**
  114748. * Create cloth for an impostor
  114749. * @param impostor to create the softbody for
  114750. */
  114751. private _createCloth;
  114752. /**
  114753. * Create rope for an impostor
  114754. * @param impostor to create the softbody for
  114755. */
  114756. private _createRope;
  114757. private _addHullVerts;
  114758. private _createShape;
  114759. /**
  114760. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  114761. * @param impostor imposter containing the physics body and babylon object
  114762. */
  114763. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114764. /**
  114765. * Sets the babylon object's position/rotation from the physics body's position/rotation
  114766. * @param impostor imposter containing the physics body and babylon object
  114767. * @param newPosition new position
  114768. * @param newRotation new rotation
  114769. */
  114770. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114771. /**
  114772. * If this plugin is supported
  114773. * @returns true if its supported
  114774. */
  114775. isSupported(): boolean;
  114776. /**
  114777. * Sets the linear velocity of the physics body
  114778. * @param impostor imposter to set the velocity on
  114779. * @param velocity velocity to set
  114780. */
  114781. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114782. /**
  114783. * Sets the angular velocity of the physics body
  114784. * @param impostor imposter to set the velocity on
  114785. * @param velocity velocity to set
  114786. */
  114787. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114788. /**
  114789. * gets the linear velocity
  114790. * @param impostor imposter to get linear velocity from
  114791. * @returns linear velocity
  114792. */
  114793. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114794. /**
  114795. * gets the angular velocity
  114796. * @param impostor imposter to get angular velocity from
  114797. * @returns angular velocity
  114798. */
  114799. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114800. /**
  114801. * Sets the mass of physics body
  114802. * @param impostor imposter to set the mass on
  114803. * @param mass mass to set
  114804. */
  114805. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114806. /**
  114807. * Gets the mass of the physics body
  114808. * @param impostor imposter to get the mass from
  114809. * @returns mass
  114810. */
  114811. getBodyMass(impostor: PhysicsImpostor): number;
  114812. /**
  114813. * Gets friction of the impostor
  114814. * @param impostor impostor to get friction from
  114815. * @returns friction value
  114816. */
  114817. getBodyFriction(impostor: PhysicsImpostor): number;
  114818. /**
  114819. * Sets friction of the impostor
  114820. * @param impostor impostor to set friction on
  114821. * @param friction friction value
  114822. */
  114823. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114824. /**
  114825. * Gets restitution of the impostor
  114826. * @param impostor impostor to get restitution from
  114827. * @returns restitution value
  114828. */
  114829. getBodyRestitution(impostor: PhysicsImpostor): number;
  114830. /**
  114831. * Sets resitution of the impostor
  114832. * @param impostor impostor to set resitution on
  114833. * @param restitution resitution value
  114834. */
  114835. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114836. /**
  114837. * Gets pressure inside the impostor
  114838. * @param impostor impostor to get pressure from
  114839. * @returns pressure value
  114840. */
  114841. getBodyPressure(impostor: PhysicsImpostor): number;
  114842. /**
  114843. * Sets pressure inside a soft body impostor
  114844. * Cloth and rope must remain 0 pressure
  114845. * @param impostor impostor to set pressure on
  114846. * @param pressure pressure value
  114847. */
  114848. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  114849. /**
  114850. * Gets stiffness of the impostor
  114851. * @param impostor impostor to get stiffness from
  114852. * @returns pressure value
  114853. */
  114854. getBodyStiffness(impostor: PhysicsImpostor): number;
  114855. /**
  114856. * Sets stiffness of the impostor
  114857. * @param impostor impostor to set stiffness on
  114858. * @param stiffness stiffness value from 0 to 1
  114859. */
  114860. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  114861. /**
  114862. * Gets velocityIterations of the impostor
  114863. * @param impostor impostor to get velocity iterations from
  114864. * @returns velocityIterations value
  114865. */
  114866. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  114867. /**
  114868. * Sets velocityIterations of the impostor
  114869. * @param impostor impostor to set velocity iterations on
  114870. * @param velocityIterations velocityIterations value
  114871. */
  114872. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  114873. /**
  114874. * Gets positionIterations of the impostor
  114875. * @param impostor impostor to get position iterations from
  114876. * @returns positionIterations value
  114877. */
  114878. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  114879. /**
  114880. * Sets positionIterations of the impostor
  114881. * @param impostor impostor to set position on
  114882. * @param positionIterations positionIterations value
  114883. */
  114884. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  114885. /**
  114886. * Append an anchor to a cloth object
  114887. * @param impostor is the cloth impostor to add anchor to
  114888. * @param otherImpostor is the rigid impostor to anchor to
  114889. * @param width ratio across width from 0 to 1
  114890. * @param height ratio up height from 0 to 1
  114891. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  114892. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114893. */
  114894. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114895. /**
  114896. * Append an hook to a rope object
  114897. * @param impostor is the rope impostor to add hook to
  114898. * @param otherImpostor is the rigid impostor to hook to
  114899. * @param length ratio along the rope from 0 to 1
  114900. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  114901. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114902. */
  114903. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114904. /**
  114905. * Sleeps the physics body and stops it from being active
  114906. * @param impostor impostor to sleep
  114907. */
  114908. sleepBody(impostor: PhysicsImpostor): void;
  114909. /**
  114910. * Activates the physics body
  114911. * @param impostor impostor to activate
  114912. */
  114913. wakeUpBody(impostor: PhysicsImpostor): void;
  114914. /**
  114915. * Updates the distance parameters of the joint
  114916. * @param joint joint to update
  114917. * @param maxDistance maximum distance of the joint
  114918. * @param minDistance minimum distance of the joint
  114919. */
  114920. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114921. /**
  114922. * Sets a motor on the joint
  114923. * @param joint joint to set motor on
  114924. * @param speed speed of the motor
  114925. * @param maxForce maximum force of the motor
  114926. * @param motorIndex index of the motor
  114927. */
  114928. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114929. /**
  114930. * Sets the motors limit
  114931. * @param joint joint to set limit on
  114932. * @param upperLimit upper limit
  114933. * @param lowerLimit lower limit
  114934. */
  114935. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114936. /**
  114937. * Syncs the position and rotation of a mesh with the impostor
  114938. * @param mesh mesh to sync
  114939. * @param impostor impostor to update the mesh with
  114940. */
  114941. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114942. /**
  114943. * Gets the radius of the impostor
  114944. * @param impostor impostor to get radius from
  114945. * @returns the radius
  114946. */
  114947. getRadius(impostor: PhysicsImpostor): number;
  114948. /**
  114949. * Gets the box size of the impostor
  114950. * @param impostor impostor to get box size from
  114951. * @param result the resulting box size
  114952. */
  114953. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114954. /**
  114955. * Disposes of the impostor
  114956. */
  114957. dispose(): void;
  114958. /**
  114959. * Does a raycast in the physics world
  114960. * @param from when should the ray start?
  114961. * @param to when should the ray end?
  114962. * @returns PhysicsRaycastResult
  114963. */
  114964. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114965. }
  114966. }
  114967. declare module BABYLON {
  114968. interface AbstractScene {
  114969. /**
  114970. * The list of reflection probes added to the scene
  114971. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114972. */
  114973. reflectionProbes: Array<ReflectionProbe>;
  114974. /**
  114975. * Removes the given reflection probe from this scene.
  114976. * @param toRemove The reflection probe to remove
  114977. * @returns The index of the removed reflection probe
  114978. */
  114979. removeReflectionProbe(toRemove: ReflectionProbe): number;
  114980. /**
  114981. * Adds the given reflection probe to this scene.
  114982. * @param newReflectionProbe The reflection probe to add
  114983. */
  114984. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  114985. }
  114986. /**
  114987. * Class used to generate realtime reflection / refraction cube textures
  114988. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114989. */
  114990. export class ReflectionProbe {
  114991. /** defines the name of the probe */
  114992. name: string;
  114993. private _scene;
  114994. private _renderTargetTexture;
  114995. private _projectionMatrix;
  114996. private _viewMatrix;
  114997. private _target;
  114998. private _add;
  114999. private _attachedMesh;
  115000. private _invertYAxis;
  115001. /** Gets or sets probe position (center of the cube map) */
  115002. position: Vector3;
  115003. /**
  115004. * Creates a new reflection probe
  115005. * @param name defines the name of the probe
  115006. * @param size defines the texture resolution (for each face)
  115007. * @param scene defines the hosting scene
  115008. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  115009. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  115010. */
  115011. constructor(
  115012. /** defines the name of the probe */
  115013. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  115014. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  115015. samples: number;
  115016. /** Gets or sets the refresh rate to use (on every frame by default) */
  115017. refreshRate: number;
  115018. /**
  115019. * Gets the hosting scene
  115020. * @returns a Scene
  115021. */
  115022. getScene(): Scene;
  115023. /** Gets the internal CubeTexture used to render to */
  115024. readonly cubeTexture: RenderTargetTexture;
  115025. /** Gets the list of meshes to render */
  115026. readonly renderList: Nullable<AbstractMesh[]>;
  115027. /**
  115028. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  115029. * @param mesh defines the mesh to attach to
  115030. */
  115031. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115032. /**
  115033. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  115034. * @param renderingGroupId The rendering group id corresponding to its index
  115035. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  115036. */
  115037. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  115038. /**
  115039. * Clean all associated resources
  115040. */
  115041. dispose(): void;
  115042. /**
  115043. * Converts the reflection probe information to a readable string for debug purpose.
  115044. * @param fullDetails Supports for multiple levels of logging within scene loading
  115045. * @returns the human readable reflection probe info
  115046. */
  115047. toString(fullDetails?: boolean): string;
  115048. /**
  115049. * Get the class name of the relfection probe.
  115050. * @returns "ReflectionProbe"
  115051. */
  115052. getClassName(): string;
  115053. /**
  115054. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  115055. * @returns The JSON representation of the texture
  115056. */
  115057. serialize(): any;
  115058. /**
  115059. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  115060. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  115061. * @param scene Define the scene the parsed reflection probe should be instantiated in
  115062. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  115063. * @returns The parsed reflection probe if successful
  115064. */
  115065. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  115066. }
  115067. }
  115068. declare module BABYLON {
  115069. /** @hidden */
  115070. export var _BabylonLoaderRegistered: boolean;
  115071. }
  115072. declare module BABYLON {
  115073. /**
  115074. * The Physically based simple base material of BJS.
  115075. *
  115076. * This enables better naming and convention enforcements on top of the pbrMaterial.
  115077. * It is used as the base class for both the specGloss and metalRough conventions.
  115078. */
  115079. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  115080. /**
  115081. * Number of Simultaneous lights allowed on the material.
  115082. */
  115083. maxSimultaneousLights: number;
  115084. /**
  115085. * If sets to true, disables all the lights affecting the material.
  115086. */
  115087. disableLighting: boolean;
  115088. /**
  115089. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  115090. */
  115091. environmentTexture: BaseTexture;
  115092. /**
  115093. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115094. */
  115095. invertNormalMapX: boolean;
  115096. /**
  115097. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115098. */
  115099. invertNormalMapY: boolean;
  115100. /**
  115101. * Normal map used in the model.
  115102. */
  115103. normalTexture: BaseTexture;
  115104. /**
  115105. * Emissivie color used to self-illuminate the model.
  115106. */
  115107. emissiveColor: Color3;
  115108. /**
  115109. * Emissivie texture used to self-illuminate the model.
  115110. */
  115111. emissiveTexture: BaseTexture;
  115112. /**
  115113. * Occlusion Channel Strenght.
  115114. */
  115115. occlusionStrength: number;
  115116. /**
  115117. * Occlusion Texture of the material (adding extra occlusion effects).
  115118. */
  115119. occlusionTexture: BaseTexture;
  115120. /**
  115121. * Defines the alpha limits in alpha test mode.
  115122. */
  115123. alphaCutOff: number;
  115124. /**
  115125. * Gets the current double sided mode.
  115126. */
  115127. /**
  115128. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115129. */
  115130. doubleSided: boolean;
  115131. /**
  115132. * Stores the pre-calculated light information of a mesh in a texture.
  115133. */
  115134. lightmapTexture: BaseTexture;
  115135. /**
  115136. * If true, the light map contains occlusion information instead of lighting info.
  115137. */
  115138. useLightmapAsShadowmap: boolean;
  115139. /**
  115140. * Instantiates a new PBRMaterial instance.
  115141. *
  115142. * @param name The material name
  115143. * @param scene The scene the material will be use in.
  115144. */
  115145. constructor(name: string, scene: Scene);
  115146. getClassName(): string;
  115147. }
  115148. }
  115149. declare module BABYLON {
  115150. /**
  115151. * The PBR material of BJS following the metal roughness convention.
  115152. *
  115153. * This fits to the PBR convention in the GLTF definition:
  115154. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  115155. */
  115156. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  115157. /**
  115158. * The base color has two different interpretations depending on the value of metalness.
  115159. * When the material is a metal, the base color is the specific measured reflectance value
  115160. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  115161. * of the material.
  115162. */
  115163. baseColor: Color3;
  115164. /**
  115165. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  115166. * well as opacity information in the alpha channel.
  115167. */
  115168. baseTexture: BaseTexture;
  115169. /**
  115170. * Specifies the metallic scalar value of the material.
  115171. * Can also be used to scale the metalness values of the metallic texture.
  115172. */
  115173. metallic: number;
  115174. /**
  115175. * Specifies the roughness scalar value of the material.
  115176. * Can also be used to scale the roughness values of the metallic texture.
  115177. */
  115178. roughness: number;
  115179. /**
  115180. * Texture containing both the metallic value in the B channel and the
  115181. * roughness value in the G channel to keep better precision.
  115182. */
  115183. metallicRoughnessTexture: BaseTexture;
  115184. /**
  115185. * Instantiates a new PBRMetalRoughnessMaterial instance.
  115186. *
  115187. * @param name The material name
  115188. * @param scene The scene the material will be use in.
  115189. */
  115190. constructor(name: string, scene: Scene);
  115191. /**
  115192. * Return the currrent class name of the material.
  115193. */
  115194. getClassName(): string;
  115195. /**
  115196. * Makes a duplicate of the current material.
  115197. * @param name - name to use for the new material.
  115198. */
  115199. clone(name: string): PBRMetallicRoughnessMaterial;
  115200. /**
  115201. * Serialize the material to a parsable JSON object.
  115202. */
  115203. serialize(): any;
  115204. /**
  115205. * Parses a JSON object correponding to the serialize function.
  115206. */
  115207. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  115208. }
  115209. }
  115210. declare module BABYLON {
  115211. /**
  115212. * The PBR material of BJS following the specular glossiness convention.
  115213. *
  115214. * This fits to the PBR convention in the GLTF definition:
  115215. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  115216. */
  115217. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  115218. /**
  115219. * Specifies the diffuse color of the material.
  115220. */
  115221. diffuseColor: Color3;
  115222. /**
  115223. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  115224. * channel.
  115225. */
  115226. diffuseTexture: BaseTexture;
  115227. /**
  115228. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  115229. */
  115230. specularColor: Color3;
  115231. /**
  115232. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  115233. */
  115234. glossiness: number;
  115235. /**
  115236. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  115237. */
  115238. specularGlossinessTexture: BaseTexture;
  115239. /**
  115240. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  115241. *
  115242. * @param name The material name
  115243. * @param scene The scene the material will be use in.
  115244. */
  115245. constructor(name: string, scene: Scene);
  115246. /**
  115247. * Return the currrent class name of the material.
  115248. */
  115249. getClassName(): string;
  115250. /**
  115251. * Makes a duplicate of the current material.
  115252. * @param name - name to use for the new material.
  115253. */
  115254. clone(name: string): PBRSpecularGlossinessMaterial;
  115255. /**
  115256. * Serialize the material to a parsable JSON object.
  115257. */
  115258. serialize(): any;
  115259. /**
  115260. * Parses a JSON object correponding to the serialize function.
  115261. */
  115262. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  115263. }
  115264. }
  115265. declare module BABYLON {
  115266. /**
  115267. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  115268. * It can help converting any input color in a desired output one. This can then be used to create effects
  115269. * from sepia, black and white to sixties or futuristic rendering...
  115270. *
  115271. * The only supported format is currently 3dl.
  115272. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  115273. */
  115274. export class ColorGradingTexture extends BaseTexture {
  115275. /**
  115276. * The current texture matrix. (will always be identity in color grading texture)
  115277. */
  115278. private _textureMatrix;
  115279. /**
  115280. * The texture URL.
  115281. */
  115282. url: string;
  115283. /**
  115284. * Empty line regex stored for GC.
  115285. */
  115286. private static _noneEmptyLineRegex;
  115287. private _engine;
  115288. /**
  115289. * Instantiates a ColorGradingTexture from the following parameters.
  115290. *
  115291. * @param url The location of the color gradind data (currently only supporting 3dl)
  115292. * @param scene The scene the texture will be used in
  115293. */
  115294. constructor(url: string, scene: Scene);
  115295. /**
  115296. * Returns the texture matrix used in most of the material.
  115297. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  115298. */
  115299. getTextureMatrix(): Matrix;
  115300. /**
  115301. * Occurs when the file being loaded is a .3dl LUT file.
  115302. */
  115303. private load3dlTexture;
  115304. /**
  115305. * Starts the loading process of the texture.
  115306. */
  115307. private loadTexture;
  115308. /**
  115309. * Clones the color gradind texture.
  115310. */
  115311. clone(): ColorGradingTexture;
  115312. /**
  115313. * Called during delayed load for textures.
  115314. */
  115315. delayLoad(): void;
  115316. /**
  115317. * Parses a color grading texture serialized by Babylon.
  115318. * @param parsedTexture The texture information being parsedTexture
  115319. * @param scene The scene to load the texture in
  115320. * @param rootUrl The root url of the data assets to load
  115321. * @return A color gradind texture
  115322. */
  115323. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  115324. /**
  115325. * Serializes the LUT texture to json format.
  115326. */
  115327. serialize(): any;
  115328. }
  115329. }
  115330. declare module BABYLON {
  115331. /**
  115332. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  115333. */
  115334. export class EquiRectangularCubeTexture extends BaseTexture {
  115335. /** The six faces of the cube. */
  115336. private static _FacesMapping;
  115337. private _noMipmap;
  115338. private _onLoad;
  115339. private _onError;
  115340. /** The size of the cubemap. */
  115341. private _size;
  115342. /** The buffer of the image. */
  115343. private _buffer;
  115344. /** The width of the input image. */
  115345. private _width;
  115346. /** The height of the input image. */
  115347. private _height;
  115348. /** The URL to the image. */
  115349. url: string;
  115350. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  115351. coordinatesMode: number;
  115352. /**
  115353. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  115354. * @param url The location of the image
  115355. * @param scene The scene the texture will be used in
  115356. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115357. * @param noMipmap Forces to not generate the mipmap if true
  115358. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115359. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115360. * @param onLoad — defines a callback called when texture is loaded
  115361. * @param onError — defines a callback called if there is an error
  115362. */
  115363. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  115364. /**
  115365. * Load the image data, by putting the image on a canvas and extracting its buffer.
  115366. */
  115367. private loadImage;
  115368. /**
  115369. * Convert the image buffer into a cubemap and create a CubeTexture.
  115370. */
  115371. private loadTexture;
  115372. /**
  115373. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  115374. * @param buffer The ArrayBuffer that should be converted.
  115375. * @returns The buffer as Float32Array.
  115376. */
  115377. private getFloat32ArrayFromArrayBuffer;
  115378. /**
  115379. * Get the current class name of the texture useful for serialization or dynamic coding.
  115380. * @returns "EquiRectangularCubeTexture"
  115381. */
  115382. getClassName(): string;
  115383. /**
  115384. * Create a clone of the current EquiRectangularCubeTexture and return it.
  115385. * @returns A clone of the current EquiRectangularCubeTexture.
  115386. */
  115387. clone(): EquiRectangularCubeTexture;
  115388. }
  115389. }
  115390. declare module BABYLON {
  115391. /**
  115392. * Based on jsTGALoader - Javascript loader for TGA file
  115393. * By Vincent Thibault
  115394. * @see http://blog.robrowser.com/javascript-tga-loader.html
  115395. */
  115396. export class TGATools {
  115397. private static _TYPE_INDEXED;
  115398. private static _TYPE_RGB;
  115399. private static _TYPE_GREY;
  115400. private static _TYPE_RLE_INDEXED;
  115401. private static _TYPE_RLE_RGB;
  115402. private static _TYPE_RLE_GREY;
  115403. private static _ORIGIN_MASK;
  115404. private static _ORIGIN_SHIFT;
  115405. private static _ORIGIN_BL;
  115406. private static _ORIGIN_BR;
  115407. private static _ORIGIN_UL;
  115408. private static _ORIGIN_UR;
  115409. /**
  115410. * Gets the header of a TGA file
  115411. * @param data defines the TGA data
  115412. * @returns the header
  115413. */
  115414. static GetTGAHeader(data: Uint8Array): any;
  115415. /**
  115416. * Uploads TGA content to a Babylon Texture
  115417. * @hidden
  115418. */
  115419. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  115420. /** @hidden */
  115421. 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;
  115422. /** @hidden */
  115423. 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;
  115424. /** @hidden */
  115425. 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;
  115426. /** @hidden */
  115427. 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;
  115428. /** @hidden */
  115429. 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;
  115430. /** @hidden */
  115431. 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;
  115432. }
  115433. }
  115434. declare module BABYLON {
  115435. /**
  115436. * Implementation of the TGA Texture Loader.
  115437. * @hidden
  115438. */
  115439. export class _TGATextureLoader implements IInternalTextureLoader {
  115440. /**
  115441. * Defines wether the loader supports cascade loading the different faces.
  115442. */
  115443. readonly supportCascades: boolean;
  115444. /**
  115445. * This returns if the loader support the current file information.
  115446. * @param extension defines the file extension of the file being loaded
  115447. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115448. * @param fallback defines the fallback internal texture if any
  115449. * @param isBase64 defines whether the texture is encoded as a base64
  115450. * @param isBuffer defines whether the texture data are stored as a buffer
  115451. * @returns true if the loader can load the specified file
  115452. */
  115453. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115454. /**
  115455. * Transform the url before loading if required.
  115456. * @param rootUrl the url of the texture
  115457. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115458. * @returns the transformed texture
  115459. */
  115460. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115461. /**
  115462. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115463. * @param rootUrl the url of the texture
  115464. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115465. * @returns the fallback texture
  115466. */
  115467. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115468. /**
  115469. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115470. * @param data contains the texture data
  115471. * @param texture defines the BabylonJS internal texture
  115472. * @param createPolynomials will be true if polynomials have been requested
  115473. * @param onLoad defines the callback to trigger once the texture is ready
  115474. * @param onError defines the callback to trigger in case of error
  115475. */
  115476. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115477. /**
  115478. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115479. * @param data contains the texture data
  115480. * @param texture defines the BabylonJS internal texture
  115481. * @param callback defines the method to call once ready to upload
  115482. */
  115483. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115484. }
  115485. }
  115486. declare module BABYLON {
  115487. /**
  115488. * Info about the .basis files
  115489. */
  115490. class BasisFileInfo {
  115491. /**
  115492. * If the file has alpha
  115493. */
  115494. hasAlpha: boolean;
  115495. /**
  115496. * Info about each image of the basis file
  115497. */
  115498. images: Array<{
  115499. levels: Array<{
  115500. width: number;
  115501. height: number;
  115502. transcodedPixels: ArrayBufferView;
  115503. }>;
  115504. }>;
  115505. }
  115506. /**
  115507. * Result of transcoding a basis file
  115508. */
  115509. class TranscodeResult {
  115510. /**
  115511. * Info about the .basis file
  115512. */
  115513. fileInfo: BasisFileInfo;
  115514. /**
  115515. * Format to use when loading the file
  115516. */
  115517. format: number;
  115518. }
  115519. /**
  115520. * Configuration options for the Basis transcoder
  115521. */
  115522. export class BasisTranscodeConfiguration {
  115523. /**
  115524. * Supported compression formats used to determine the supported output format of the transcoder
  115525. */
  115526. supportedCompressionFormats?: {
  115527. /**
  115528. * etc1 compression format
  115529. */
  115530. etc1?: boolean;
  115531. /**
  115532. * s3tc compression format
  115533. */
  115534. s3tc?: boolean;
  115535. /**
  115536. * pvrtc compression format
  115537. */
  115538. pvrtc?: boolean;
  115539. /**
  115540. * etc2 compression format
  115541. */
  115542. etc2?: boolean;
  115543. };
  115544. /**
  115545. * If mipmap levels should be loaded for transcoded images (Default: true)
  115546. */
  115547. loadMipmapLevels?: boolean;
  115548. /**
  115549. * Index of a single image to load (Default: all images)
  115550. */
  115551. loadSingleImage?: number;
  115552. }
  115553. /**
  115554. * Used to load .Basis files
  115555. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  115556. */
  115557. export class BasisTools {
  115558. private static _IgnoreSupportedFormats;
  115559. /**
  115560. * URL to use when loading the basis transcoder
  115561. */
  115562. static JSModuleURL: string;
  115563. /**
  115564. * URL to use when loading the wasm module for the transcoder
  115565. */
  115566. static WasmModuleURL: string;
  115567. /**
  115568. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  115569. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  115570. * @returns internal format corresponding to the Basis format
  115571. */
  115572. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  115573. private static _WorkerPromise;
  115574. private static _Worker;
  115575. private static _actionId;
  115576. private static _CreateWorkerAsync;
  115577. /**
  115578. * Transcodes a loaded image file to compressed pixel data
  115579. * @param imageData image data to transcode
  115580. * @param config configuration options for the transcoding
  115581. * @returns a promise resulting in the transcoded image
  115582. */
  115583. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  115584. /**
  115585. * Loads a texture from the transcode result
  115586. * @param texture texture load to
  115587. * @param transcodeResult the result of transcoding the basis file to load from
  115588. */
  115589. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  115590. }
  115591. }
  115592. declare module BABYLON {
  115593. /**
  115594. * Loader for .basis file format
  115595. */
  115596. export class _BasisTextureLoader implements IInternalTextureLoader {
  115597. /**
  115598. * Defines whether the loader supports cascade loading the different faces.
  115599. */
  115600. readonly supportCascades: boolean;
  115601. /**
  115602. * This returns if the loader support the current file information.
  115603. * @param extension defines the file extension of the file being loaded
  115604. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115605. * @param fallback defines the fallback internal texture if any
  115606. * @param isBase64 defines whether the texture is encoded as a base64
  115607. * @param isBuffer defines whether the texture data are stored as a buffer
  115608. * @returns true if the loader can load the specified file
  115609. */
  115610. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115611. /**
  115612. * Transform the url before loading if required.
  115613. * @param rootUrl the url of the texture
  115614. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115615. * @returns the transformed texture
  115616. */
  115617. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115618. /**
  115619. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115620. * @param rootUrl the url of the texture
  115621. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115622. * @returns the fallback texture
  115623. */
  115624. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115625. /**
  115626. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  115627. * @param data contains the texture data
  115628. * @param texture defines the BabylonJS internal texture
  115629. * @param createPolynomials will be true if polynomials have been requested
  115630. * @param onLoad defines the callback to trigger once the texture is ready
  115631. * @param onError defines the callback to trigger in case of error
  115632. */
  115633. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115634. /**
  115635. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115636. * @param data contains the texture data
  115637. * @param texture defines the BabylonJS internal texture
  115638. * @param callback defines the method to call once ready to upload
  115639. */
  115640. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115641. }
  115642. }
  115643. declare module BABYLON {
  115644. /**
  115645. * 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.
  115646. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115647. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115648. */
  115649. export class CustomProceduralTexture extends ProceduralTexture {
  115650. private _animate;
  115651. private _time;
  115652. private _config;
  115653. private _texturePath;
  115654. /**
  115655. * Instantiates a new Custom Procedural Texture.
  115656. * 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.
  115657. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115658. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115659. * @param name Define the name of the texture
  115660. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  115661. * @param size Define the size of the texture to create
  115662. * @param scene Define the scene the texture belongs to
  115663. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  115664. * @param generateMipMaps Define if the texture should creates mip maps or not
  115665. */
  115666. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115667. private _loadJson;
  115668. /**
  115669. * Is the texture ready to be used ? (rendered at least once)
  115670. * @returns true if ready, otherwise, false.
  115671. */
  115672. isReady(): boolean;
  115673. /**
  115674. * Render the texture to its associated render target.
  115675. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  115676. */
  115677. render(useCameraPostProcess?: boolean): void;
  115678. /**
  115679. * Update the list of dependant textures samplers in the shader.
  115680. */
  115681. updateTextures(): void;
  115682. /**
  115683. * Update the uniform values of the procedural texture in the shader.
  115684. */
  115685. updateShaderUniforms(): void;
  115686. /**
  115687. * Define if the texture animates or not.
  115688. */
  115689. animate: boolean;
  115690. }
  115691. }
  115692. declare module BABYLON {
  115693. /** @hidden */
  115694. export var noisePixelShader: {
  115695. name: string;
  115696. shader: string;
  115697. };
  115698. }
  115699. declare module BABYLON {
  115700. /**
  115701. * Class used to generate noise procedural textures
  115702. */
  115703. export class NoiseProceduralTexture extends ProceduralTexture {
  115704. private _time;
  115705. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  115706. brightness: number;
  115707. /** Defines the number of octaves to process */
  115708. octaves: number;
  115709. /** Defines the level of persistence (0.8 by default) */
  115710. persistence: number;
  115711. /** Gets or sets animation speed factor (default is 1) */
  115712. animationSpeedFactor: number;
  115713. /**
  115714. * Creates a new NoiseProceduralTexture
  115715. * @param name defines the name fo the texture
  115716. * @param size defines the size of the texture (default is 256)
  115717. * @param scene defines the hosting scene
  115718. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  115719. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  115720. */
  115721. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115722. private _updateShaderUniforms;
  115723. protected _getDefines(): string;
  115724. /** Generate the current state of the procedural texture */
  115725. render(useCameraPostProcess?: boolean): void;
  115726. /**
  115727. * Serializes this noise procedural texture
  115728. * @returns a serialized noise procedural texture object
  115729. */
  115730. serialize(): any;
  115731. /**
  115732. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  115733. * @param parsedTexture defines parsed texture data
  115734. * @param scene defines the current scene
  115735. * @param rootUrl defines the root URL containing noise procedural texture information
  115736. * @returns a parsed NoiseProceduralTexture
  115737. */
  115738. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  115739. }
  115740. }
  115741. declare module BABYLON {
  115742. /**
  115743. * Raw cube texture where the raw buffers are passed in
  115744. */
  115745. export class RawCubeTexture extends CubeTexture {
  115746. /**
  115747. * Creates a cube texture where the raw buffers are passed in.
  115748. * @param scene defines the scene the texture is attached to
  115749. * @param data defines the array of data to use to create each face
  115750. * @param size defines the size of the textures
  115751. * @param format defines the format of the data
  115752. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  115753. * @param generateMipMaps defines if the engine should generate the mip levels
  115754. * @param invertY defines if data must be stored with Y axis inverted
  115755. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  115756. * @param compression defines the compression used (null by default)
  115757. */
  115758. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  115759. /**
  115760. * Updates the raw cube texture.
  115761. * @param data defines the data to store
  115762. * @param format defines the data format
  115763. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  115764. * @param invertY defines if data must be stored with Y axis inverted
  115765. * @param compression defines the compression used (null by default)
  115766. * @param level defines which level of the texture to update
  115767. */
  115768. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  115769. /**
  115770. * Updates a raw cube texture with RGBD encoded data.
  115771. * @param data defines the array of data [mipmap][face] to use to create each face
  115772. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  115773. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  115774. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  115775. * @returns a promsie that resolves when the operation is complete
  115776. */
  115777. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  115778. /**
  115779. * Clones the raw cube texture.
  115780. * @return a new cube texture
  115781. */
  115782. clone(): CubeTexture;
  115783. /** @hidden */
  115784. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  115785. }
  115786. }
  115787. declare module BABYLON {
  115788. /**
  115789. * Class used to store 3D textures containing user data
  115790. */
  115791. export class RawTexture3D extends Texture {
  115792. /** Gets or sets the texture format to use */
  115793. format: number;
  115794. private _engine;
  115795. /**
  115796. * Create a new RawTexture3D
  115797. * @param data defines the data of the texture
  115798. * @param width defines the width of the texture
  115799. * @param height defines the height of the texture
  115800. * @param depth defines the depth of the texture
  115801. * @param format defines the texture format to use
  115802. * @param scene defines the hosting scene
  115803. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  115804. * @param invertY defines if texture must be stored with Y axis inverted
  115805. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115806. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  115807. */
  115808. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  115809. /** Gets or sets the texture format to use */
  115810. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  115811. /**
  115812. * Update the texture with new data
  115813. * @param data defines the data to store in the texture
  115814. */
  115815. update(data: ArrayBufferView): void;
  115816. }
  115817. }
  115818. declare module BABYLON {
  115819. /**
  115820. * Creates a refraction texture used by refraction channel of the standard material.
  115821. * It is like a mirror but to see through a material.
  115822. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115823. */
  115824. export class RefractionTexture extends RenderTargetTexture {
  115825. /**
  115826. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  115827. * 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.
  115828. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115829. */
  115830. refractionPlane: Plane;
  115831. /**
  115832. * Define how deep under the surface we should see.
  115833. */
  115834. depth: number;
  115835. /**
  115836. * Creates a refraction texture used by refraction channel of the standard material.
  115837. * It is like a mirror but to see through a material.
  115838. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115839. * @param name Define the texture name
  115840. * @param size Define the size of the underlying texture
  115841. * @param scene Define the scene the refraction belongs to
  115842. * @param generateMipMaps Define if we need to generate mips level for the refraction
  115843. */
  115844. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  115845. /**
  115846. * Clone the refraction texture.
  115847. * @returns the cloned texture
  115848. */
  115849. clone(): RefractionTexture;
  115850. /**
  115851. * Serialize the texture to a JSON representation you could use in Parse later on
  115852. * @returns the serialized JSON representation
  115853. */
  115854. serialize(): any;
  115855. }
  115856. }
  115857. declare module BABYLON {
  115858. /**
  115859. * Defines the options related to the creation of an HtmlElementTexture
  115860. */
  115861. export interface IHtmlElementTextureOptions {
  115862. /**
  115863. * Defines wether mip maps should be created or not.
  115864. */
  115865. generateMipMaps?: boolean;
  115866. /**
  115867. * Defines the sampling mode of the texture.
  115868. */
  115869. samplingMode?: number;
  115870. /**
  115871. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  115872. */
  115873. engine: Nullable<Engine>;
  115874. /**
  115875. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  115876. */
  115877. scene: Nullable<Scene>;
  115878. }
  115879. /**
  115880. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  115881. * To be as efficient as possible depending on your constraints nothing aside the first upload
  115882. * is automatically managed.
  115883. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  115884. * in your application.
  115885. *
  115886. * As the update is not automatic, you need to call them manually.
  115887. */
  115888. export class HtmlElementTexture extends BaseTexture {
  115889. /**
  115890. * The texture URL.
  115891. */
  115892. element: HTMLVideoElement | HTMLCanvasElement;
  115893. private static readonly DefaultOptions;
  115894. private _textureMatrix;
  115895. private _engine;
  115896. private _isVideo;
  115897. private _generateMipMaps;
  115898. private _samplingMode;
  115899. /**
  115900. * Instantiates a HtmlElementTexture from the following parameters.
  115901. *
  115902. * @param name Defines the name of the texture
  115903. * @param element Defines the video or canvas the texture is filled with
  115904. * @param options Defines the other none mandatory texture creation options
  115905. */
  115906. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  115907. private _createInternalTexture;
  115908. /**
  115909. * Returns the texture matrix used in most of the material.
  115910. */
  115911. getTextureMatrix(): Matrix;
  115912. /**
  115913. * Updates the content of the texture.
  115914. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  115915. */
  115916. update(invertY?: Nullable<boolean>): void;
  115917. }
  115918. }
  115919. declare module BABYLON {
  115920. /**
  115921. * Enum used to define the target of a block
  115922. */
  115923. export enum NodeMaterialBlockTargets {
  115924. /** Vertex shader */
  115925. Vertex = 1,
  115926. /** Fragment shader */
  115927. Fragment = 2,
  115928. /** Neutral */
  115929. Neutral = 4,
  115930. /** Vertex and Fragment */
  115931. VertexAndFragment = 3
  115932. }
  115933. }
  115934. declare module BABYLON {
  115935. /**
  115936. * Defines the kind of connection point for node based material
  115937. */
  115938. export enum NodeMaterialBlockConnectionPointTypes {
  115939. /** Float */
  115940. Float = 1,
  115941. /** Int */
  115942. Int = 2,
  115943. /** Vector2 */
  115944. Vector2 = 4,
  115945. /** Vector3 */
  115946. Vector3 = 8,
  115947. /** Vector4 */
  115948. Vector4 = 16,
  115949. /** Color3 */
  115950. Color3 = 32,
  115951. /** Color4 */
  115952. Color4 = 64,
  115953. /** Matrix */
  115954. Matrix = 128,
  115955. /** Detect type based on connection */
  115956. AutoDetect = 1024,
  115957. /** Output type that will be defined by input type */
  115958. BasedOnInput = 2048
  115959. }
  115960. }
  115961. declare module BABYLON {
  115962. /**
  115963. * Root class for all node material optimizers
  115964. */
  115965. export class NodeMaterialOptimizer {
  115966. /**
  115967. * Function used to optimize a NodeMaterial graph
  115968. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  115969. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  115970. */
  115971. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  115972. }
  115973. }
  115974. declare module BABYLON {
  115975. /**
  115976. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  115977. */
  115978. export class TransformBlock extends NodeMaterialBlock {
  115979. /**
  115980. * Defines the value to use to complement W value to transform it to a Vector4
  115981. */
  115982. complementW: number;
  115983. /**
  115984. * Defines the value to use to complement z value to transform it to a Vector4
  115985. */
  115986. complementZ: number;
  115987. /**
  115988. * Creates a new TransformBlock
  115989. * @param name defines the block name
  115990. */
  115991. constructor(name: string);
  115992. /**
  115993. * Gets the current class name
  115994. * @returns the class name
  115995. */
  115996. getClassName(): string;
  115997. /**
  115998. * Gets the vector input
  115999. */
  116000. readonly vector: NodeMaterialConnectionPoint;
  116001. /**
  116002. * Gets the output component
  116003. */
  116004. readonly output: NodeMaterialConnectionPoint;
  116005. /**
  116006. * Gets the matrix transform input
  116007. */
  116008. readonly transform: NodeMaterialConnectionPoint;
  116009. protected _buildBlock(state: NodeMaterialBuildState): this;
  116010. serialize(): any;
  116011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116012. }
  116013. }
  116014. declare module BABYLON {
  116015. /**
  116016. * Block used to output the vertex position
  116017. */
  116018. export class VertexOutputBlock extends NodeMaterialBlock {
  116019. /**
  116020. * Creates a new VertexOutputBlock
  116021. * @param name defines the block name
  116022. */
  116023. constructor(name: string);
  116024. /**
  116025. * Gets the current class name
  116026. * @returns the class name
  116027. */
  116028. getClassName(): string;
  116029. /**
  116030. * Gets the vector input component
  116031. */
  116032. readonly vector: NodeMaterialConnectionPoint;
  116033. protected _buildBlock(state: NodeMaterialBuildState): this;
  116034. }
  116035. }
  116036. declare module BABYLON {
  116037. /**
  116038. * Block used to output the final color
  116039. */
  116040. export class FragmentOutputBlock extends NodeMaterialBlock {
  116041. /**
  116042. * Create a new FragmentOutputBlock
  116043. * @param name defines the block name
  116044. */
  116045. constructor(name: string);
  116046. /**
  116047. * Gets the current class name
  116048. * @returns the class name
  116049. */
  116050. getClassName(): string;
  116051. /**
  116052. * Gets the rgba input component
  116053. */
  116054. readonly rgba: NodeMaterialConnectionPoint;
  116055. /**
  116056. * Gets the rgb input component
  116057. */
  116058. readonly rgb: NodeMaterialConnectionPoint;
  116059. /**
  116060. * Gets the a input component
  116061. */
  116062. readonly a: NodeMaterialConnectionPoint;
  116063. protected _buildBlock(state: NodeMaterialBuildState): this;
  116064. }
  116065. }
  116066. declare module BABYLON {
  116067. /**
  116068. * Interface used to configure the node material editor
  116069. */
  116070. export interface INodeMaterialEditorOptions {
  116071. /** Define the URl to load node editor script */
  116072. editorURL?: string;
  116073. }
  116074. /** @hidden */
  116075. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  116076. /** BONES */
  116077. NUM_BONE_INFLUENCERS: number;
  116078. BonesPerMesh: number;
  116079. BONETEXTURE: boolean;
  116080. /** MORPH TARGETS */
  116081. MORPHTARGETS: boolean;
  116082. MORPHTARGETS_NORMAL: boolean;
  116083. MORPHTARGETS_TANGENT: boolean;
  116084. MORPHTARGETS_UV: boolean;
  116085. NUM_MORPH_INFLUENCERS: number;
  116086. /** IMAGE PROCESSING */
  116087. IMAGEPROCESSING: boolean;
  116088. VIGNETTE: boolean;
  116089. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116090. VIGNETTEBLENDMODEOPAQUE: boolean;
  116091. TONEMAPPING: boolean;
  116092. TONEMAPPING_ACES: boolean;
  116093. CONTRAST: boolean;
  116094. EXPOSURE: boolean;
  116095. COLORCURVES: boolean;
  116096. COLORGRADING: boolean;
  116097. COLORGRADING3D: boolean;
  116098. SAMPLER3DGREENDEPTH: boolean;
  116099. SAMPLER3DBGRMAP: boolean;
  116100. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116101. constructor();
  116102. setValue(name: string, value: boolean): void;
  116103. }
  116104. /**
  116105. * Class used to configure NodeMaterial
  116106. */
  116107. export interface INodeMaterialOptions {
  116108. /**
  116109. * Defines if blocks should emit comments
  116110. */
  116111. emitComments: boolean;
  116112. }
  116113. /**
  116114. * Class used to create a node based material built by assembling shader blocks
  116115. */
  116116. export class NodeMaterial extends PushMaterial {
  116117. private static _BuildIdGenerator;
  116118. private _options;
  116119. private _vertexCompilationState;
  116120. private _fragmentCompilationState;
  116121. private _sharedData;
  116122. private _buildId;
  116123. private _buildWasSuccessful;
  116124. private _cachedWorldViewMatrix;
  116125. private _cachedWorldViewProjectionMatrix;
  116126. private _optimizers;
  116127. /** Define the URl to load node editor script */
  116128. static EditorURL: string;
  116129. private BJSNODEMATERIALEDITOR;
  116130. /** Get the inspector from bundle or global */
  116131. private _getGlobalNodeMaterialEditor;
  116132. /**
  116133. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  116134. */
  116135. ignoreAlpha: boolean;
  116136. /**
  116137. * Defines the maximum number of lights that can be used in the material
  116138. */
  116139. maxSimultaneousLights: number;
  116140. /**
  116141. * Observable raised when the material is built
  116142. */
  116143. onBuildObservable: Observable<NodeMaterial>;
  116144. /**
  116145. * Gets or sets the root nodes of the material vertex shader
  116146. */
  116147. _vertexOutputNodes: NodeMaterialBlock[];
  116148. /**
  116149. * Gets or sets the root nodes of the material fragment (pixel) shader
  116150. */
  116151. _fragmentOutputNodes: NodeMaterialBlock[];
  116152. /** Gets or sets options to control the node material overall behavior */
  116153. options: INodeMaterialOptions;
  116154. /**
  116155. * Default configuration related to image processing available in the standard Material.
  116156. */
  116157. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116158. /**
  116159. * Gets the image processing configuration used either in this material.
  116160. */
  116161. /**
  116162. * Sets the Default image processing configuration used either in the this material.
  116163. *
  116164. * If sets to null, the scene one is in use.
  116165. */
  116166. imageProcessingConfiguration: ImageProcessingConfiguration;
  116167. /**
  116168. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  116169. */
  116170. attachedBlocks: NodeMaterialBlock[];
  116171. /**
  116172. * Create a new node based material
  116173. * @param name defines the material name
  116174. * @param scene defines the hosting scene
  116175. * @param options defines creation option
  116176. */
  116177. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  116178. /**
  116179. * Gets the current class name of the material e.g. "NodeMaterial"
  116180. * @returns the class name
  116181. */
  116182. getClassName(): string;
  116183. /**
  116184. * Keep track of the image processing observer to allow dispose and replace.
  116185. */
  116186. private _imageProcessingObserver;
  116187. /**
  116188. * Attaches a new image processing configuration to the Standard Material.
  116189. * @param configuration
  116190. */
  116191. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116192. /**
  116193. * Adds a new optimizer to the list of optimizers
  116194. * @param optimizer defines the optimizers to add
  116195. * @returns the current material
  116196. */
  116197. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116198. /**
  116199. * Remove an optimizer from the list of optimizers
  116200. * @param optimizer defines the optimizers to remove
  116201. * @returns the current material
  116202. */
  116203. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116204. /**
  116205. * Add a new block to the list of output nodes
  116206. * @param node defines the node to add
  116207. * @returns the current material
  116208. */
  116209. addOutputNode(node: NodeMaterialBlock): this;
  116210. /**
  116211. * Remove a block from the list of root nodes
  116212. * @param node defines the node to remove
  116213. * @returns the current material
  116214. */
  116215. removeOutputNode(node: NodeMaterialBlock): this;
  116216. private _addVertexOutputNode;
  116217. private _removeVertexOutputNode;
  116218. private _addFragmentOutputNode;
  116219. private _removeFragmentOutputNode;
  116220. /**
  116221. * Specifies if the material will require alpha blending
  116222. * @returns a boolean specifying if alpha blending is needed
  116223. */
  116224. needAlphaBlending(): boolean;
  116225. /**
  116226. * Specifies if this material should be rendered in alpha test mode
  116227. * @returns a boolean specifying if an alpha test is needed.
  116228. */
  116229. needAlphaTesting(): boolean;
  116230. private _initializeBlock;
  116231. private _resetDualBlocks;
  116232. /**
  116233. * Build the material and generates the inner effect
  116234. * @param verbose defines if the build should log activity
  116235. */
  116236. build(verbose?: boolean): void;
  116237. /**
  116238. * Runs an otpimization phase to try to improve the shader code
  116239. */
  116240. optimize(): void;
  116241. private _prepareDefinesForAttributes;
  116242. /**
  116243. * Get if the submesh is ready to be used and all its information available.
  116244. * Child classes can use it to update shaders
  116245. * @param mesh defines the mesh to check
  116246. * @param subMesh defines which submesh to check
  116247. * @param useInstances specifies that instances should be used
  116248. * @returns a boolean indicating that the submesh is ready or not
  116249. */
  116250. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116251. /**
  116252. * Get a string representing the shaders built by the current node graph
  116253. */
  116254. readonly compiledShaders: string;
  116255. /**
  116256. * Binds the world matrix to the material
  116257. * @param world defines the world transformation matrix
  116258. */
  116259. bindOnlyWorldMatrix(world: Matrix): void;
  116260. /**
  116261. * Binds the submesh to this material by preparing the effect and shader to draw
  116262. * @param world defines the world transformation matrix
  116263. * @param mesh defines the mesh containing the submesh
  116264. * @param subMesh defines the submesh to bind the material to
  116265. */
  116266. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116267. /**
  116268. * Gets the active textures from the material
  116269. * @returns an array of textures
  116270. */
  116271. getActiveTextures(): BaseTexture[];
  116272. /**
  116273. * Specifies if the material uses a texture
  116274. * @param texture defines the texture to check against the material
  116275. * @returns a boolean specifying if the material uses the texture
  116276. */
  116277. hasTexture(texture: BaseTexture): boolean;
  116278. /**
  116279. * Disposes the material
  116280. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  116281. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  116282. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  116283. */
  116284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  116285. /** Creates the node editor window. */
  116286. private _createNodeEditor;
  116287. /**
  116288. * Launch the node material editor
  116289. * @param config Define the configuration of the editor
  116290. * @return a promise fulfilled when the node editor is visible
  116291. */
  116292. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  116293. /**
  116294. * Clear the current material
  116295. */
  116296. clear(): void;
  116297. /**
  116298. * Clear the current material and set it to a default state
  116299. */
  116300. setToDefault(): void;
  116301. private _gatherBlocks;
  116302. /**
  116303. * Serializes this material in a JSON representation
  116304. * @returns the serialized material object
  116305. */
  116306. serialize(): any;
  116307. /**
  116308. * Clear the current graph and load a new one from a serialization object
  116309. * @param source defines the JSON representation of the material
  116310. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116311. */
  116312. loadFromSerialization(source: any, rootUrl?: string): void;
  116313. /**
  116314. * Creates a node material from parsed material data
  116315. * @param source defines the JSON representation of the material
  116316. * @param scene defines the hosting scene
  116317. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116318. * @returns a new node material
  116319. */
  116320. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  116321. }
  116322. }
  116323. declare module BABYLON {
  116324. /**
  116325. * Block used to read a texture from a sampler
  116326. */
  116327. export class TextureBlock extends NodeMaterialBlock {
  116328. private _defineName;
  116329. private _samplerName;
  116330. private _transformedUVName;
  116331. private _textureTransformName;
  116332. private _textureInfoName;
  116333. private _mainUVName;
  116334. private _mainUVDefineName;
  116335. /**
  116336. * Gets or sets the texture associated with the node
  116337. */
  116338. texture: Nullable<BaseTexture>;
  116339. /**
  116340. * Create a new TextureBlock
  116341. * @param name defines the block name
  116342. */
  116343. constructor(name: string);
  116344. /**
  116345. * Gets the current class name
  116346. * @returns the class name
  116347. */
  116348. getClassName(): string;
  116349. /**
  116350. * Gets the uv input component
  116351. */
  116352. readonly uv: NodeMaterialConnectionPoint;
  116353. /**
  116354. * Gets the rgba output component
  116355. */
  116356. readonly rgba: NodeMaterialConnectionPoint;
  116357. /**
  116358. * Gets the rgb output component
  116359. */
  116360. readonly rgb: NodeMaterialConnectionPoint;
  116361. /**
  116362. * Gets the r output component
  116363. */
  116364. readonly r: NodeMaterialConnectionPoint;
  116365. /**
  116366. * Gets the g output component
  116367. */
  116368. readonly g: NodeMaterialConnectionPoint;
  116369. /**
  116370. * Gets the b output component
  116371. */
  116372. readonly b: NodeMaterialConnectionPoint;
  116373. /**
  116374. * Gets the a output component
  116375. */
  116376. readonly a: NodeMaterialConnectionPoint;
  116377. autoConfigure(): void;
  116378. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116379. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116380. isReady(): boolean;
  116381. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116382. private _injectVertexCode;
  116383. private _writeOutput;
  116384. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116385. serialize(): any;
  116386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116387. }
  116388. }
  116389. declare module BABYLON {
  116390. /**
  116391. * Enum used to define well known values e.g. values automatically provided by the system
  116392. */
  116393. export enum NodeMaterialWellKnownValues {
  116394. /** World */
  116395. World = 1,
  116396. /** View */
  116397. View = 2,
  116398. /** Projection */
  116399. Projection = 3,
  116400. /** ViewProjection */
  116401. ViewProjection = 4,
  116402. /** WorldView */
  116403. WorldView = 5,
  116404. /** WorldViewProjection */
  116405. WorldViewProjection = 6,
  116406. /** CameraPosition */
  116407. CameraPosition = 7,
  116408. /** Fog Color */
  116409. FogColor = 8
  116410. }
  116411. }
  116412. declare module BABYLON {
  116413. /**
  116414. * Block used to read a reflection texture from a sampler
  116415. */
  116416. export class ReflectionTextureBlock extends NodeMaterialBlock {
  116417. private _define3DName;
  116418. private _defineCubicName;
  116419. private _defineExplicitName;
  116420. private _defineProjectionName;
  116421. private _defineLocalCubicName;
  116422. private _defineSphericalName;
  116423. private _definePlanarName;
  116424. private _defineEquirectangularName;
  116425. private _defineMirroredEquirectangularFixedName;
  116426. private _defineEquirectangularFixedName;
  116427. private _defineSkyboxName;
  116428. private _cubeSamplerName;
  116429. private _2DSamplerName;
  116430. private _positionUVWName;
  116431. private _directionWName;
  116432. private _reflectionCoordsName;
  116433. private _reflection2DCoordsName;
  116434. private _reflectionColorName;
  116435. private _reflectionMatrixName;
  116436. /**
  116437. * Gets or sets the texture associated with the node
  116438. */
  116439. texture: Nullable<BaseTexture>;
  116440. /**
  116441. * Create a new TextureBlock
  116442. * @param name defines the block name
  116443. */
  116444. constructor(name: string);
  116445. /**
  116446. * Gets the current class name
  116447. * @returns the class name
  116448. */
  116449. getClassName(): string;
  116450. /**
  116451. * Gets the world position input component
  116452. */
  116453. readonly position: NodeMaterialConnectionPoint;
  116454. /**
  116455. * Gets the world position input component
  116456. */
  116457. readonly worldPosition: NodeMaterialConnectionPoint;
  116458. /**
  116459. * Gets the world normal input component
  116460. */
  116461. readonly worldNormal: NodeMaterialConnectionPoint;
  116462. /**
  116463. * Gets the world input component
  116464. */
  116465. readonly world: NodeMaterialConnectionPoint;
  116466. /**
  116467. * Gets the camera (or eye) position component
  116468. */
  116469. readonly cameraPosition: NodeMaterialConnectionPoint;
  116470. /**
  116471. * Gets the view input component
  116472. */
  116473. readonly view: NodeMaterialConnectionPoint;
  116474. /**
  116475. * Gets the rgb output component
  116476. */
  116477. readonly rgb: NodeMaterialConnectionPoint;
  116478. /**
  116479. * Gets the r output component
  116480. */
  116481. readonly r: NodeMaterialConnectionPoint;
  116482. /**
  116483. * Gets the g output component
  116484. */
  116485. readonly g: NodeMaterialConnectionPoint;
  116486. /**
  116487. * Gets the b output component
  116488. */
  116489. readonly b: NodeMaterialConnectionPoint;
  116490. autoConfigure(): void;
  116491. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116492. isReady(): boolean;
  116493. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116494. private _injectVertexCode;
  116495. private _writeOutput;
  116496. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116497. serialize(): any;
  116498. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116499. }
  116500. }
  116501. declare module BABYLON {
  116502. /**
  116503. * Class used to store shared data between 2 NodeMaterialBuildState
  116504. */
  116505. export class NodeMaterialBuildStateSharedData {
  116506. /**
  116507. * Gets the list of emitted varyings
  116508. */
  116509. varyings: string[];
  116510. /**
  116511. * Gets the varying declaration string
  116512. */
  116513. varyingDeclaration: string;
  116514. /**
  116515. * Input blocks
  116516. */
  116517. inputBlocks: InputBlock[];
  116518. /**
  116519. * Input blocks
  116520. */
  116521. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  116522. /**
  116523. * Bindable blocks (Blocks that need to set data to the effect)
  116524. */
  116525. bindableBlocks: NodeMaterialBlock[];
  116526. /**
  116527. * List of blocks that can provide a compilation fallback
  116528. */
  116529. blocksWithFallbacks: NodeMaterialBlock[];
  116530. /**
  116531. * List of blocks that can provide a define update
  116532. */
  116533. blocksWithDefines: NodeMaterialBlock[];
  116534. /**
  116535. * List of blocks that can provide a repeatable content
  116536. */
  116537. repeatableContentBlocks: NodeMaterialBlock[];
  116538. /**
  116539. * List of blocks that can provide a dynamic list of uniforms
  116540. */
  116541. dynamicUniformBlocks: NodeMaterialBlock[];
  116542. /**
  116543. * List of blocks that can block the isReady function for the material
  116544. */
  116545. blockingBlocks: NodeMaterialBlock[];
  116546. /**
  116547. * Build Id used to avoid multiple recompilations
  116548. */
  116549. buildId: number;
  116550. /** List of emitted variables */
  116551. variableNames: {
  116552. [key: string]: number;
  116553. };
  116554. /** List of emitted defines */
  116555. defineNames: {
  116556. [key: string]: number;
  116557. };
  116558. /** Should emit comments? */
  116559. emitComments: boolean;
  116560. /** Emit build activity */
  116561. verbose: boolean;
  116562. /**
  116563. * Gets the compilation hints emitted at compilation time
  116564. */
  116565. hints: {
  116566. needWorldViewMatrix: boolean;
  116567. needWorldViewProjectionMatrix: boolean;
  116568. needAlphaBlending: boolean;
  116569. needAlphaTesting: boolean;
  116570. };
  116571. /**
  116572. * List of compilation checks
  116573. */
  116574. checks: {
  116575. emitVertex: boolean;
  116576. emitFragment: boolean;
  116577. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  116578. };
  116579. /** Creates a new shared data */
  116580. constructor();
  116581. /**
  116582. * Emits console errors and exceptions if there is a failing check
  116583. */
  116584. emitErrors(): void;
  116585. }
  116586. }
  116587. declare module BABYLON {
  116588. /**
  116589. * Class used to store node based material build state
  116590. */
  116591. export class NodeMaterialBuildState {
  116592. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  116593. supportUniformBuffers: boolean;
  116594. /**
  116595. * Gets the list of emitted attributes
  116596. */
  116597. attributes: string[];
  116598. /**
  116599. * Gets the list of emitted uniforms
  116600. */
  116601. uniforms: string[];
  116602. /**
  116603. * Gets the list of emitted uniform buffers
  116604. */
  116605. uniformBuffers: string[];
  116606. /**
  116607. * Gets the list of emitted samplers
  116608. */
  116609. samplers: string[];
  116610. /**
  116611. * Gets the list of emitted functions
  116612. */
  116613. functions: {
  116614. [key: string]: string;
  116615. };
  116616. /**
  116617. * Gets the target of the compilation state
  116618. */
  116619. target: NodeMaterialBlockTargets;
  116620. /**
  116621. * Gets the list of emitted counters
  116622. */
  116623. counters: {
  116624. [key: string]: number;
  116625. };
  116626. /**
  116627. * Shared data between multiple NodeMaterialBuildState instances
  116628. */
  116629. sharedData: NodeMaterialBuildStateSharedData;
  116630. /** @hidden */
  116631. _vertexState: NodeMaterialBuildState;
  116632. /** @hidden */
  116633. _attributeDeclaration: string;
  116634. /** @hidden */
  116635. _uniformDeclaration: string;
  116636. /** @hidden */
  116637. _samplerDeclaration: string;
  116638. /** @hidden */
  116639. _varyingTransfer: string;
  116640. private _repeatableContentAnchorIndex;
  116641. /** @hidden */
  116642. _builtCompilationString: string;
  116643. /**
  116644. * Gets the emitted compilation strings
  116645. */
  116646. compilationString: string;
  116647. /**
  116648. * Finalize the compilation strings
  116649. * @param state defines the current compilation state
  116650. */
  116651. finalize(state: NodeMaterialBuildState): void;
  116652. /** @hidden */
  116653. readonly _repeatableContentAnchor: string;
  116654. /** @hidden */
  116655. _getFreeVariableName(prefix: string): string;
  116656. /** @hidden */
  116657. _getFreeDefineName(prefix: string): string;
  116658. /** @hidden */
  116659. _excludeVariableName(name: string): void;
  116660. /** @hidden */
  116661. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  116662. /** @hidden */
  116663. _emitFunction(name: string, code: string, comments: string): void;
  116664. /** @hidden */
  116665. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  116666. replaceStrings?: {
  116667. search: RegExp;
  116668. replace: string;
  116669. }[];
  116670. repeatKey?: string;
  116671. }): string;
  116672. /** @hidden */
  116673. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  116674. repeatKey?: string;
  116675. removeAttributes?: boolean;
  116676. removeUniforms?: boolean;
  116677. removeVaryings?: boolean;
  116678. removeIfDef?: boolean;
  116679. replaceStrings?: {
  116680. search: RegExp;
  116681. replace: string;
  116682. }[];
  116683. }, storeKey?: string): void;
  116684. /** @hidden */
  116685. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  116686. /** @hidden */
  116687. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  116688. }
  116689. }
  116690. declare module BABYLON {
  116691. /**
  116692. * Defines a block that can be used inside a node based material
  116693. */
  116694. export class NodeMaterialBlock {
  116695. private _buildId;
  116696. private _buildTarget;
  116697. private _target;
  116698. private _isFinalMerger;
  116699. private _isInput;
  116700. /** @hidden */
  116701. _inputs: NodeMaterialConnectionPoint[];
  116702. /** @hidden */
  116703. _outputs: NodeMaterialConnectionPoint[];
  116704. /**
  116705. * Gets or sets the name of the block
  116706. */
  116707. name: string;
  116708. /**
  116709. * Gets or sets the unique id of the node
  116710. */
  116711. uniqueId: number;
  116712. /**
  116713. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  116714. */
  116715. readonly isFinalMerger: boolean;
  116716. /**
  116717. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  116718. */
  116719. readonly isInput: boolean;
  116720. /**
  116721. * Gets or sets the build Id
  116722. */
  116723. buildId: number;
  116724. /**
  116725. * Gets or sets the target of the block
  116726. */
  116727. target: NodeMaterialBlockTargets;
  116728. /**
  116729. * Gets the list of input points
  116730. */
  116731. readonly inputs: NodeMaterialConnectionPoint[];
  116732. /** Gets the list of output points */
  116733. readonly outputs: NodeMaterialConnectionPoint[];
  116734. /**
  116735. * Find an input by its name
  116736. * @param name defines the name of the input to look for
  116737. * @returns the input or null if not found
  116738. */
  116739. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  116740. /**
  116741. * Find an output by its name
  116742. * @param name defines the name of the outputto look for
  116743. * @returns the output or null if not found
  116744. */
  116745. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  116746. /**
  116747. * Creates a new NodeMaterialBlock
  116748. * @param name defines the block name
  116749. * @param target defines the target of that block (Vertex by default)
  116750. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  116751. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  116752. */
  116753. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  116754. /**
  116755. * Initialize the block and prepare the context for build
  116756. * @param state defines the state that will be used for the build
  116757. */
  116758. initialize(state: NodeMaterialBuildState): void;
  116759. /**
  116760. * Bind data to effect. Will only be called for blocks with isBindable === true
  116761. * @param effect defines the effect to bind data to
  116762. * @param nodeMaterial defines the hosting NodeMaterial
  116763. * @param mesh defines the mesh that will be rendered
  116764. */
  116765. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116766. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  116767. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  116768. protected _writeFloat(value: number): string;
  116769. /**
  116770. * Gets the current class name e.g. "NodeMaterialBlock"
  116771. * @returns the class name
  116772. */
  116773. getClassName(): string;
  116774. /**
  116775. * Register a new input. Must be called inside a block constructor
  116776. * @param name defines the connection point name
  116777. * @param type defines the connection point type
  116778. * @param isOptional defines a boolean indicating that this input can be omitted
  116779. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  116780. * @returns the current block
  116781. */
  116782. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  116783. /**
  116784. * Register a new output. Must be called inside a block constructor
  116785. * @param name defines the connection point name
  116786. * @param type defines the connection point type
  116787. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  116788. * @returns the current block
  116789. */
  116790. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  116791. /**
  116792. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  116793. * @param forOutput defines an optional connection point to check compatibility with
  116794. * @returns the first available input or null
  116795. */
  116796. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  116797. /**
  116798. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  116799. * @param forBlock defines an optional block to check compatibility with
  116800. * @returns the first available input or null
  116801. */
  116802. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  116803. /**
  116804. * Gets the sibling of the given output
  116805. * @param current defines the current output
  116806. * @returns the next output in the list or null
  116807. */
  116808. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  116809. /**
  116810. * Connect current block with another block
  116811. * @param other defines the block to connect with
  116812. * @param options define the various options to help pick the right connections
  116813. * @returns the current block
  116814. */
  116815. connectTo(other: NodeMaterialBlock, options?: {
  116816. input?: string;
  116817. output?: string;
  116818. outputSwizzle?: string;
  116819. }): this | undefined;
  116820. protected _buildBlock(state: NodeMaterialBuildState): void;
  116821. /**
  116822. * Add uniforms, samplers and uniform buffers at compilation time
  116823. * @param state defines the state to update
  116824. * @param nodeMaterial defines the node material requesting the update
  116825. * @param defines defines the material defines to update
  116826. */
  116827. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116828. /**
  116829. * Add potential fallbacks if shader compilation fails
  116830. * @param mesh defines the mesh to be rendered
  116831. * @param fallbacks defines the current prioritized list of fallbacks
  116832. */
  116833. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116834. /**
  116835. * Update defines for shader compilation
  116836. * @param mesh defines the mesh to be rendered
  116837. * @param nodeMaterial defines the node material requesting the update
  116838. * @param defines defines the material defines to update
  116839. * @param useInstances specifies that instances should be used
  116840. */
  116841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116842. /**
  116843. * Initialize defines for shader compilation
  116844. * @param mesh defines the mesh to be rendered
  116845. * @param nodeMaterial defines the node material requesting the update
  116846. * @param defines defines the material defines to be prepared
  116847. * @param useInstances specifies that instances should be used
  116848. */
  116849. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116850. /**
  116851. * Lets the block try to connect some inputs automatically
  116852. */
  116853. autoConfigure(): void;
  116854. /**
  116855. * Function called when a block is declared as repeatable content generator
  116856. * @param vertexShaderState defines the current compilation state for the vertex shader
  116857. * @param fragmentShaderState defines the current compilation state for the fragment shader
  116858. * @param mesh defines the mesh to be rendered
  116859. * @param defines defines the material defines to update
  116860. */
  116861. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116862. /**
  116863. * Checks if the block is ready
  116864. * @param mesh defines the mesh to be rendered
  116865. * @param nodeMaterial defines the node material requesting the update
  116866. * @param defines defines the material defines to update
  116867. * @param useInstances specifies that instances should be used
  116868. * @returns true if the block is ready
  116869. */
  116870. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  116871. private _processBuild;
  116872. /**
  116873. * Compile the current node and generate the shader code
  116874. * @param state defines the current compilation state (uniforms, samplers, current string)
  116875. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  116876. * @returns true if already built
  116877. */
  116878. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  116879. /**
  116880. * Clone the current block to a new identical block
  116881. * @param scene defines the hosting scene
  116882. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116883. * @returns a copy of the current block
  116884. */
  116885. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  116886. /**
  116887. * Serializes this block in a JSON representation
  116888. * @returns the serialized block object
  116889. */
  116890. serialize(): any;
  116891. /** @hidden */
  116892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116893. }
  116894. }
  116895. declare module BABYLON {
  116896. /**
  116897. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  116898. */
  116899. export enum NodeMaterialBlockConnectionPointMode {
  116900. /** Value is an uniform */
  116901. Uniform = 0,
  116902. /** Value is a mesh attribute */
  116903. Attribute = 1,
  116904. /** Value is a varying between vertex and fragment shaders */
  116905. Varying = 2,
  116906. /** Mode is undefined */
  116907. Undefined = 3
  116908. }
  116909. }
  116910. declare module BABYLON {
  116911. /**
  116912. * Block used to expose an input value
  116913. */
  116914. export class InputBlock extends NodeMaterialBlock {
  116915. private _mode;
  116916. private _associatedVariableName;
  116917. private _storedValue;
  116918. private _valueCallback;
  116919. private _type;
  116920. /** @hidden */
  116921. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116922. /**
  116923. * Gets or sets the connection point type (default is float)
  116924. */
  116925. readonly type: NodeMaterialBlockConnectionPointTypes;
  116926. /**
  116927. * Creates a new InputBlock
  116928. * @param name defines the block name
  116929. * @param target defines the target of that block (Vertex by default)
  116930. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  116931. */
  116932. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  116933. /**
  116934. * Gets the output component
  116935. */
  116936. readonly output: NodeMaterialConnectionPoint;
  116937. /**
  116938. * Set the source of this connection point to a vertex attribute
  116939. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  116940. * @returns the current connection point
  116941. */
  116942. setAsAttribute(attributeName?: string): InputBlock;
  116943. /**
  116944. * Set the source of this connection point to a well known value
  116945. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  116946. * @returns the current connection point
  116947. */
  116948. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  116949. /**
  116950. * Gets or sets the value of that point.
  116951. * Please note that this value will be ignored if valueCallback is defined
  116952. */
  116953. value: any;
  116954. /**
  116955. * Gets or sets a callback used to get the value of that point.
  116956. * Please note that setting this value will force the connection point to ignore the value property
  116957. */
  116958. valueCallback: () => any;
  116959. /**
  116960. * Gets or sets the associated variable name in the shader
  116961. */
  116962. associatedVariableName: string;
  116963. /**
  116964. * Gets a boolean indicating that this connection point not defined yet
  116965. */
  116966. readonly isUndefined: boolean;
  116967. /**
  116968. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  116969. * In this case the connection point name must be the name of the uniform to use.
  116970. * Can only be set on inputs
  116971. */
  116972. isUniform: boolean;
  116973. /**
  116974. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  116975. * In this case the connection point name must be the name of the attribute to use
  116976. * Can only be set on inputs
  116977. */
  116978. isAttribute: boolean;
  116979. /**
  116980. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  116981. * Can only be set on exit points
  116982. */
  116983. isVarying: boolean;
  116984. /**
  116985. * Gets a boolean indicating that the current connection point is a well known value
  116986. */
  116987. readonly isWellKnownValue: boolean;
  116988. /**
  116989. * Gets or sets the current well known value or null if not defined as well know value
  116990. */
  116991. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116992. /**
  116993. * Gets the current class name
  116994. * @returns the class name
  116995. */
  116996. getClassName(): string;
  116997. private _emitDefine;
  116998. /**
  116999. * Set the input block to its default value (based on its type)
  117000. */
  117001. setDefaultValue(): void;
  117002. private _emit;
  117003. /** @hidden */
  117004. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  117005. /** @hidden */
  117006. _transmit(effect: Effect, scene: Scene): void;
  117007. protected _buildBlock(state: NodeMaterialBuildState): void;
  117008. serialize(): any;
  117009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117010. }
  117011. }
  117012. declare module BABYLON {
  117013. /**
  117014. * Defines a connection point for a block
  117015. */
  117016. export class NodeMaterialConnectionPoint {
  117017. /** @hidden */
  117018. _ownerBlock: NodeMaterialBlock;
  117019. /** @hidden */
  117020. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117021. private _endpoints;
  117022. private _associatedVariableName;
  117023. /** @hidden */
  117024. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  117025. private _type;
  117026. /** @hidden */
  117027. _enforceAssociatedVariableName: boolean;
  117028. /**
  117029. * Gets or sets the additional types supported byt this connection point
  117030. */
  117031. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  117032. /**
  117033. * Gets or sets the associated variable name in the shader
  117034. */
  117035. associatedVariableName: string;
  117036. /**
  117037. * Gets or sets the connection point type (default is float)
  117038. */
  117039. type: NodeMaterialBlockConnectionPointTypes;
  117040. /**
  117041. * Gets or sets the connection point name
  117042. */
  117043. name: string;
  117044. /**
  117045. * Gets or sets a boolean indicating that this connection point can be omitted
  117046. */
  117047. isOptional: boolean;
  117048. /**
  117049. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  117050. */
  117051. define: string;
  117052. /** Gets or sets the target of that connection point */
  117053. target: NodeMaterialBlockTargets;
  117054. /**
  117055. * Gets a boolean indicating that the current point is connected
  117056. */
  117057. readonly isConnected: boolean;
  117058. /**
  117059. * Gets a boolean indicating that the current point is connected to an input block
  117060. */
  117061. readonly isConnectedToInput: boolean;
  117062. /**
  117063. * Gets a the connected input block (if any)
  117064. */
  117065. readonly connectInputBlock: Nullable<InputBlock>;
  117066. /** Get the other side of the connection (if any) */
  117067. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117068. /** Get the block that owns this connection point */
  117069. readonly ownerBlock: NodeMaterialBlock;
  117070. /** Get the block connected on the other side of this connection (if any) */
  117071. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  117072. /** Get the block connected on the endpoints of this connection (if any) */
  117073. readonly connectedBlocks: Array<NodeMaterialBlock>;
  117074. /** Gets the list of connected endpoints */
  117075. readonly endpoints: NodeMaterialConnectionPoint[];
  117076. /**
  117077. * Creates a new connection point
  117078. * @param name defines the connection point name
  117079. * @param ownerBlock defines the block hosting this connection point
  117080. */
  117081. constructor(name: string, ownerBlock: NodeMaterialBlock);
  117082. /**
  117083. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  117084. * @returns the class name
  117085. */
  117086. getClassName(): string;
  117087. /**
  117088. * Gets an boolean indicating if the current point can be connected to another point
  117089. * @param connectionPoint defines the other connection point
  117090. * @returns true if the connection is possible
  117091. */
  117092. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  117093. /**
  117094. * Connect this point to another connection point
  117095. * @param connectionPoint defines the other connection point
  117096. * @returns the current connection point
  117097. */
  117098. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117099. /**
  117100. * Disconnect this point from one of his endpoint
  117101. * @param endpoint defines the other connection point
  117102. * @returns the current connection point
  117103. */
  117104. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117105. /**
  117106. * Serializes this point in a JSON representation
  117107. * @returns the serialized point object
  117108. */
  117109. serialize(): any;
  117110. }
  117111. }
  117112. declare module BABYLON {
  117113. /**
  117114. * Block used to add support for vertex skinning (bones)
  117115. */
  117116. export class BonesBlock extends NodeMaterialBlock {
  117117. /**
  117118. * Creates a new BonesBlock
  117119. * @param name defines the block name
  117120. */
  117121. constructor(name: string);
  117122. /**
  117123. * Initialize the block and prepare the context for build
  117124. * @param state defines the state that will be used for the build
  117125. */
  117126. initialize(state: NodeMaterialBuildState): void;
  117127. /**
  117128. * Gets the current class name
  117129. * @returns the class name
  117130. */
  117131. getClassName(): string;
  117132. /**
  117133. * Gets the matrix indices input component
  117134. */
  117135. readonly matricesIndices: NodeMaterialConnectionPoint;
  117136. /**
  117137. * Gets the matrix weights input component
  117138. */
  117139. readonly matricesWeights: NodeMaterialConnectionPoint;
  117140. /**
  117141. * Gets the extra matrix indices input component
  117142. */
  117143. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  117144. /**
  117145. * Gets the extra matrix weights input component
  117146. */
  117147. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  117148. /**
  117149. * Gets the world input component
  117150. */
  117151. readonly world: NodeMaterialConnectionPoint;
  117152. /**
  117153. * Gets the output component
  117154. */
  117155. readonly output: NodeMaterialConnectionPoint;
  117156. autoConfigure(): void;
  117157. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117160. protected _buildBlock(state: NodeMaterialBuildState): this;
  117161. }
  117162. }
  117163. declare module BABYLON {
  117164. /**
  117165. * Block used to add support for instances
  117166. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  117167. */
  117168. export class InstancesBlock extends NodeMaterialBlock {
  117169. /**
  117170. * Creates a new InstancesBlock
  117171. * @param name defines the block name
  117172. */
  117173. constructor(name: string);
  117174. /**
  117175. * Gets the current class name
  117176. * @returns the class name
  117177. */
  117178. getClassName(): string;
  117179. /**
  117180. * Gets the first world row input component
  117181. */
  117182. readonly world0: NodeMaterialConnectionPoint;
  117183. /**
  117184. * Gets the second world row input component
  117185. */
  117186. readonly world1: NodeMaterialConnectionPoint;
  117187. /**
  117188. * Gets the third world row input component
  117189. */
  117190. readonly world2: NodeMaterialConnectionPoint;
  117191. /**
  117192. * Gets the forth world row input component
  117193. */
  117194. readonly world3: NodeMaterialConnectionPoint;
  117195. /**
  117196. * Gets the world input component
  117197. */
  117198. readonly world: NodeMaterialConnectionPoint;
  117199. /**
  117200. * Gets the output component
  117201. */
  117202. readonly output: NodeMaterialConnectionPoint;
  117203. autoConfigure(): void;
  117204. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117205. protected _buildBlock(state: NodeMaterialBuildState): this;
  117206. }
  117207. }
  117208. declare module BABYLON {
  117209. /**
  117210. * Block used to add morph targets support to vertex shader
  117211. */
  117212. export class MorphTargetsBlock extends NodeMaterialBlock {
  117213. private _repeatableContentAnchor;
  117214. private _repeatebleContentGenerated;
  117215. /**
  117216. * Create a new MorphTargetsBlock
  117217. * @param name defines the block name
  117218. */
  117219. constructor(name: string);
  117220. /**
  117221. * Gets the current class name
  117222. * @returns the class name
  117223. */
  117224. getClassName(): string;
  117225. /**
  117226. * Gets the position input component
  117227. */
  117228. readonly position: NodeMaterialConnectionPoint;
  117229. /**
  117230. * Gets the normal input component
  117231. */
  117232. readonly normal: NodeMaterialConnectionPoint;
  117233. /**
  117234. * Gets the tangent input component
  117235. */
  117236. readonly tangent: NodeMaterialConnectionPoint;
  117237. /**
  117238. * Gets the tangent input component
  117239. */
  117240. readonly uv: NodeMaterialConnectionPoint;
  117241. /**
  117242. * Gets the position output component
  117243. */
  117244. readonly positionOutput: NodeMaterialConnectionPoint;
  117245. /**
  117246. * Gets the normal output component
  117247. */
  117248. readonly normalOutput: NodeMaterialConnectionPoint;
  117249. /**
  117250. * Gets the tangent output component
  117251. */
  117252. readonly tangentOutput: NodeMaterialConnectionPoint;
  117253. /**
  117254. * Gets the tangent output component
  117255. */
  117256. readonly uvOutput: NodeMaterialConnectionPoint;
  117257. initialize(state: NodeMaterialBuildState): void;
  117258. autoConfigure(): void;
  117259. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117261. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117262. protected _buildBlock(state: NodeMaterialBuildState): this;
  117263. }
  117264. }
  117265. declare module BABYLON {
  117266. /**
  117267. * Block used to add an alpha test in the fragment shader
  117268. */
  117269. export class AlphaTestBlock extends NodeMaterialBlock {
  117270. /**
  117271. * Gets or sets the alpha value where alpha testing happens
  117272. */
  117273. alphaCutOff: number;
  117274. /**
  117275. * Create a new AlphaTestBlock
  117276. * @param name defines the block name
  117277. */
  117278. constructor(name: string);
  117279. /**
  117280. * Gets the current class name
  117281. * @returns the class name
  117282. */
  117283. getClassName(): string;
  117284. /**
  117285. * Gets the color input component
  117286. */
  117287. readonly color: NodeMaterialConnectionPoint;
  117288. /**
  117289. * Gets the alpha input component
  117290. */
  117291. readonly alpha: NodeMaterialConnectionPoint;
  117292. protected _buildBlock(state: NodeMaterialBuildState): this;
  117293. }
  117294. }
  117295. declare module BABYLON {
  117296. /**
  117297. * Block used to create a Color3/4 out of individual inputs (one for each component)
  117298. */
  117299. export class ColorMergerBlock extends NodeMaterialBlock {
  117300. /**
  117301. * Create a new ColorMergerBlock
  117302. * @param name defines the block name
  117303. */
  117304. constructor(name: string);
  117305. /**
  117306. * Gets the current class name
  117307. * @returns the class name
  117308. */
  117309. getClassName(): string;
  117310. /**
  117311. * Gets the r component (input)
  117312. */
  117313. readonly r: NodeMaterialConnectionPoint;
  117314. /**
  117315. * Gets the g component (input)
  117316. */
  117317. readonly g: NodeMaterialConnectionPoint;
  117318. /**
  117319. * Gets the b component (input)
  117320. */
  117321. readonly b: NodeMaterialConnectionPoint;
  117322. /**
  117323. * Gets the a component (input)
  117324. */
  117325. readonly a: NodeMaterialConnectionPoint;
  117326. /**
  117327. * Gets the rgba component (output)
  117328. */
  117329. readonly rgba: NodeMaterialConnectionPoint;
  117330. /**
  117331. * Gets the rgb component (output)
  117332. */
  117333. readonly rgb: NodeMaterialConnectionPoint;
  117334. protected _buildBlock(state: NodeMaterialBuildState): this;
  117335. }
  117336. }
  117337. declare module BABYLON {
  117338. /**
  117339. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  117340. */
  117341. export class VectorMergerBlock extends NodeMaterialBlock {
  117342. /**
  117343. * Create a new VectorMergerBlock
  117344. * @param name defines the block name
  117345. */
  117346. constructor(name: string);
  117347. /**
  117348. * Gets the current class name
  117349. * @returns the class name
  117350. */
  117351. getClassName(): string;
  117352. /**
  117353. * Gets the x component (input)
  117354. */
  117355. readonly x: NodeMaterialConnectionPoint;
  117356. /**
  117357. * Gets the y component (input)
  117358. */
  117359. readonly y: NodeMaterialConnectionPoint;
  117360. /**
  117361. * Gets the z component (input)
  117362. */
  117363. readonly z: NodeMaterialConnectionPoint;
  117364. /**
  117365. * Gets the w component (input)
  117366. */
  117367. readonly w: NodeMaterialConnectionPoint;
  117368. /**
  117369. * Gets the xyzw component (output)
  117370. */
  117371. readonly xyzw: NodeMaterialConnectionPoint;
  117372. /**
  117373. * Gets the xyz component (output)
  117374. */
  117375. readonly xyz: NodeMaterialConnectionPoint;
  117376. /**
  117377. * Gets the xy component (output)
  117378. */
  117379. readonly xy: NodeMaterialConnectionPoint;
  117380. protected _buildBlock(state: NodeMaterialBuildState): this;
  117381. }
  117382. }
  117383. declare module BABYLON {
  117384. /**
  117385. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  117386. */
  117387. export class ColorSplitterBlock extends NodeMaterialBlock {
  117388. /**
  117389. * Create a new ColorSplitterBlock
  117390. * @param name defines the block name
  117391. */
  117392. constructor(name: string);
  117393. /**
  117394. * Gets the current class name
  117395. * @returns the class name
  117396. */
  117397. getClassName(): string;
  117398. /**
  117399. * Gets the rgba component (input)
  117400. */
  117401. readonly rgba: NodeMaterialConnectionPoint;
  117402. /**
  117403. * Gets the rgb component (input)
  117404. */
  117405. readonly rgbIn: NodeMaterialConnectionPoint;
  117406. /**
  117407. * Gets the rgb component (output)
  117408. */
  117409. readonly rgbOut: NodeMaterialConnectionPoint;
  117410. /**
  117411. * Gets the r component (output)
  117412. */
  117413. readonly r: NodeMaterialConnectionPoint;
  117414. /**
  117415. * Gets the g component (output)
  117416. */
  117417. readonly g: NodeMaterialConnectionPoint;
  117418. /**
  117419. * Gets the b component (output)
  117420. */
  117421. readonly b: NodeMaterialConnectionPoint;
  117422. /**
  117423. * Gets the a component (output)
  117424. */
  117425. readonly a: NodeMaterialConnectionPoint;
  117426. protected _buildBlock(state: NodeMaterialBuildState): this;
  117427. }
  117428. }
  117429. declare module BABYLON {
  117430. /**
  117431. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  117432. */
  117433. export class VectorSplitterBlock extends NodeMaterialBlock {
  117434. /**
  117435. * Create a new VectorSplitterBlock
  117436. * @param name defines the block name
  117437. */
  117438. constructor(name: string);
  117439. /**
  117440. * Gets the current class name
  117441. * @returns the class name
  117442. */
  117443. getClassName(): string;
  117444. /**
  117445. * Gets the xyzw component (input)
  117446. */
  117447. readonly xyzw: NodeMaterialConnectionPoint;
  117448. /**
  117449. * Gets the xyz component (input)
  117450. */
  117451. readonly xyzIn: NodeMaterialConnectionPoint;
  117452. /**
  117453. * Gets the xyz component (output)
  117454. */
  117455. readonly xyzOut: NodeMaterialConnectionPoint;
  117456. /**
  117457. * Gets the xy component (output)
  117458. */
  117459. readonly xy: NodeMaterialConnectionPoint;
  117460. /**
  117461. * Gets the x component (output)
  117462. */
  117463. readonly x: NodeMaterialConnectionPoint;
  117464. /**
  117465. * Gets the y component (output)
  117466. */
  117467. readonly y: NodeMaterialConnectionPoint;
  117468. /**
  117469. * Gets the z component (output)
  117470. */
  117471. readonly z: NodeMaterialConnectionPoint;
  117472. /**
  117473. * Gets the w component (output)
  117474. */
  117475. readonly w: NodeMaterialConnectionPoint;
  117476. protected _buildBlock(state: NodeMaterialBuildState): this;
  117477. }
  117478. }
  117479. declare module BABYLON {
  117480. /**
  117481. * Block used to add image processing support to fragment shader
  117482. */
  117483. export class ImageProcessingBlock extends NodeMaterialBlock {
  117484. /**
  117485. * Create a new ImageProcessingBlock
  117486. * @param name defines the block name
  117487. */
  117488. constructor(name: string);
  117489. /**
  117490. * Gets the current class name
  117491. * @returns the class name
  117492. */
  117493. getClassName(): string;
  117494. /**
  117495. * Gets the color input component
  117496. */
  117497. readonly color: NodeMaterialConnectionPoint;
  117498. /**
  117499. * Gets the output component
  117500. */
  117501. readonly output: NodeMaterialConnectionPoint;
  117502. /**
  117503. * Initialize the block and prepare the context for build
  117504. * @param state defines the state that will be used for the build
  117505. */
  117506. initialize(state: NodeMaterialBuildState): void;
  117507. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  117508. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117509. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117510. protected _buildBlock(state: NodeMaterialBuildState): this;
  117511. }
  117512. }
  117513. declare module BABYLON {
  117514. /**
  117515. * Block used to add support for scene fog
  117516. */
  117517. export class FogBlock extends NodeMaterialBlock {
  117518. private _fogDistanceName;
  117519. private _fogParameters;
  117520. /**
  117521. * Create a new FogBlock
  117522. * @param name defines the block name
  117523. */
  117524. constructor(name: string);
  117525. /**
  117526. * Gets the current class name
  117527. * @returns the class name
  117528. */
  117529. getClassName(): string;
  117530. /**
  117531. * Gets the world position input component
  117532. */
  117533. readonly worldPosition: NodeMaterialConnectionPoint;
  117534. /**
  117535. * Gets the view input component
  117536. */
  117537. readonly view: NodeMaterialConnectionPoint;
  117538. /**
  117539. * Gets the color input component
  117540. */
  117541. readonly color: NodeMaterialConnectionPoint;
  117542. /**
  117543. * Gets the fog color input component
  117544. */
  117545. readonly fogColor: NodeMaterialConnectionPoint;
  117546. /**
  117547. * Gets the output component
  117548. */
  117549. readonly output: NodeMaterialConnectionPoint;
  117550. autoConfigure(): void;
  117551. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117552. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117553. protected _buildBlock(state: NodeMaterialBuildState): this;
  117554. }
  117555. }
  117556. declare module BABYLON {
  117557. /**
  117558. * Block used to add light in the fragment shader
  117559. */
  117560. export class LightBlock extends NodeMaterialBlock {
  117561. private _lightId;
  117562. /**
  117563. * Gets or sets the light associated with this block
  117564. */
  117565. light: Nullable<Light>;
  117566. /**
  117567. * Create a new LightBlock
  117568. * @param name defines the block name
  117569. */
  117570. constructor(name: string);
  117571. /**
  117572. * Gets the current class name
  117573. * @returns the class name
  117574. */
  117575. getClassName(): string;
  117576. /**
  117577. * Gets the world position input component
  117578. */
  117579. readonly worldPosition: NodeMaterialConnectionPoint;
  117580. /**
  117581. * Gets the world normal input component
  117582. */
  117583. readonly worldNormal: NodeMaterialConnectionPoint;
  117584. /**
  117585. * Gets the camera (or eye) position component
  117586. */
  117587. readonly cameraPosition: NodeMaterialConnectionPoint;
  117588. /**
  117589. * Gets the diffuse output component
  117590. */
  117591. readonly diffuseOutput: NodeMaterialConnectionPoint;
  117592. /**
  117593. * Gets the specular output component
  117594. */
  117595. readonly specularOutput: NodeMaterialConnectionPoint;
  117596. autoConfigure(): void;
  117597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117598. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117600. private _injectVertexCode;
  117601. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117602. serialize(): any;
  117603. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117604. }
  117605. }
  117606. declare module BABYLON {
  117607. /**
  117608. * Block used to multiply 2 values
  117609. */
  117610. export class MultiplyBlock extends NodeMaterialBlock {
  117611. /**
  117612. * Creates a new MultiplyBlock
  117613. * @param name defines the block name
  117614. */
  117615. constructor(name: string);
  117616. /**
  117617. * Gets the current class name
  117618. * @returns the class name
  117619. */
  117620. getClassName(): string;
  117621. /**
  117622. * Gets the left operand input component
  117623. */
  117624. readonly left: NodeMaterialConnectionPoint;
  117625. /**
  117626. * Gets the right operand input component
  117627. */
  117628. readonly right: NodeMaterialConnectionPoint;
  117629. /**
  117630. * Gets the output component
  117631. */
  117632. readonly output: NodeMaterialConnectionPoint;
  117633. protected _buildBlock(state: NodeMaterialBuildState): this;
  117634. }
  117635. }
  117636. declare module BABYLON {
  117637. /**
  117638. * Block used to add 2 vectors
  117639. */
  117640. export class AddBlock extends NodeMaterialBlock {
  117641. /**
  117642. * Creates a new AddBlock
  117643. * @param name defines the block name
  117644. */
  117645. constructor(name: string);
  117646. /**
  117647. * Gets the current class name
  117648. * @returns the class name
  117649. */
  117650. getClassName(): string;
  117651. /**
  117652. * Gets the left operand input component
  117653. */
  117654. readonly left: NodeMaterialConnectionPoint;
  117655. /**
  117656. * Gets the right operand input component
  117657. */
  117658. readonly right: NodeMaterialConnectionPoint;
  117659. /**
  117660. * Gets the output component
  117661. */
  117662. readonly output: NodeMaterialConnectionPoint;
  117663. protected _buildBlock(state: NodeMaterialBuildState): this;
  117664. }
  117665. }
  117666. declare module BABYLON {
  117667. /**
  117668. * Block used to clamp a float
  117669. */
  117670. export class ClampBlock extends NodeMaterialBlock {
  117671. /** Gets or sets the minimum range */
  117672. minimum: number;
  117673. /** Gets or sets the maximum range */
  117674. maximum: number;
  117675. /**
  117676. * Creates a new ClampBlock
  117677. * @param name defines the block name
  117678. */
  117679. constructor(name: string);
  117680. /**
  117681. * Gets the current class name
  117682. * @returns the class name
  117683. */
  117684. getClassName(): string;
  117685. /**
  117686. * Gets the value input component
  117687. */
  117688. readonly value: NodeMaterialConnectionPoint;
  117689. /**
  117690. * Gets the output component
  117691. */
  117692. readonly output: NodeMaterialConnectionPoint;
  117693. protected _buildBlock(state: NodeMaterialBuildState): this;
  117694. }
  117695. }
  117696. declare module BABYLON {
  117697. /**
  117698. * Block used to apply a cross product between 2 vectors
  117699. */
  117700. export class CrossBlock extends NodeMaterialBlock {
  117701. /**
  117702. * Creates a new CrossBlock
  117703. * @param name defines the block name
  117704. */
  117705. constructor(name: string);
  117706. /**
  117707. * Gets the current class name
  117708. * @returns the class name
  117709. */
  117710. getClassName(): string;
  117711. /**
  117712. * Gets the left operand input component
  117713. */
  117714. readonly left: NodeMaterialConnectionPoint;
  117715. /**
  117716. * Gets the right operand input component
  117717. */
  117718. readonly right: NodeMaterialConnectionPoint;
  117719. /**
  117720. * Gets the output component
  117721. */
  117722. readonly output: NodeMaterialConnectionPoint;
  117723. protected _buildBlock(state: NodeMaterialBuildState): this;
  117724. }
  117725. }
  117726. declare module BABYLON {
  117727. /**
  117728. * Block used to apply a dot product between 2 vectors
  117729. */
  117730. export class DotBlock extends NodeMaterialBlock {
  117731. /**
  117732. * Creates a new DotBlock
  117733. * @param name defines the block name
  117734. */
  117735. constructor(name: string);
  117736. /**
  117737. * Gets the current class name
  117738. * @returns the class name
  117739. */
  117740. getClassName(): string;
  117741. /**
  117742. * Gets the left operand input component
  117743. */
  117744. readonly left: NodeMaterialConnectionPoint;
  117745. /**
  117746. * Gets the right operand input component
  117747. */
  117748. readonly right: NodeMaterialConnectionPoint;
  117749. /**
  117750. * Gets the output component
  117751. */
  117752. readonly output: NodeMaterialConnectionPoint;
  117753. protected _buildBlock(state: NodeMaterialBuildState): this;
  117754. }
  117755. }
  117756. declare module BABYLON {
  117757. /**
  117758. * Block used to remap a float from a range to a new one
  117759. */
  117760. export class RemapBlock extends NodeMaterialBlock {
  117761. /**
  117762. * Gets or sets the source range
  117763. */
  117764. sourceRange: Vector2;
  117765. /**
  117766. * Gets or sets the target range
  117767. */
  117768. targetRange: Vector2;
  117769. /**
  117770. * Creates a new RemapBlock
  117771. * @param name defines the block name
  117772. */
  117773. constructor(name: string);
  117774. /**
  117775. * Gets the current class name
  117776. * @returns the class name
  117777. */
  117778. getClassName(): string;
  117779. /**
  117780. * Gets the input component
  117781. */
  117782. readonly input: NodeMaterialConnectionPoint;
  117783. /**
  117784. * Gets the output component
  117785. */
  117786. readonly output: NodeMaterialConnectionPoint;
  117787. protected _buildBlock(state: NodeMaterialBuildState): this;
  117788. }
  117789. }
  117790. declare module BABYLON {
  117791. /**
  117792. * Block used to normalize a vector
  117793. */
  117794. export class NormalizeBlock extends NodeMaterialBlock {
  117795. /**
  117796. * Creates a new NormalizeBlock
  117797. * @param name defines the block name
  117798. */
  117799. constructor(name: string);
  117800. /**
  117801. * Gets the current class name
  117802. * @returns the class name
  117803. */
  117804. getClassName(): string;
  117805. /**
  117806. * Gets the input component
  117807. */
  117808. readonly input: NodeMaterialConnectionPoint;
  117809. /**
  117810. * Gets the output component
  117811. */
  117812. readonly output: NodeMaterialConnectionPoint;
  117813. protected _buildBlock(state: NodeMaterialBuildState): this;
  117814. }
  117815. }
  117816. declare module BABYLON {
  117817. /**
  117818. * Effect Render Options
  117819. */
  117820. export interface IEffectRendererOptions {
  117821. /**
  117822. * Defines the vertices positions.
  117823. */
  117824. positions?: number[];
  117825. /**
  117826. * Defines the indices.
  117827. */
  117828. indices?: number[];
  117829. }
  117830. /**
  117831. * Helper class to render one or more effects
  117832. */
  117833. export class EffectRenderer {
  117834. private engine;
  117835. private static _DefaultOptions;
  117836. private _vertexBuffers;
  117837. private _indexBuffer;
  117838. private _ringBufferIndex;
  117839. private _ringScreenBuffer;
  117840. private _fullscreenViewport;
  117841. private _getNextFrameBuffer;
  117842. /**
  117843. * Creates an effect renderer
  117844. * @param engine the engine to use for rendering
  117845. * @param options defines the options of the effect renderer
  117846. */
  117847. constructor(engine: Engine, options?: IEffectRendererOptions);
  117848. /**
  117849. * Sets the current viewport in normalized coordinates 0-1
  117850. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  117851. */
  117852. setViewport(viewport?: Viewport): void;
  117853. /**
  117854. * Sets the current effect wrapper to use during draw.
  117855. * The effect needs to be ready before calling this api.
  117856. * This also sets the default full screen position attribute.
  117857. * @param effectWrapper Defines the effect to draw with
  117858. */
  117859. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  117860. /**
  117861. * Draws a full screen quad.
  117862. */
  117863. draw(): void;
  117864. /**
  117865. * renders one or more effects to a specified texture
  117866. * @param effectWrappers list of effects to renderer
  117867. * @param outputTexture texture to draw to, if null it will render to the screen
  117868. */
  117869. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  117870. /**
  117871. * Disposes of the effect renderer
  117872. */
  117873. dispose(): void;
  117874. }
  117875. /**
  117876. * Options to create an EffectWrapper
  117877. */
  117878. interface EffectWrapperCreationOptions {
  117879. /**
  117880. * Engine to use to create the effect
  117881. */
  117882. engine: Engine;
  117883. /**
  117884. * Fragment shader for the effect
  117885. */
  117886. fragmentShader: string;
  117887. /**
  117888. * Vertex shader for the effect
  117889. */
  117890. vertexShader?: string;
  117891. /**
  117892. * Attributes to use in the shader
  117893. */
  117894. attributeNames?: Array<string>;
  117895. /**
  117896. * Uniforms to use in the shader
  117897. */
  117898. uniformNames?: Array<string>;
  117899. /**
  117900. * Texture sampler names to use in the shader
  117901. */
  117902. samplerNames?: Array<string>;
  117903. /**
  117904. * The friendly name of the effect displayed in Spector.
  117905. */
  117906. name?: string;
  117907. }
  117908. /**
  117909. * Wraps an effect to be used for rendering
  117910. */
  117911. export class EffectWrapper {
  117912. /**
  117913. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  117914. */
  117915. onApplyObservable: Observable<{}>;
  117916. /**
  117917. * The underlying effect
  117918. */
  117919. effect: Effect;
  117920. /**
  117921. * Creates an effect to be renderer
  117922. * @param creationOptions options to create the effect
  117923. */
  117924. constructor(creationOptions: EffectWrapperCreationOptions);
  117925. /**
  117926. * Disposes of the effect wrapper
  117927. */
  117928. dispose(): void;
  117929. }
  117930. }
  117931. declare module BABYLON {
  117932. /**
  117933. * Helper class to push actions to a pool of workers.
  117934. */
  117935. export class WorkerPool implements IDisposable {
  117936. private _workerInfos;
  117937. private _pendingActions;
  117938. /**
  117939. * Constructor
  117940. * @param workers Array of workers to use for actions
  117941. */
  117942. constructor(workers: Array<Worker>);
  117943. /**
  117944. * Terminates all workers and clears any pending actions.
  117945. */
  117946. dispose(): void;
  117947. /**
  117948. * Pushes an action to the worker pool. If all the workers are active, the action will be
  117949. * pended until a worker has completed its action.
  117950. * @param action The action to perform. Call onComplete when the action is complete.
  117951. */
  117952. push(action: (worker: Worker, onComplete: () => void) => void): void;
  117953. private _execute;
  117954. }
  117955. }
  117956. declare module BABYLON {
  117957. /**
  117958. * Configuration for Draco compression
  117959. */
  117960. export interface IDracoCompressionConfiguration {
  117961. /**
  117962. * Configuration for the decoder.
  117963. */
  117964. decoder: {
  117965. /**
  117966. * The url to the WebAssembly module.
  117967. */
  117968. wasmUrl?: string;
  117969. /**
  117970. * The url to the WebAssembly binary.
  117971. */
  117972. wasmBinaryUrl?: string;
  117973. /**
  117974. * The url to the fallback JavaScript module.
  117975. */
  117976. fallbackUrl?: string;
  117977. };
  117978. }
  117979. /**
  117980. * Draco compression (https://google.github.io/draco/)
  117981. *
  117982. * This class wraps the Draco module.
  117983. *
  117984. * **Encoder**
  117985. *
  117986. * The encoder is not currently implemented.
  117987. *
  117988. * **Decoder**
  117989. *
  117990. * 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.
  117991. *
  117992. * To update the configuration, use the following code:
  117993. * ```javascript
  117994. * DracoCompression.Configuration = {
  117995. * decoder: {
  117996. * wasmUrl: "<url to the WebAssembly library>",
  117997. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  117998. * fallbackUrl: "<url to the fallback JavaScript library>",
  117999. * }
  118000. * };
  118001. * ```
  118002. *
  118003. * 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.
  118004. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  118005. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  118006. *
  118007. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  118008. * ```javascript
  118009. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  118010. * ```
  118011. *
  118012. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  118013. */
  118014. export class DracoCompression implements IDisposable {
  118015. private _workerPoolPromise?;
  118016. private _decoderModulePromise?;
  118017. /**
  118018. * The configuration. Defaults to the following urls:
  118019. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  118020. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  118021. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  118022. */
  118023. static Configuration: IDracoCompressionConfiguration;
  118024. /**
  118025. * Returns true if the decoder configuration is available.
  118026. */
  118027. static readonly DecoderAvailable: boolean;
  118028. /**
  118029. * Default number of workers to create when creating the draco compression object.
  118030. */
  118031. static DefaultNumWorkers: number;
  118032. private static GetDefaultNumWorkers;
  118033. private static _Default;
  118034. /**
  118035. * Default instance for the draco compression object.
  118036. */
  118037. static readonly Default: DracoCompression;
  118038. /**
  118039. * Constructor
  118040. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  118041. */
  118042. constructor(numWorkers?: number);
  118043. /**
  118044. * Stop all async operations and release resources.
  118045. */
  118046. dispose(): void;
  118047. /**
  118048. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  118049. * @returns a promise that resolves when ready
  118050. */
  118051. whenReadyAsync(): Promise<void>;
  118052. /**
  118053. * Decode Draco compressed mesh data to vertex data.
  118054. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  118055. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  118056. * @returns A promise that resolves with the decoded vertex data
  118057. */
  118058. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  118059. [kind: string]: number;
  118060. }): Promise<VertexData>;
  118061. }
  118062. }
  118063. declare module BABYLON {
  118064. /**
  118065. * Class for building Constructive Solid Geometry
  118066. */
  118067. export class CSG {
  118068. private polygons;
  118069. /**
  118070. * The world matrix
  118071. */
  118072. matrix: Matrix;
  118073. /**
  118074. * Stores the position
  118075. */
  118076. position: Vector3;
  118077. /**
  118078. * Stores the rotation
  118079. */
  118080. rotation: Vector3;
  118081. /**
  118082. * Stores the rotation quaternion
  118083. */
  118084. rotationQuaternion: Nullable<Quaternion>;
  118085. /**
  118086. * Stores the scaling vector
  118087. */
  118088. scaling: Vector3;
  118089. /**
  118090. * Convert the Mesh to CSG
  118091. * @param mesh The Mesh to convert to CSG
  118092. * @returns A new CSG from the Mesh
  118093. */
  118094. static FromMesh(mesh: Mesh): CSG;
  118095. /**
  118096. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  118097. * @param polygons Polygons used to construct a CSG solid
  118098. */
  118099. private static FromPolygons;
  118100. /**
  118101. * Clones, or makes a deep copy, of the CSG
  118102. * @returns A new CSG
  118103. */
  118104. clone(): CSG;
  118105. /**
  118106. * Unions this CSG with another CSG
  118107. * @param csg The CSG to union against this CSG
  118108. * @returns The unioned CSG
  118109. */
  118110. union(csg: CSG): CSG;
  118111. /**
  118112. * Unions this CSG with another CSG in place
  118113. * @param csg The CSG to union against this CSG
  118114. */
  118115. unionInPlace(csg: CSG): void;
  118116. /**
  118117. * Subtracts this CSG with another CSG
  118118. * @param csg The CSG to subtract against this CSG
  118119. * @returns A new CSG
  118120. */
  118121. subtract(csg: CSG): CSG;
  118122. /**
  118123. * Subtracts this CSG with another CSG in place
  118124. * @param csg The CSG to subtact against this CSG
  118125. */
  118126. subtractInPlace(csg: CSG): void;
  118127. /**
  118128. * Intersect this CSG with another CSG
  118129. * @param csg The CSG to intersect against this CSG
  118130. * @returns A new CSG
  118131. */
  118132. intersect(csg: CSG): CSG;
  118133. /**
  118134. * Intersects this CSG with another CSG in place
  118135. * @param csg The CSG to intersect against this CSG
  118136. */
  118137. intersectInPlace(csg: CSG): void;
  118138. /**
  118139. * Return a new CSG solid with solid and empty space switched. This solid is
  118140. * not modified.
  118141. * @returns A new CSG solid with solid and empty space switched
  118142. */
  118143. inverse(): CSG;
  118144. /**
  118145. * Inverses the CSG in place
  118146. */
  118147. inverseInPlace(): void;
  118148. /**
  118149. * This is used to keep meshes transformations so they can be restored
  118150. * when we build back a Babylon Mesh
  118151. * NB : All CSG operations are performed in world coordinates
  118152. * @param csg The CSG to copy the transform attributes from
  118153. * @returns This CSG
  118154. */
  118155. copyTransformAttributes(csg: CSG): CSG;
  118156. /**
  118157. * Build Raw mesh from CSG
  118158. * Coordinates here are in world space
  118159. * @param name The name of the mesh geometry
  118160. * @param scene The Scene
  118161. * @param keepSubMeshes Specifies if the submeshes should be kept
  118162. * @returns A new Mesh
  118163. */
  118164. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  118165. /**
  118166. * Build Mesh from CSG taking material and transforms into account
  118167. * @param name The name of the Mesh
  118168. * @param material The material of the Mesh
  118169. * @param scene The Scene
  118170. * @param keepSubMeshes Specifies if submeshes should be kept
  118171. * @returns The new Mesh
  118172. */
  118173. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  118174. }
  118175. }
  118176. declare module BABYLON {
  118177. /**
  118178. * Class used to create a trail following a mesh
  118179. */
  118180. export class TrailMesh extends Mesh {
  118181. private _generator;
  118182. private _autoStart;
  118183. private _running;
  118184. private _diameter;
  118185. private _length;
  118186. private _sectionPolygonPointsCount;
  118187. private _sectionVectors;
  118188. private _sectionNormalVectors;
  118189. private _beforeRenderObserver;
  118190. /**
  118191. * @constructor
  118192. * @param name The value used by scene.getMeshByName() to do a lookup.
  118193. * @param generator The mesh to generate a trail.
  118194. * @param scene The scene to add this mesh to.
  118195. * @param diameter Diameter of trailing mesh. Default is 1.
  118196. * @param length Length of trailing mesh. Default is 60.
  118197. * @param autoStart Automatically start trailing mesh. Default true.
  118198. */
  118199. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  118200. /**
  118201. * "TrailMesh"
  118202. * @returns "TrailMesh"
  118203. */
  118204. getClassName(): string;
  118205. private _createMesh;
  118206. /**
  118207. * Start trailing mesh.
  118208. */
  118209. start(): void;
  118210. /**
  118211. * Stop trailing mesh.
  118212. */
  118213. stop(): void;
  118214. /**
  118215. * Update trailing mesh geometry.
  118216. */
  118217. update(): void;
  118218. /**
  118219. * Returns a new TrailMesh object.
  118220. * @param name is a string, the name given to the new mesh
  118221. * @param newGenerator use new generator object for cloned trail mesh
  118222. * @returns a new mesh
  118223. */
  118224. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  118225. /**
  118226. * Serializes this trail mesh
  118227. * @param serializationObject object to write serialization to
  118228. */
  118229. serialize(serializationObject: any): void;
  118230. /**
  118231. * Parses a serialized trail mesh
  118232. * @param parsedMesh the serialized mesh
  118233. * @param scene the scene to create the trail mesh in
  118234. * @returns the created trail mesh
  118235. */
  118236. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  118237. }
  118238. }
  118239. declare module BABYLON {
  118240. /**
  118241. * Class containing static functions to help procedurally build meshes
  118242. */
  118243. export class TiledBoxBuilder {
  118244. /**
  118245. * Creates a box mesh
  118246. * 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)
  118247. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118251. * @param name defines the name of the mesh
  118252. * @param options defines the options used to create the mesh
  118253. * @param scene defines the hosting scene
  118254. * @returns the box mesh
  118255. */
  118256. static CreateTiledBox(name: string, options: {
  118257. pattern?: number;
  118258. width?: number;
  118259. height?: number;
  118260. depth?: number;
  118261. tileSize?: number;
  118262. tileWidth?: number;
  118263. tileHeight?: number;
  118264. alignHorizontal?: number;
  118265. alignVertical?: number;
  118266. faceUV?: Vector4[];
  118267. faceColors?: Color4[];
  118268. sideOrientation?: number;
  118269. updatable?: boolean;
  118270. }, scene?: Nullable<Scene>): Mesh;
  118271. }
  118272. }
  118273. declare module BABYLON {
  118274. /**
  118275. * Class containing static functions to help procedurally build meshes
  118276. */
  118277. export class TorusKnotBuilder {
  118278. /**
  118279. * Creates a torus knot mesh
  118280. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  118281. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  118282. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  118283. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  118284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118287. * @param name defines the name of the mesh
  118288. * @param options defines the options used to create the mesh
  118289. * @param scene defines the hosting scene
  118290. * @returns the torus knot mesh
  118291. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  118292. */
  118293. static CreateTorusKnot(name: string, options: {
  118294. radius?: number;
  118295. tube?: number;
  118296. radialSegments?: number;
  118297. tubularSegments?: number;
  118298. p?: number;
  118299. q?: number;
  118300. updatable?: boolean;
  118301. sideOrientation?: number;
  118302. frontUVs?: Vector4;
  118303. backUVs?: Vector4;
  118304. }, scene: any): Mesh;
  118305. }
  118306. }
  118307. declare module BABYLON {
  118308. /**
  118309. * Polygon
  118310. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  118311. */
  118312. export class Polygon {
  118313. /**
  118314. * Creates a rectangle
  118315. * @param xmin bottom X coord
  118316. * @param ymin bottom Y coord
  118317. * @param xmax top X coord
  118318. * @param ymax top Y coord
  118319. * @returns points that make the resulting rectation
  118320. */
  118321. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  118322. /**
  118323. * Creates a circle
  118324. * @param radius radius of circle
  118325. * @param cx scale in x
  118326. * @param cy scale in y
  118327. * @param numberOfSides number of sides that make up the circle
  118328. * @returns points that make the resulting circle
  118329. */
  118330. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  118331. /**
  118332. * Creates a polygon from input string
  118333. * @param input Input polygon data
  118334. * @returns the parsed points
  118335. */
  118336. static Parse(input: string): Vector2[];
  118337. /**
  118338. * Starts building a polygon from x and y coordinates
  118339. * @param x x coordinate
  118340. * @param y y coordinate
  118341. * @returns the started path2
  118342. */
  118343. static StartingAt(x: number, y: number): Path2;
  118344. }
  118345. /**
  118346. * Builds a polygon
  118347. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  118348. */
  118349. export class PolygonMeshBuilder {
  118350. private _points;
  118351. private _outlinepoints;
  118352. private _holes;
  118353. private _name;
  118354. private _scene;
  118355. private _epoints;
  118356. private _eholes;
  118357. private _addToepoint;
  118358. /**
  118359. * Babylon reference to the earcut plugin.
  118360. */
  118361. bjsEarcut: any;
  118362. /**
  118363. * Creates a PolygonMeshBuilder
  118364. * @param name name of the builder
  118365. * @param contours Path of the polygon
  118366. * @param scene scene to add to when creating the mesh
  118367. * @param earcutInjection can be used to inject your own earcut reference
  118368. */
  118369. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  118370. /**
  118371. * Adds a whole within the polygon
  118372. * @param hole Array of points defining the hole
  118373. * @returns this
  118374. */
  118375. addHole(hole: Vector2[]): PolygonMeshBuilder;
  118376. /**
  118377. * Creates the polygon
  118378. * @param updatable If the mesh should be updatable
  118379. * @param depth The depth of the mesh created
  118380. * @returns the created mesh
  118381. */
  118382. build(updatable?: boolean, depth?: number): Mesh;
  118383. /**
  118384. * Creates the polygon
  118385. * @param depth The depth of the mesh created
  118386. * @returns the created VertexData
  118387. */
  118388. buildVertexData(depth?: number): VertexData;
  118389. /**
  118390. * Adds a side to the polygon
  118391. * @param positions points that make the polygon
  118392. * @param normals normals of the polygon
  118393. * @param uvs uvs of the polygon
  118394. * @param indices indices of the polygon
  118395. * @param bounds bounds of the polygon
  118396. * @param points points of the polygon
  118397. * @param depth depth of the polygon
  118398. * @param flip flip of the polygon
  118399. */
  118400. private addSide;
  118401. }
  118402. }
  118403. declare module BABYLON {
  118404. /**
  118405. * Class containing static functions to help procedurally build meshes
  118406. */
  118407. export class PolygonBuilder {
  118408. /**
  118409. * Creates a polygon mesh
  118410. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118411. * * 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
  118412. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118415. * * Remember you can only change the shape positions, not their number when updating a polygon
  118416. * @param name defines the name of the mesh
  118417. * @param options defines the options used to create the mesh
  118418. * @param scene defines the hosting scene
  118419. * @param earcutInjection can be used to inject your own earcut reference
  118420. * @returns the polygon mesh
  118421. */
  118422. static CreatePolygon(name: string, options: {
  118423. shape: Vector3[];
  118424. holes?: Vector3[][];
  118425. depth?: number;
  118426. faceUV?: Vector4[];
  118427. faceColors?: Color4[];
  118428. updatable?: boolean;
  118429. sideOrientation?: number;
  118430. frontUVs?: Vector4;
  118431. backUVs?: Vector4;
  118432. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118433. /**
  118434. * Creates an extruded polygon mesh, with depth in the Y direction.
  118435. * * 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)
  118436. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118437. * @param name defines the name of the mesh
  118438. * @param options defines the options used to create the mesh
  118439. * @param scene defines the hosting scene
  118440. * @param earcutInjection can be used to inject your own earcut reference
  118441. * @returns the polygon mesh
  118442. */
  118443. static ExtrudePolygon(name: string, options: {
  118444. shape: Vector3[];
  118445. holes?: Vector3[][];
  118446. depth?: number;
  118447. faceUV?: Vector4[];
  118448. faceColors?: Color4[];
  118449. updatable?: boolean;
  118450. sideOrientation?: number;
  118451. frontUVs?: Vector4;
  118452. backUVs?: Vector4;
  118453. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118454. }
  118455. }
  118456. declare module BABYLON {
  118457. /**
  118458. * Class containing static functions to help procedurally build meshes
  118459. */
  118460. export class LatheBuilder {
  118461. /**
  118462. * Creates lathe mesh.
  118463. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118464. * * 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
  118465. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118466. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118467. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118468. * * 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
  118469. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118470. * * 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
  118471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118475. * @param name defines the name of the mesh
  118476. * @param options defines the options used to create the mesh
  118477. * @param scene defines the hosting scene
  118478. * @returns the lathe mesh
  118479. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118480. */
  118481. static CreateLathe(name: string, options: {
  118482. shape: Vector3[];
  118483. radius?: number;
  118484. tessellation?: number;
  118485. clip?: number;
  118486. arc?: number;
  118487. closed?: boolean;
  118488. updatable?: boolean;
  118489. sideOrientation?: number;
  118490. frontUVs?: Vector4;
  118491. backUVs?: Vector4;
  118492. cap?: number;
  118493. invertUV?: boolean;
  118494. }, scene?: Nullable<Scene>): Mesh;
  118495. }
  118496. }
  118497. declare module BABYLON {
  118498. /**
  118499. * Class containing static functions to help procedurally build meshes
  118500. */
  118501. export class TiledPlaneBuilder {
  118502. /**
  118503. * Creates a tiled plane mesh
  118504. * * The parameter `pattern` will, depending on value, do nothing or
  118505. * * * flip (reflect about central vertical) alternate tiles across and up
  118506. * * * flip every tile on alternate rows
  118507. * * * rotate (180 degs) alternate tiles across and up
  118508. * * * rotate every tile on alternate rows
  118509. * * * flip and rotate alternate tiles across and up
  118510. * * * flip and rotate every tile on alternate rows
  118511. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  118512. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  118513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118515. * * 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)
  118516. * * 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)
  118517. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118518. * @param name defines the name of the mesh
  118519. * @param options defines the options used to create the mesh
  118520. * @param scene defines the hosting scene
  118521. * @returns the box mesh
  118522. */
  118523. static CreateTiledPlane(name: string, options: {
  118524. pattern?: number;
  118525. tileSize?: number;
  118526. tileWidth?: number;
  118527. tileHeight?: number;
  118528. size?: number;
  118529. width?: number;
  118530. height?: number;
  118531. alignHorizontal?: number;
  118532. alignVertical?: number;
  118533. sideOrientation?: number;
  118534. frontUVs?: Vector4;
  118535. backUVs?: Vector4;
  118536. updatable?: boolean;
  118537. }, scene?: Nullable<Scene>): Mesh;
  118538. }
  118539. }
  118540. declare module BABYLON {
  118541. /**
  118542. * Class containing static functions to help procedurally build meshes
  118543. */
  118544. export class TubeBuilder {
  118545. /**
  118546. * Creates a tube mesh.
  118547. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118548. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118549. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118550. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118551. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118552. * * 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)
  118553. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118554. * * 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
  118555. * * 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
  118556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118558. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118560. * @param name defines the name of the mesh
  118561. * @param options defines the options used to create the mesh
  118562. * @param scene defines the hosting scene
  118563. * @returns the tube mesh
  118564. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118565. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118566. */
  118567. static CreateTube(name: string, options: {
  118568. path: Vector3[];
  118569. radius?: number;
  118570. tessellation?: number;
  118571. radiusFunction?: {
  118572. (i: number, distance: number): number;
  118573. };
  118574. cap?: number;
  118575. arc?: number;
  118576. updatable?: boolean;
  118577. sideOrientation?: number;
  118578. frontUVs?: Vector4;
  118579. backUVs?: Vector4;
  118580. instance?: Mesh;
  118581. invertUV?: boolean;
  118582. }, scene?: Nullable<Scene>): Mesh;
  118583. }
  118584. }
  118585. declare module BABYLON {
  118586. /**
  118587. * Class containing static functions to help procedurally build meshes
  118588. */
  118589. export class IcoSphereBuilder {
  118590. /**
  118591. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118592. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118593. * * 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`)
  118594. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118595. * * 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
  118596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118599. * @param name defines the name of the mesh
  118600. * @param options defines the options used to create the mesh
  118601. * @param scene defines the hosting scene
  118602. * @returns the icosahedron mesh
  118603. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  118604. */
  118605. static CreateIcoSphere(name: string, options: {
  118606. radius?: number;
  118607. radiusX?: number;
  118608. radiusY?: number;
  118609. radiusZ?: number;
  118610. flat?: boolean;
  118611. subdivisions?: number;
  118612. sideOrientation?: number;
  118613. frontUVs?: Vector4;
  118614. backUVs?: Vector4;
  118615. updatable?: boolean;
  118616. }, scene?: Nullable<Scene>): Mesh;
  118617. }
  118618. }
  118619. declare module BABYLON {
  118620. /**
  118621. * Class containing static functions to help procedurally build meshes
  118622. */
  118623. export class DecalBuilder {
  118624. /**
  118625. * Creates a decal mesh.
  118626. * 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
  118627. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  118628. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  118629. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  118630. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  118631. * @param name defines the name of the mesh
  118632. * @param sourceMesh defines the mesh where the decal must be applied
  118633. * @param options defines the options used to create the mesh
  118634. * @param scene defines the hosting scene
  118635. * @returns the decal mesh
  118636. * @see https://doc.babylonjs.com/how_to/decals
  118637. */
  118638. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  118639. position?: Vector3;
  118640. normal?: Vector3;
  118641. size?: Vector3;
  118642. angle?: number;
  118643. }): Mesh;
  118644. }
  118645. }
  118646. declare module BABYLON {
  118647. /**
  118648. * Class containing static functions to help procedurally build meshes
  118649. */
  118650. export class MeshBuilder {
  118651. /**
  118652. * Creates a box mesh
  118653. * * The parameter `size` sets the size (float) of each box side (default 1)
  118654. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118655. * * 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)
  118656. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118660. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118661. * @param name defines the name of the mesh
  118662. * @param options defines the options used to create the mesh
  118663. * @param scene defines the hosting scene
  118664. * @returns the box mesh
  118665. */
  118666. static CreateBox(name: string, options: {
  118667. size?: number;
  118668. width?: number;
  118669. height?: number;
  118670. depth?: number;
  118671. faceUV?: Vector4[];
  118672. faceColors?: Color4[];
  118673. sideOrientation?: number;
  118674. frontUVs?: Vector4;
  118675. backUVs?: Vector4;
  118676. updatable?: boolean;
  118677. }, scene?: Nullable<Scene>): Mesh;
  118678. /**
  118679. * Creates a tiled box mesh
  118680. * * faceTiles sets the pattern, tile size and number of tiles for a face
  118681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118682. * @param name defines the name of the mesh
  118683. * @param options defines the options used to create the mesh
  118684. * @param scene defines the hosting scene
  118685. * @returns the tiled box mesh
  118686. */
  118687. static CreateTiledBox(name: string, options: {
  118688. pattern?: number;
  118689. size?: number;
  118690. width?: number;
  118691. height?: number;
  118692. depth: number;
  118693. tileSize?: number;
  118694. tileWidth?: number;
  118695. tileHeight?: number;
  118696. faceUV?: Vector4[];
  118697. faceColors?: Color4[];
  118698. alignHorizontal?: number;
  118699. alignVertical?: number;
  118700. sideOrientation?: number;
  118701. updatable?: boolean;
  118702. }, scene?: Nullable<Scene>): Mesh;
  118703. /**
  118704. * Creates a sphere mesh
  118705. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118706. * * 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`)
  118707. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118708. * * 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
  118709. * * 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)
  118710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118713. * @param name defines the name of the mesh
  118714. * @param options defines the options used to create the mesh
  118715. * @param scene defines the hosting scene
  118716. * @returns the sphere mesh
  118717. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118718. */
  118719. static CreateSphere(name: string, options: {
  118720. segments?: number;
  118721. diameter?: number;
  118722. diameterX?: number;
  118723. diameterY?: number;
  118724. diameterZ?: number;
  118725. arc?: number;
  118726. slice?: number;
  118727. sideOrientation?: number;
  118728. frontUVs?: Vector4;
  118729. backUVs?: Vector4;
  118730. updatable?: boolean;
  118731. }, scene?: Nullable<Scene>): Mesh;
  118732. /**
  118733. * Creates a plane polygonal mesh. By default, this is a disc
  118734. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  118735. * * 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
  118736. * * 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
  118737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118740. * @param name defines the name of the mesh
  118741. * @param options defines the options used to create the mesh
  118742. * @param scene defines the hosting scene
  118743. * @returns the plane polygonal mesh
  118744. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  118745. */
  118746. static CreateDisc(name: string, options: {
  118747. radius?: number;
  118748. tessellation?: number;
  118749. arc?: number;
  118750. updatable?: boolean;
  118751. sideOrientation?: number;
  118752. frontUVs?: Vector4;
  118753. backUVs?: Vector4;
  118754. }, scene?: Nullable<Scene>): Mesh;
  118755. /**
  118756. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118757. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118758. * * 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`)
  118759. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118760. * * 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
  118761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118762. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118764. * @param name defines the name of the mesh
  118765. * @param options defines the options used to create the mesh
  118766. * @param scene defines the hosting scene
  118767. * @returns the icosahedron mesh
  118768. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  118769. */
  118770. static CreateIcoSphere(name: string, options: {
  118771. radius?: number;
  118772. radiusX?: number;
  118773. radiusY?: number;
  118774. radiusZ?: number;
  118775. flat?: boolean;
  118776. subdivisions?: number;
  118777. sideOrientation?: number;
  118778. frontUVs?: Vector4;
  118779. backUVs?: Vector4;
  118780. updatable?: boolean;
  118781. }, scene?: Nullable<Scene>): Mesh;
  118782. /**
  118783. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118784. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  118785. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  118786. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  118787. * * 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
  118788. * * 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
  118789. * * 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
  118790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118793. * * 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
  118794. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  118795. * * 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
  118796. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  118797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118798. * @param name defines the name of the mesh
  118799. * @param options defines the options used to create the mesh
  118800. * @param scene defines the hosting scene
  118801. * @returns the ribbon mesh
  118802. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  118803. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118804. */
  118805. static CreateRibbon(name: string, options: {
  118806. pathArray: Vector3[][];
  118807. closeArray?: boolean;
  118808. closePath?: boolean;
  118809. offset?: number;
  118810. updatable?: boolean;
  118811. sideOrientation?: number;
  118812. frontUVs?: Vector4;
  118813. backUVs?: Vector4;
  118814. instance?: Mesh;
  118815. invertUV?: boolean;
  118816. uvs?: Vector2[];
  118817. colors?: Color4[];
  118818. }, scene?: Nullable<Scene>): Mesh;
  118819. /**
  118820. * Creates a cylinder or a cone mesh
  118821. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  118822. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  118823. * * 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.
  118824. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  118825. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  118826. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  118827. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  118828. * * 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).
  118829. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  118830. * * 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).
  118831. * * 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
  118832. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  118833. * * 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
  118834. * * 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.
  118835. * * If `enclose` is false, a ring surface is one element.
  118836. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  118837. * * 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
  118838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118841. * @param name defines the name of the mesh
  118842. * @param options defines the options used to create the mesh
  118843. * @param scene defines the hosting scene
  118844. * @returns the cylinder mesh
  118845. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  118846. */
  118847. static CreateCylinder(name: string, options: {
  118848. height?: number;
  118849. diameterTop?: number;
  118850. diameterBottom?: number;
  118851. diameter?: number;
  118852. tessellation?: number;
  118853. subdivisions?: number;
  118854. arc?: number;
  118855. faceColors?: Color4[];
  118856. faceUV?: Vector4[];
  118857. updatable?: boolean;
  118858. hasRings?: boolean;
  118859. enclose?: boolean;
  118860. cap?: number;
  118861. sideOrientation?: number;
  118862. frontUVs?: Vector4;
  118863. backUVs?: Vector4;
  118864. }, scene?: Nullable<Scene>): Mesh;
  118865. /**
  118866. * Creates a torus mesh
  118867. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  118868. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  118869. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  118870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118873. * @param name defines the name of the mesh
  118874. * @param options defines the options used to create the mesh
  118875. * @param scene defines the hosting scene
  118876. * @returns the torus mesh
  118877. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  118878. */
  118879. static CreateTorus(name: string, options: {
  118880. diameter?: number;
  118881. thickness?: number;
  118882. tessellation?: number;
  118883. updatable?: boolean;
  118884. sideOrientation?: number;
  118885. frontUVs?: Vector4;
  118886. backUVs?: Vector4;
  118887. }, scene?: Nullable<Scene>): Mesh;
  118888. /**
  118889. * Creates a torus knot mesh
  118890. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  118891. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  118892. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  118893. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  118894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118897. * @param name defines the name of the mesh
  118898. * @param options defines the options used to create the mesh
  118899. * @param scene defines the hosting scene
  118900. * @returns the torus knot mesh
  118901. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  118902. */
  118903. static CreateTorusKnot(name: string, options: {
  118904. radius?: number;
  118905. tube?: number;
  118906. radialSegments?: number;
  118907. tubularSegments?: number;
  118908. p?: number;
  118909. q?: number;
  118910. updatable?: boolean;
  118911. sideOrientation?: number;
  118912. frontUVs?: Vector4;
  118913. backUVs?: Vector4;
  118914. }, scene?: Nullable<Scene>): Mesh;
  118915. /**
  118916. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118917. * * 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
  118918. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118919. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118920. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118921. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118922. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118923. * * 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
  118924. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118927. * @param name defines the name of the new line system
  118928. * @param options defines the options used to create the line system
  118929. * @param scene defines the hosting scene
  118930. * @returns a new line system mesh
  118931. */
  118932. static CreateLineSystem(name: string, options: {
  118933. lines: Vector3[][];
  118934. updatable?: boolean;
  118935. instance?: Nullable<LinesMesh>;
  118936. colors?: Nullable<Color4[][]>;
  118937. useVertexAlpha?: boolean;
  118938. }, scene: Nullable<Scene>): LinesMesh;
  118939. /**
  118940. * Creates a line mesh
  118941. * 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
  118942. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118943. * * The parameter `points` is an array successive Vector3
  118944. * * 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
  118945. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118946. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118947. * * When updating an instance, remember that only point positions can change, not the number of points
  118948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118950. * @param name defines the name of the new line system
  118951. * @param options defines the options used to create the line system
  118952. * @param scene defines the hosting scene
  118953. * @returns a new line mesh
  118954. */
  118955. static CreateLines(name: string, options: {
  118956. points: Vector3[];
  118957. updatable?: boolean;
  118958. instance?: Nullable<LinesMesh>;
  118959. colors?: Color4[];
  118960. useVertexAlpha?: boolean;
  118961. }, scene?: Nullable<Scene>): LinesMesh;
  118962. /**
  118963. * Creates a dashed line mesh
  118964. * * 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
  118965. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118966. * * The parameter `points` is an array successive Vector3
  118967. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118968. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118969. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118970. * * 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
  118971. * * When updating an instance, remember that only point positions can change, not the number of points
  118972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118973. * @param name defines the name of the mesh
  118974. * @param options defines the options used to create the mesh
  118975. * @param scene defines the hosting scene
  118976. * @returns the dashed line mesh
  118977. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118978. */
  118979. static CreateDashedLines(name: string, options: {
  118980. points: Vector3[];
  118981. dashSize?: number;
  118982. gapSize?: number;
  118983. dashNb?: number;
  118984. updatable?: boolean;
  118985. instance?: LinesMesh;
  118986. }, scene?: Nullable<Scene>): LinesMesh;
  118987. /**
  118988. * 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.
  118989. * * 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.
  118990. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118991. * * 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.
  118992. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118993. * * 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
  118994. * * 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
  118995. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118998. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119000. * @param name defines the name of the mesh
  119001. * @param options defines the options used to create the mesh
  119002. * @param scene defines the hosting scene
  119003. * @returns the extruded shape mesh
  119004. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119005. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119006. */
  119007. static ExtrudeShape(name: string, options: {
  119008. shape: Vector3[];
  119009. path: Vector3[];
  119010. scale?: number;
  119011. rotation?: number;
  119012. cap?: number;
  119013. updatable?: boolean;
  119014. sideOrientation?: number;
  119015. frontUVs?: Vector4;
  119016. backUVs?: Vector4;
  119017. instance?: Mesh;
  119018. invertUV?: boolean;
  119019. }, scene?: Nullable<Scene>): Mesh;
  119020. /**
  119021. * Creates an custom extruded shape mesh.
  119022. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119023. * * 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.
  119024. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119025. * * 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
  119026. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119027. * * 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
  119028. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119029. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119030. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119031. * * 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
  119032. * * 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
  119033. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119038. * @param name defines the name of the mesh
  119039. * @param options defines the options used to create the mesh
  119040. * @param scene defines the hosting scene
  119041. * @returns the custom extruded shape mesh
  119042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119043. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119045. */
  119046. static ExtrudeShapeCustom(name: string, options: {
  119047. shape: Vector3[];
  119048. path: Vector3[];
  119049. scaleFunction?: any;
  119050. rotationFunction?: any;
  119051. ribbonCloseArray?: boolean;
  119052. ribbonClosePath?: boolean;
  119053. cap?: number;
  119054. updatable?: boolean;
  119055. sideOrientation?: number;
  119056. frontUVs?: Vector4;
  119057. backUVs?: Vector4;
  119058. instance?: Mesh;
  119059. invertUV?: boolean;
  119060. }, scene?: Nullable<Scene>): Mesh;
  119061. /**
  119062. * Creates lathe mesh.
  119063. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  119064. * * 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
  119065. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  119066. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  119067. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  119068. * * 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
  119069. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  119070. * * 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
  119071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119073. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119075. * @param name defines the name of the mesh
  119076. * @param options defines the options used to create the mesh
  119077. * @param scene defines the hosting scene
  119078. * @returns the lathe mesh
  119079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  119080. */
  119081. static CreateLathe(name: string, options: {
  119082. shape: Vector3[];
  119083. radius?: number;
  119084. tessellation?: number;
  119085. clip?: number;
  119086. arc?: number;
  119087. closed?: boolean;
  119088. updatable?: boolean;
  119089. sideOrientation?: number;
  119090. frontUVs?: Vector4;
  119091. backUVs?: Vector4;
  119092. cap?: number;
  119093. invertUV?: boolean;
  119094. }, scene?: Nullable<Scene>): Mesh;
  119095. /**
  119096. * Creates a tiled plane mesh
  119097. * * You can set a limited pattern arrangement with the tiles
  119098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119101. * @param name defines the name of the mesh
  119102. * @param options defines the options used to create the mesh
  119103. * @param scene defines the hosting scene
  119104. * @returns the plane mesh
  119105. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119106. */
  119107. static CreateTiledPlane(name: string, options: {
  119108. pattern?: number;
  119109. tileSize?: number;
  119110. tileWidth?: number;
  119111. tileHeight?: number;
  119112. size?: number;
  119113. width?: number;
  119114. height?: number;
  119115. alignHorizontal?: number;
  119116. alignVertical?: number;
  119117. sideOrientation?: number;
  119118. frontUVs?: Vector4;
  119119. backUVs?: Vector4;
  119120. updatable?: boolean;
  119121. }, scene?: Nullable<Scene>): Mesh;
  119122. /**
  119123. * Creates a plane mesh
  119124. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119125. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119126. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119130. * @param name defines the name of the mesh
  119131. * @param options defines the options used to create the mesh
  119132. * @param scene defines the hosting scene
  119133. * @returns the plane mesh
  119134. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119135. */
  119136. static CreatePlane(name: string, options: {
  119137. size?: number;
  119138. width?: number;
  119139. height?: number;
  119140. sideOrientation?: number;
  119141. frontUVs?: Vector4;
  119142. backUVs?: Vector4;
  119143. updatable?: boolean;
  119144. sourcePlane?: Plane;
  119145. }, scene?: Nullable<Scene>): Mesh;
  119146. /**
  119147. * Creates a ground mesh
  119148. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  119149. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  119150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119151. * @param name defines the name of the mesh
  119152. * @param options defines the options used to create the mesh
  119153. * @param scene defines the hosting scene
  119154. * @returns the ground mesh
  119155. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  119156. */
  119157. static CreateGround(name: string, options: {
  119158. width?: number;
  119159. height?: number;
  119160. subdivisions?: number;
  119161. subdivisionsX?: number;
  119162. subdivisionsY?: number;
  119163. updatable?: boolean;
  119164. }, scene?: Nullable<Scene>): Mesh;
  119165. /**
  119166. * Creates a tiled ground mesh
  119167. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  119168. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  119169. * * 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
  119170. * * 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
  119171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119172. * @param name defines the name of the mesh
  119173. * @param options defines the options used to create the mesh
  119174. * @param scene defines the hosting scene
  119175. * @returns the tiled ground mesh
  119176. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  119177. */
  119178. static CreateTiledGround(name: string, options: {
  119179. xmin: number;
  119180. zmin: number;
  119181. xmax: number;
  119182. zmax: number;
  119183. subdivisions?: {
  119184. w: number;
  119185. h: number;
  119186. };
  119187. precision?: {
  119188. w: number;
  119189. h: number;
  119190. };
  119191. updatable?: boolean;
  119192. }, scene?: Nullable<Scene>): Mesh;
  119193. /**
  119194. * Creates a ground mesh from a height map
  119195. * * The parameter `url` sets the URL of the height map image resource.
  119196. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  119197. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  119198. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  119199. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  119200. * * 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.
  119201. * * 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).
  119202. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  119203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119204. * @param name defines the name of the mesh
  119205. * @param url defines the url to the height map
  119206. * @param options defines the options used to create the mesh
  119207. * @param scene defines the hosting scene
  119208. * @returns the ground mesh
  119209. * @see https://doc.babylonjs.com/babylon101/height_map
  119210. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  119211. */
  119212. static CreateGroundFromHeightMap(name: string, url: string, options: {
  119213. width?: number;
  119214. height?: number;
  119215. subdivisions?: number;
  119216. minHeight?: number;
  119217. maxHeight?: number;
  119218. colorFilter?: Color3;
  119219. alphaFilter?: number;
  119220. updatable?: boolean;
  119221. onReady?: (mesh: GroundMesh) => void;
  119222. }, scene?: Nullable<Scene>): GroundMesh;
  119223. /**
  119224. * Creates a polygon mesh
  119225. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  119226. * * 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
  119227. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  119230. * * Remember you can only change the shape positions, not their number when updating a polygon
  119231. * @param name defines the name of the mesh
  119232. * @param options defines the options used to create the mesh
  119233. * @param scene defines the hosting scene
  119234. * @param earcutInjection can be used to inject your own earcut reference
  119235. * @returns the polygon mesh
  119236. */
  119237. static CreatePolygon(name: string, options: {
  119238. shape: Vector3[];
  119239. holes?: Vector3[][];
  119240. depth?: number;
  119241. faceUV?: Vector4[];
  119242. faceColors?: Color4[];
  119243. updatable?: boolean;
  119244. sideOrientation?: number;
  119245. frontUVs?: Vector4;
  119246. backUVs?: Vector4;
  119247. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119248. /**
  119249. * Creates an extruded polygon mesh, with depth in the Y direction.
  119250. * * 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)
  119251. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119252. * @param name defines the name of the mesh
  119253. * @param options defines the options used to create the mesh
  119254. * @param scene defines the hosting scene
  119255. * @param earcutInjection can be used to inject your own earcut reference
  119256. * @returns the polygon mesh
  119257. */
  119258. static ExtrudePolygon(name: string, options: {
  119259. shape: Vector3[];
  119260. holes?: Vector3[][];
  119261. depth?: number;
  119262. faceUV?: Vector4[];
  119263. faceColors?: Color4[];
  119264. updatable?: boolean;
  119265. sideOrientation?: number;
  119266. frontUVs?: Vector4;
  119267. backUVs?: Vector4;
  119268. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119269. /**
  119270. * Creates a tube mesh.
  119271. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119272. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  119273. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  119274. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  119275. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  119276. * * 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)
  119277. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  119278. * * 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
  119279. * * 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
  119280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119282. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119284. * @param name defines the name of the mesh
  119285. * @param options defines the options used to create the mesh
  119286. * @param scene defines the hosting scene
  119287. * @returns the tube mesh
  119288. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119289. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  119290. */
  119291. static CreateTube(name: string, options: {
  119292. path: Vector3[];
  119293. radius?: number;
  119294. tessellation?: number;
  119295. radiusFunction?: {
  119296. (i: number, distance: number): number;
  119297. };
  119298. cap?: number;
  119299. arc?: number;
  119300. updatable?: boolean;
  119301. sideOrientation?: number;
  119302. frontUVs?: Vector4;
  119303. backUVs?: Vector4;
  119304. instance?: Mesh;
  119305. invertUV?: boolean;
  119306. }, scene?: Nullable<Scene>): Mesh;
  119307. /**
  119308. * Creates a polyhedron mesh
  119309. * * 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
  119310. * * The parameter `size` (positive float, default 1) sets the polygon size
  119311. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  119312. * * 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`
  119313. * * 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
  119314. * * 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)`)
  119315. * * 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
  119316. * * 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
  119317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119320. * @param name defines the name of the mesh
  119321. * @param options defines the options used to create the mesh
  119322. * @param scene defines the hosting scene
  119323. * @returns the polyhedron mesh
  119324. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  119325. */
  119326. static CreatePolyhedron(name: string, options: {
  119327. type?: number;
  119328. size?: number;
  119329. sizeX?: number;
  119330. sizeY?: number;
  119331. sizeZ?: number;
  119332. custom?: any;
  119333. faceUV?: Vector4[];
  119334. faceColors?: Color4[];
  119335. flat?: boolean;
  119336. updatable?: boolean;
  119337. sideOrientation?: number;
  119338. frontUVs?: Vector4;
  119339. backUVs?: Vector4;
  119340. }, scene?: Nullable<Scene>): Mesh;
  119341. /**
  119342. * Creates a decal mesh.
  119343. * 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
  119344. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119345. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119346. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119347. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119348. * @param name defines the name of the mesh
  119349. * @param sourceMesh defines the mesh where the decal must be applied
  119350. * @param options defines the options used to create the mesh
  119351. * @param scene defines the hosting scene
  119352. * @returns the decal mesh
  119353. * @see https://doc.babylonjs.com/how_to/decals
  119354. */
  119355. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119356. position?: Vector3;
  119357. normal?: Vector3;
  119358. size?: Vector3;
  119359. angle?: number;
  119360. }): Mesh;
  119361. }
  119362. }
  119363. declare module BABYLON {
  119364. /**
  119365. * A simplifier interface for future simplification implementations
  119366. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119367. */
  119368. export interface ISimplifier {
  119369. /**
  119370. * Simplification of a given mesh according to the given settings.
  119371. * Since this requires computation, it is assumed that the function runs async.
  119372. * @param settings The settings of the simplification, including quality and distance
  119373. * @param successCallback A callback that will be called after the mesh was simplified.
  119374. * @param errorCallback in case of an error, this callback will be called. optional.
  119375. */
  119376. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  119377. }
  119378. /**
  119379. * Expected simplification settings.
  119380. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  119381. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119382. */
  119383. export interface ISimplificationSettings {
  119384. /**
  119385. * Gets or sets the expected quality
  119386. */
  119387. quality: number;
  119388. /**
  119389. * Gets or sets the distance when this optimized version should be used
  119390. */
  119391. distance: number;
  119392. /**
  119393. * Gets an already optimized mesh
  119394. */
  119395. optimizeMesh?: boolean;
  119396. }
  119397. /**
  119398. * Class used to specify simplification options
  119399. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119400. */
  119401. export class SimplificationSettings implements ISimplificationSettings {
  119402. /** expected quality */
  119403. quality: number;
  119404. /** distance when this optimized version should be used */
  119405. distance: number;
  119406. /** already optimized mesh */
  119407. optimizeMesh?: boolean | undefined;
  119408. /**
  119409. * Creates a SimplificationSettings
  119410. * @param quality expected quality
  119411. * @param distance distance when this optimized version should be used
  119412. * @param optimizeMesh already optimized mesh
  119413. */
  119414. constructor(
  119415. /** expected quality */
  119416. quality: number,
  119417. /** distance when this optimized version should be used */
  119418. distance: number,
  119419. /** already optimized mesh */
  119420. optimizeMesh?: boolean | undefined);
  119421. }
  119422. /**
  119423. * Interface used to define a simplification task
  119424. */
  119425. export interface ISimplificationTask {
  119426. /**
  119427. * Array of settings
  119428. */
  119429. settings: Array<ISimplificationSettings>;
  119430. /**
  119431. * Simplification type
  119432. */
  119433. simplificationType: SimplificationType;
  119434. /**
  119435. * Mesh to simplify
  119436. */
  119437. mesh: Mesh;
  119438. /**
  119439. * Callback called on success
  119440. */
  119441. successCallback?: () => void;
  119442. /**
  119443. * Defines if parallel processing can be used
  119444. */
  119445. parallelProcessing: boolean;
  119446. }
  119447. /**
  119448. * Queue used to order the simplification tasks
  119449. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119450. */
  119451. export class SimplificationQueue {
  119452. private _simplificationArray;
  119453. /**
  119454. * Gets a boolean indicating that the process is still running
  119455. */
  119456. running: boolean;
  119457. /**
  119458. * Creates a new queue
  119459. */
  119460. constructor();
  119461. /**
  119462. * Adds a new simplification task
  119463. * @param task defines a task to add
  119464. */
  119465. addTask(task: ISimplificationTask): void;
  119466. /**
  119467. * Execute next task
  119468. */
  119469. executeNext(): void;
  119470. /**
  119471. * Execute a simplification task
  119472. * @param task defines the task to run
  119473. */
  119474. runSimplification(task: ISimplificationTask): void;
  119475. private getSimplifier;
  119476. }
  119477. /**
  119478. * The implemented types of simplification
  119479. * At the moment only Quadratic Error Decimation is implemented
  119480. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119481. */
  119482. export enum SimplificationType {
  119483. /** Quadratic error decimation */
  119484. QUADRATIC = 0
  119485. }
  119486. }
  119487. declare module BABYLON {
  119488. interface Scene {
  119489. /** @hidden (Backing field) */
  119490. _simplificationQueue: SimplificationQueue;
  119491. /**
  119492. * Gets or sets the simplification queue attached to the scene
  119493. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119494. */
  119495. simplificationQueue: SimplificationQueue;
  119496. }
  119497. interface Mesh {
  119498. /**
  119499. * Simplify the mesh according to the given array of settings.
  119500. * Function will return immediately and will simplify async
  119501. * @param settings a collection of simplification settings
  119502. * @param parallelProcessing should all levels calculate parallel or one after the other
  119503. * @param simplificationType the type of simplification to run
  119504. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  119505. * @returns the current mesh
  119506. */
  119507. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  119508. }
  119509. /**
  119510. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  119511. * created in a scene
  119512. */
  119513. export class SimplicationQueueSceneComponent implements ISceneComponent {
  119514. /**
  119515. * The component name helpfull to identify the component in the list of scene components.
  119516. */
  119517. readonly name: string;
  119518. /**
  119519. * The scene the component belongs to.
  119520. */
  119521. scene: Scene;
  119522. /**
  119523. * Creates a new instance of the component for the given scene
  119524. * @param scene Defines the scene to register the component in
  119525. */
  119526. constructor(scene: Scene);
  119527. /**
  119528. * Registers the component in a given scene
  119529. */
  119530. register(): void;
  119531. /**
  119532. * Rebuilds the elements related to this component in case of
  119533. * context lost for instance.
  119534. */
  119535. rebuild(): void;
  119536. /**
  119537. * Disposes the component and the associated ressources
  119538. */
  119539. dispose(): void;
  119540. private _beforeCameraUpdate;
  119541. }
  119542. }
  119543. declare module BABYLON {
  119544. /**
  119545. * Navigation plugin interface to add navigation constrained by a navigation mesh
  119546. */
  119547. export interface INavigationEnginePlugin {
  119548. /**
  119549. * plugin name
  119550. */
  119551. name: string;
  119552. /**
  119553. * Creates a navigation mesh
  119554. * @param meshes array of all the geometry used to compute the navigatio mesh
  119555. * @param parameters bunch of parameters used to filter geometry
  119556. */
  119557. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  119558. /**
  119559. * Create a navigation mesh debug mesh
  119560. * @param scene is where the mesh will be added
  119561. * @returns debug display mesh
  119562. */
  119563. createDebugNavMesh(scene: Scene): Mesh;
  119564. /**
  119565. * Get a navigation mesh constrained position, closest to the parameter position
  119566. * @param position world position
  119567. * @returns the closest point to position constrained by the navigation mesh
  119568. */
  119569. getClosestPoint(position: Vector3): Vector3;
  119570. /**
  119571. * Get a navigation mesh constrained position, within a particular radius
  119572. * @param position world position
  119573. * @param maxRadius the maximum distance to the constrained world position
  119574. * @returns the closest point to position constrained by the navigation mesh
  119575. */
  119576. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  119577. /**
  119578. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  119579. * @param start world position
  119580. * @param end world position
  119581. * @returns array containing world position composing the path
  119582. */
  119583. computePath(start: Vector3, end: Vector3): Vector3[];
  119584. /**
  119585. * If this plugin is supported
  119586. * @returns true if plugin is supported
  119587. */
  119588. isSupported(): boolean;
  119589. /**
  119590. * Create a new Crowd so you can add agents
  119591. * @param maxAgents the maximum agent count in the crowd
  119592. * @param maxAgentRadius the maximum radius an agent can have
  119593. * @param scene to attach the crowd to
  119594. * @returns the crowd you can add agents to
  119595. */
  119596. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  119597. /**
  119598. * Release all resources
  119599. */
  119600. dispose(): void;
  119601. }
  119602. /**
  119603. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  119604. */
  119605. export interface ICrowd {
  119606. /**
  119607. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  119608. * You can attach anything to that node. The node position is updated in the scene update tick.
  119609. * @param pos world position that will be constrained by the navigation mesh
  119610. * @param parameters agent parameters
  119611. * @param transform hooked to the agent that will be update by the scene
  119612. * @returns agent index
  119613. */
  119614. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  119615. /**
  119616. * Returns the agent position in world space
  119617. * @param index agent index returned by addAgent
  119618. * @returns world space position
  119619. */
  119620. getAgentPosition(index: number): Vector3;
  119621. /**
  119622. * Gets the agent velocity in world space
  119623. * @param index agent index returned by addAgent
  119624. * @returns world space velocity
  119625. */
  119626. getAgentVelocity(index: number): Vector3;
  119627. /**
  119628. * remove a particular agent previously created
  119629. * @param index agent index returned by addAgent
  119630. */
  119631. removeAgent(index: number): void;
  119632. /**
  119633. * get the list of all agents attached to this crowd
  119634. * @returns list of agent indices
  119635. */
  119636. getAgents(): number[];
  119637. /**
  119638. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  119639. * @param deltaTime in seconds
  119640. */
  119641. update(deltaTime: number): void;
  119642. /**
  119643. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  119644. * @param index agent index returned by addAgent
  119645. * @param destination targeted world position
  119646. */
  119647. agentGoto(index: number, destination: Vector3): void;
  119648. /**
  119649. * Release all resources
  119650. */
  119651. dispose(): void;
  119652. }
  119653. /**
  119654. * Configures an agent
  119655. */
  119656. export interface IAgentParameters {
  119657. /**
  119658. * Agent radius. [Limit: >= 0]
  119659. */
  119660. radius: number;
  119661. /**
  119662. * Agent height. [Limit: > 0]
  119663. */
  119664. height: number;
  119665. /**
  119666. * Maximum allowed acceleration. [Limit: >= 0]
  119667. */
  119668. maxAcceleration: number;
  119669. /**
  119670. * Maximum allowed speed. [Limit: >= 0]
  119671. */
  119672. maxSpeed: number;
  119673. /**
  119674. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  119675. */
  119676. collisionQueryRange: number;
  119677. /**
  119678. * The path visibility optimization range. [Limit: > 0]
  119679. */
  119680. pathOptimizationRange: number;
  119681. /**
  119682. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  119683. */
  119684. separationWeight: number;
  119685. }
  119686. /**
  119687. * Configures the navigation mesh creation
  119688. */
  119689. export interface INavMeshParameters {
  119690. /**
  119691. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  119692. */
  119693. cs: number;
  119694. /**
  119695. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  119696. */
  119697. ch: number;
  119698. /**
  119699. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  119700. */
  119701. walkableSlopeAngle: number;
  119702. /**
  119703. * Minimum floor to 'ceiling' height that will still allow the floor area to
  119704. * be considered walkable. [Limit: >= 3] [Units: vx]
  119705. */
  119706. walkableHeight: number;
  119707. /**
  119708. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  119709. */
  119710. walkableClimb: number;
  119711. /**
  119712. * The distance to erode/shrink the walkable area of the heightfield away from
  119713. * obstructions. [Limit: >=0] [Units: vx]
  119714. */
  119715. walkableRadius: number;
  119716. /**
  119717. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  119718. */
  119719. maxEdgeLen: number;
  119720. /**
  119721. * The maximum distance a simplfied contour's border edges should deviate
  119722. * the original raw contour. [Limit: >=0] [Units: vx]
  119723. */
  119724. maxSimplificationError: number;
  119725. /**
  119726. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  119727. */
  119728. minRegionArea: number;
  119729. /**
  119730. * Any regions with a span count smaller than this value will, if possible,
  119731. * be merged with larger regions. [Limit: >=0] [Units: vx]
  119732. */
  119733. mergeRegionArea: number;
  119734. /**
  119735. * The maximum number of vertices allowed for polygons generated during the
  119736. * contour to polygon conversion process. [Limit: >= 3]
  119737. */
  119738. maxVertsPerPoly: number;
  119739. /**
  119740. * Sets the sampling distance to use when generating the detail mesh.
  119741. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  119742. */
  119743. detailSampleDist: number;
  119744. /**
  119745. * The maximum distance the detail mesh surface should deviate from heightfield
  119746. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  119747. */
  119748. detailSampleMaxError: number;
  119749. }
  119750. }
  119751. declare module BABYLON {
  119752. /**
  119753. * RecastJS navigation plugin
  119754. */
  119755. export class RecastJSPlugin implements INavigationEnginePlugin {
  119756. /**
  119757. * Reference to the Recast library
  119758. */
  119759. bjsRECAST: any;
  119760. /**
  119761. * plugin name
  119762. */
  119763. name: string;
  119764. /**
  119765. * the first navmesh created. We might extend this to support multiple navmeshes
  119766. */
  119767. navMesh: any;
  119768. /**
  119769. * Initializes the recastJS plugin
  119770. * @param recastInjection can be used to inject your own recast reference
  119771. */
  119772. constructor(recastInjection?: any);
  119773. /**
  119774. * Creates a navigation mesh
  119775. * @param meshes array of all the geometry used to compute the navigatio mesh
  119776. * @param parameters bunch of parameters used to filter geometry
  119777. */
  119778. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  119779. /**
  119780. * Create a navigation mesh debug mesh
  119781. * @param scene is where the mesh will be added
  119782. * @returns debug display mesh
  119783. */
  119784. createDebugNavMesh(scene: Scene): Mesh;
  119785. /**
  119786. * Get a navigation mesh constrained position, closest to the parameter position
  119787. * @param position world position
  119788. * @returns the closest point to position constrained by the navigation mesh
  119789. */
  119790. getClosestPoint(position: Vector3): Vector3;
  119791. /**
  119792. * Get a navigation mesh constrained position, within a particular radius
  119793. * @param position world position
  119794. * @param maxRadius the maximum distance to the constrained world position
  119795. * @returns the closest point to position constrained by the navigation mesh
  119796. */
  119797. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  119798. /**
  119799. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  119800. * @param start world position
  119801. * @param end world position
  119802. * @returns array containing world position composing the path
  119803. */
  119804. computePath(start: Vector3, end: Vector3): Vector3[];
  119805. /**
  119806. * Create a new Crowd so you can add agents
  119807. * @param maxAgents the maximum agent count in the crowd
  119808. * @param maxAgentRadius the maximum radius an agent can have
  119809. * @param scene to attach the crowd to
  119810. * @returns the crowd you can add agents to
  119811. */
  119812. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  119813. /**
  119814. * Disposes
  119815. */
  119816. dispose(): void;
  119817. /**
  119818. * If this plugin is supported
  119819. * @returns true if plugin is supported
  119820. */
  119821. isSupported(): boolean;
  119822. }
  119823. /**
  119824. * Recast detour crowd implementation
  119825. */
  119826. export class RecastJSCrowd implements ICrowd {
  119827. /**
  119828. * Recast/detour plugin
  119829. */
  119830. bjsRECASTPlugin: RecastJSPlugin;
  119831. /**
  119832. * Link to the detour crowd
  119833. */
  119834. recastCrowd: any;
  119835. /**
  119836. * One transform per agent
  119837. */
  119838. transforms: TransformNode[];
  119839. /**
  119840. * All agents created
  119841. */
  119842. agents: number[];
  119843. /**
  119844. * Link to the scene is kept to unregister the crowd from the scene
  119845. */
  119846. private _scene;
  119847. /**
  119848. * Observer for crowd updates
  119849. */
  119850. private _onBeforeAnimationsObserver;
  119851. /**
  119852. * Constructor
  119853. * @param plugin recastJS plugin
  119854. * @param maxAgents the maximum agent count in the crowd
  119855. * @param maxAgentRadius the maximum radius an agent can have
  119856. * @param scene to attach the crowd to
  119857. * @returns the crowd you can add agents to
  119858. */
  119859. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  119860. /**
  119861. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  119862. * You can attach anything to that node. The node position is updated in the scene update tick.
  119863. * @param pos world position that will be constrained by the navigation mesh
  119864. * @param parameters agent parameters
  119865. * @param transform hooked to the agent that will be update by the scene
  119866. * @returns agent index
  119867. */
  119868. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  119869. /**
  119870. * Returns the agent position in world space
  119871. * @param index agent index returned by addAgent
  119872. * @returns world space position
  119873. */
  119874. getAgentPosition(index: number): Vector3;
  119875. /**
  119876. * Returns the agent velocity in world space
  119877. * @param index agent index returned by addAgent
  119878. * @returns world space velocity
  119879. */
  119880. getAgentVelocity(index: number): Vector3;
  119881. /**
  119882. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  119883. * @param index agent index returned by addAgent
  119884. * @param destination targeted world position
  119885. */
  119886. agentGoto(index: number, destination: Vector3): void;
  119887. /**
  119888. * remove a particular agent previously created
  119889. * @param index agent index returned by addAgent
  119890. */
  119891. removeAgent(index: number): void;
  119892. /**
  119893. * get the list of all agents attached to this crowd
  119894. * @returns list of agent indices
  119895. */
  119896. getAgents(): number[];
  119897. /**
  119898. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  119899. * @param deltaTime in seconds
  119900. */
  119901. update(deltaTime: number): void;
  119902. /**
  119903. * Release all resources
  119904. */
  119905. dispose(): void;
  119906. }
  119907. }
  119908. declare module BABYLON {
  119909. /**
  119910. * Class used to enable access to IndexedDB
  119911. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119912. */
  119913. export class Database implements IOfflineProvider {
  119914. private _callbackManifestChecked;
  119915. private _currentSceneUrl;
  119916. private _db;
  119917. private _enableSceneOffline;
  119918. private _enableTexturesOffline;
  119919. private _manifestVersionFound;
  119920. private _mustUpdateRessources;
  119921. private _hasReachedQuota;
  119922. private _isSupported;
  119923. private _idbFactory;
  119924. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  119925. private static IsUASupportingBlobStorage;
  119926. /**
  119927. * Gets a boolean indicating if Database storate is enabled (off by default)
  119928. */
  119929. static IDBStorageEnabled: boolean;
  119930. /**
  119931. * Gets a boolean indicating if scene must be saved in the database
  119932. */
  119933. readonly enableSceneOffline: boolean;
  119934. /**
  119935. * Gets a boolean indicating if textures must be saved in the database
  119936. */
  119937. readonly enableTexturesOffline: boolean;
  119938. /**
  119939. * Creates a new Database
  119940. * @param urlToScene defines the url to load the scene
  119941. * @param callbackManifestChecked defines the callback to use when manifest is checked
  119942. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  119943. */
  119944. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  119945. private static _ParseURL;
  119946. private static _ReturnFullUrlLocation;
  119947. private _checkManifestFile;
  119948. /**
  119949. * Open the database and make it available
  119950. * @param successCallback defines the callback to call on success
  119951. * @param errorCallback defines the callback to call on error
  119952. */
  119953. open(successCallback: () => void, errorCallback: () => void): void;
  119954. /**
  119955. * Loads an image from the database
  119956. * @param url defines the url to load from
  119957. * @param image defines the target DOM image
  119958. */
  119959. loadImage(url: string, image: HTMLImageElement): void;
  119960. private _loadImageFromDBAsync;
  119961. private _saveImageIntoDBAsync;
  119962. private _checkVersionFromDB;
  119963. private _loadVersionFromDBAsync;
  119964. private _saveVersionIntoDBAsync;
  119965. /**
  119966. * Loads a file from database
  119967. * @param url defines the URL to load from
  119968. * @param sceneLoaded defines a callback to call on success
  119969. * @param progressCallBack defines a callback to call when progress changed
  119970. * @param errorCallback defines a callback to call on error
  119971. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  119972. */
  119973. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  119974. private _loadFileAsync;
  119975. private _saveFileAsync;
  119976. /**
  119977. * Validates if xhr data is correct
  119978. * @param xhr defines the request to validate
  119979. * @param dataType defines the expected data type
  119980. * @returns true if data is correct
  119981. */
  119982. private static _ValidateXHRData;
  119983. }
  119984. }
  119985. declare module BABYLON {
  119986. /** @hidden */
  119987. export var gpuUpdateParticlesPixelShader: {
  119988. name: string;
  119989. shader: string;
  119990. };
  119991. }
  119992. declare module BABYLON {
  119993. /** @hidden */
  119994. export var gpuUpdateParticlesVertexShader: {
  119995. name: string;
  119996. shader: string;
  119997. };
  119998. }
  119999. declare module BABYLON {
  120000. /** @hidden */
  120001. export var clipPlaneFragmentDeclaration2: {
  120002. name: string;
  120003. shader: string;
  120004. };
  120005. }
  120006. declare module BABYLON {
  120007. /** @hidden */
  120008. export var gpuRenderParticlesPixelShader: {
  120009. name: string;
  120010. shader: string;
  120011. };
  120012. }
  120013. declare module BABYLON {
  120014. /** @hidden */
  120015. export var clipPlaneVertexDeclaration2: {
  120016. name: string;
  120017. shader: string;
  120018. };
  120019. }
  120020. declare module BABYLON {
  120021. /** @hidden */
  120022. export var gpuRenderParticlesVertexShader: {
  120023. name: string;
  120024. shader: string;
  120025. };
  120026. }
  120027. declare module BABYLON {
  120028. /**
  120029. * This represents a GPU particle system in Babylon
  120030. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  120031. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  120032. */
  120033. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  120034. /**
  120035. * The layer mask we are rendering the particles through.
  120036. */
  120037. layerMask: number;
  120038. private _capacity;
  120039. private _activeCount;
  120040. private _currentActiveCount;
  120041. private _accumulatedCount;
  120042. private _renderEffect;
  120043. private _updateEffect;
  120044. private _buffer0;
  120045. private _buffer1;
  120046. private _spriteBuffer;
  120047. private _updateVAO;
  120048. private _renderVAO;
  120049. private _targetIndex;
  120050. private _sourceBuffer;
  120051. private _targetBuffer;
  120052. private _engine;
  120053. private _currentRenderId;
  120054. private _started;
  120055. private _stopped;
  120056. private _timeDelta;
  120057. private _randomTexture;
  120058. private _randomTexture2;
  120059. private _attributesStrideSize;
  120060. private _updateEffectOptions;
  120061. private _randomTextureSize;
  120062. private _actualFrame;
  120063. private readonly _rawTextureWidth;
  120064. /**
  120065. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  120066. */
  120067. static readonly IsSupported: boolean;
  120068. /**
  120069. * An event triggered when the system is disposed.
  120070. */
  120071. onDisposeObservable: Observable<GPUParticleSystem>;
  120072. /**
  120073. * Gets the maximum number of particles active at the same time.
  120074. * @returns The max number of active particles.
  120075. */
  120076. getCapacity(): number;
  120077. /**
  120078. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  120079. * to override the particles.
  120080. */
  120081. forceDepthWrite: boolean;
  120082. /**
  120083. * Gets or set the number of active particles
  120084. */
  120085. activeParticleCount: number;
  120086. private _preWarmDone;
  120087. /**
  120088. * Is this system ready to be used/rendered
  120089. * @return true if the system is ready
  120090. */
  120091. isReady(): boolean;
  120092. /**
  120093. * Gets if the system has been started. (Note: this will still be true after stop is called)
  120094. * @returns True if it has been started, otherwise false.
  120095. */
  120096. isStarted(): boolean;
  120097. /**
  120098. * Starts the particle system and begins to emit
  120099. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  120100. */
  120101. start(delay?: number): void;
  120102. /**
  120103. * Stops the particle system.
  120104. */
  120105. stop(): void;
  120106. /**
  120107. * Remove all active particles
  120108. */
  120109. reset(): void;
  120110. /**
  120111. * Returns the string "GPUParticleSystem"
  120112. * @returns a string containing the class name
  120113. */
  120114. getClassName(): string;
  120115. private _colorGradientsTexture;
  120116. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  120117. /**
  120118. * Adds a new color gradient
  120119. * @param gradient defines the gradient to use (between 0 and 1)
  120120. * @param color1 defines the color to affect to the specified gradient
  120121. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  120122. * @returns the current particle system
  120123. */
  120124. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  120125. /**
  120126. * Remove a specific color gradient
  120127. * @param gradient defines the gradient to remove
  120128. * @returns the current particle system
  120129. */
  120130. removeColorGradient(gradient: number): GPUParticleSystem;
  120131. private _angularSpeedGradientsTexture;
  120132. private _sizeGradientsTexture;
  120133. private _velocityGradientsTexture;
  120134. private _limitVelocityGradientsTexture;
  120135. private _dragGradientsTexture;
  120136. private _addFactorGradient;
  120137. /**
  120138. * Adds a new size gradient
  120139. * @param gradient defines the gradient to use (between 0 and 1)
  120140. * @param factor defines the size factor to affect to the specified gradient
  120141. * @returns the current particle system
  120142. */
  120143. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  120144. /**
  120145. * Remove a specific size gradient
  120146. * @param gradient defines the gradient to remove
  120147. * @returns the current particle system
  120148. */
  120149. removeSizeGradient(gradient: number): GPUParticleSystem;
  120150. /**
  120151. * Adds a new angular speed gradient
  120152. * @param gradient defines the gradient to use (between 0 and 1)
  120153. * @param factor defines the angular speed to affect to the specified gradient
  120154. * @returns the current particle system
  120155. */
  120156. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  120157. /**
  120158. * Remove a specific angular speed gradient
  120159. * @param gradient defines the gradient to remove
  120160. * @returns the current particle system
  120161. */
  120162. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  120163. /**
  120164. * Adds a new velocity gradient
  120165. * @param gradient defines the gradient to use (between 0 and 1)
  120166. * @param factor defines the velocity to affect to the specified gradient
  120167. * @returns the current particle system
  120168. */
  120169. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  120170. /**
  120171. * Remove a specific velocity gradient
  120172. * @param gradient defines the gradient to remove
  120173. * @returns the current particle system
  120174. */
  120175. removeVelocityGradient(gradient: number): GPUParticleSystem;
  120176. /**
  120177. * Adds a new limit velocity gradient
  120178. * @param gradient defines the gradient to use (between 0 and 1)
  120179. * @param factor defines the limit velocity value to affect to the specified gradient
  120180. * @returns the current particle system
  120181. */
  120182. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  120183. /**
  120184. * Remove a specific limit velocity gradient
  120185. * @param gradient defines the gradient to remove
  120186. * @returns the current particle system
  120187. */
  120188. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  120189. /**
  120190. * Adds a new drag gradient
  120191. * @param gradient defines the gradient to use (between 0 and 1)
  120192. * @param factor defines the drag value to affect to the specified gradient
  120193. * @returns the current particle system
  120194. */
  120195. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  120196. /**
  120197. * Remove a specific drag gradient
  120198. * @param gradient defines the gradient to remove
  120199. * @returns the current particle system
  120200. */
  120201. removeDragGradient(gradient: number): GPUParticleSystem;
  120202. /**
  120203. * Not supported by GPUParticleSystem
  120204. * @param gradient defines the gradient to use (between 0 and 1)
  120205. * @param factor defines the emit rate value to affect to the specified gradient
  120206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120207. * @returns the current particle system
  120208. */
  120209. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120210. /**
  120211. * Not supported by GPUParticleSystem
  120212. * @param gradient defines the gradient to remove
  120213. * @returns the current particle system
  120214. */
  120215. removeEmitRateGradient(gradient: number): IParticleSystem;
  120216. /**
  120217. * Not supported by GPUParticleSystem
  120218. * @param gradient defines the gradient to use (between 0 and 1)
  120219. * @param factor defines the start size value to affect to the specified gradient
  120220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120221. * @returns the current particle system
  120222. */
  120223. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120224. /**
  120225. * Not supported by GPUParticleSystem
  120226. * @param gradient defines the gradient to remove
  120227. * @returns the current particle system
  120228. */
  120229. removeStartSizeGradient(gradient: number): IParticleSystem;
  120230. /**
  120231. * Not supported by GPUParticleSystem
  120232. * @param gradient defines the gradient to use (between 0 and 1)
  120233. * @param min defines the color remap minimal range
  120234. * @param max defines the color remap maximal range
  120235. * @returns the current particle system
  120236. */
  120237. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  120238. /**
  120239. * Not supported by GPUParticleSystem
  120240. * @param gradient defines the gradient to remove
  120241. * @returns the current particle system
  120242. */
  120243. removeColorRemapGradient(): IParticleSystem;
  120244. /**
  120245. * Not supported by GPUParticleSystem
  120246. * @param gradient defines the gradient to use (between 0 and 1)
  120247. * @param min defines the alpha remap minimal range
  120248. * @param max defines the alpha remap maximal range
  120249. * @returns the current particle system
  120250. */
  120251. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  120252. /**
  120253. * Not supported by GPUParticleSystem
  120254. * @param gradient defines the gradient to remove
  120255. * @returns the current particle system
  120256. */
  120257. removeAlphaRemapGradient(): IParticleSystem;
  120258. /**
  120259. * Not supported by GPUParticleSystem
  120260. * @param gradient defines the gradient to use (between 0 and 1)
  120261. * @param color defines the color to affect to the specified gradient
  120262. * @returns the current particle system
  120263. */
  120264. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  120265. /**
  120266. * Not supported by GPUParticleSystem
  120267. * @param gradient defines the gradient to remove
  120268. * @returns the current particle system
  120269. */
  120270. removeRampGradient(): IParticleSystem;
  120271. /**
  120272. * Not supported by GPUParticleSystem
  120273. * @returns the list of ramp gradients
  120274. */
  120275. getRampGradients(): Nullable<Array<Color3Gradient>>;
  120276. /**
  120277. * Not supported by GPUParticleSystem
  120278. * Gets or sets a boolean indicating that ramp gradients must be used
  120279. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  120280. */
  120281. useRampGradients: boolean;
  120282. /**
  120283. * Not supported by GPUParticleSystem
  120284. * @param gradient defines the gradient to use (between 0 and 1)
  120285. * @param factor defines the life time factor to affect to the specified gradient
  120286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120287. * @returns the current particle system
  120288. */
  120289. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120290. /**
  120291. * Not supported by GPUParticleSystem
  120292. * @param gradient defines the gradient to remove
  120293. * @returns the current particle system
  120294. */
  120295. removeLifeTimeGradient(gradient: number): IParticleSystem;
  120296. /**
  120297. * Instantiates a GPU particle system.
  120298. * 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.
  120299. * @param name The name of the particle system
  120300. * @param options The options used to create the system
  120301. * @param scene The scene the particle system belongs to
  120302. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  120303. */
  120304. constructor(name: string, options: Partial<{
  120305. capacity: number;
  120306. randomTextureSize: number;
  120307. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  120308. protected _reset(): void;
  120309. private _createUpdateVAO;
  120310. private _createRenderVAO;
  120311. private _initialize;
  120312. /** @hidden */
  120313. _recreateUpdateEffect(): void;
  120314. /** @hidden */
  120315. _recreateRenderEffect(): void;
  120316. /**
  120317. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  120318. * @param preWarm defines if we are in the pre-warmimg phase
  120319. */
  120320. animate(preWarm?: boolean): void;
  120321. private _createFactorGradientTexture;
  120322. private _createSizeGradientTexture;
  120323. private _createAngularSpeedGradientTexture;
  120324. private _createVelocityGradientTexture;
  120325. private _createLimitVelocityGradientTexture;
  120326. private _createDragGradientTexture;
  120327. private _createColorGradientTexture;
  120328. /**
  120329. * Renders the particle system in its current state
  120330. * @param preWarm defines if the system should only update the particles but not render them
  120331. * @returns the current number of particles
  120332. */
  120333. render(preWarm?: boolean): number;
  120334. /**
  120335. * Rebuilds the particle system
  120336. */
  120337. rebuild(): void;
  120338. private _releaseBuffers;
  120339. private _releaseVAOs;
  120340. /**
  120341. * Disposes the particle system and free the associated resources
  120342. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  120343. */
  120344. dispose(disposeTexture?: boolean): void;
  120345. /**
  120346. * Clones the particle system.
  120347. * @param name The name of the cloned object
  120348. * @param newEmitter The new emitter to use
  120349. * @returns the cloned particle system
  120350. */
  120351. clone(name: string, newEmitter: any): GPUParticleSystem;
  120352. /**
  120353. * Serializes the particle system to a JSON object.
  120354. * @returns the JSON object
  120355. */
  120356. serialize(): any;
  120357. /**
  120358. * Parses a JSON object to create a GPU particle system.
  120359. * @param parsedParticleSystem The JSON object to parse
  120360. * @param scene The scene to create the particle system in
  120361. * @param rootUrl The root url to use to load external dependencies like texture
  120362. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  120363. * @returns the parsed GPU particle system
  120364. */
  120365. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  120366. }
  120367. }
  120368. declare module BABYLON {
  120369. /**
  120370. * Represents a set of particle systems working together to create a specific effect
  120371. */
  120372. export class ParticleSystemSet implements IDisposable {
  120373. private _emitterCreationOptions;
  120374. private _emitterNode;
  120375. /**
  120376. * Gets the particle system list
  120377. */
  120378. systems: IParticleSystem[];
  120379. /**
  120380. * Gets the emitter node used with this set
  120381. */
  120382. readonly emitterNode: Nullable<TransformNode>;
  120383. /**
  120384. * Creates a new emitter mesh as a sphere
  120385. * @param options defines the options used to create the sphere
  120386. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  120387. * @param scene defines the hosting scene
  120388. */
  120389. setEmitterAsSphere(options: {
  120390. diameter: number;
  120391. segments: number;
  120392. color: Color3;
  120393. }, renderingGroupId: number, scene: Scene): void;
  120394. /**
  120395. * Starts all particle systems of the set
  120396. * @param emitter defines an optional mesh to use as emitter for the particle systems
  120397. */
  120398. start(emitter?: AbstractMesh): void;
  120399. /**
  120400. * Release all associated resources
  120401. */
  120402. dispose(): void;
  120403. /**
  120404. * Serialize the set into a JSON compatible object
  120405. * @returns a JSON compatible representation of the set
  120406. */
  120407. serialize(): any;
  120408. /**
  120409. * Parse a new ParticleSystemSet from a serialized source
  120410. * @param data defines a JSON compatible representation of the set
  120411. * @param scene defines the hosting scene
  120412. * @param gpu defines if we want GPU particles or CPU particles
  120413. * @returns a new ParticleSystemSet
  120414. */
  120415. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  120416. }
  120417. }
  120418. declare module BABYLON {
  120419. /**
  120420. * This class is made for on one-liner static method to help creating particle system set.
  120421. */
  120422. export class ParticleHelper {
  120423. /**
  120424. * Gets or sets base Assets URL
  120425. */
  120426. static BaseAssetsUrl: string;
  120427. /**
  120428. * Create a default particle system that you can tweak
  120429. * @param emitter defines the emitter to use
  120430. * @param capacity defines the system capacity (default is 500 particles)
  120431. * @param scene defines the hosting scene
  120432. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  120433. * @returns the new Particle system
  120434. */
  120435. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  120436. /**
  120437. * This is the main static method (one-liner) of this helper to create different particle systems
  120438. * @param type This string represents the type to the particle system to create
  120439. * @param scene The scene where the particle system should live
  120440. * @param gpu If the system will use gpu
  120441. * @returns the ParticleSystemSet created
  120442. */
  120443. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  120444. /**
  120445. * Static function used to export a particle system to a ParticleSystemSet variable.
  120446. * Please note that the emitter shape is not exported
  120447. * @param systems defines the particle systems to export
  120448. * @returns the created particle system set
  120449. */
  120450. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  120451. }
  120452. }
  120453. declare module BABYLON {
  120454. interface Engine {
  120455. /**
  120456. * Create an effect to use with particle systems.
  120457. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  120458. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  120459. * @param uniformsNames defines a list of attribute names
  120460. * @param samplers defines an array of string used to represent textures
  120461. * @param defines defines the string containing the defines to use to compile the shaders
  120462. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120463. * @param onCompiled defines a function to call when the effect creation is successful
  120464. * @param onError defines a function to call when the effect creation has failed
  120465. * @returns the new Effect
  120466. */
  120467. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  120468. }
  120469. interface Mesh {
  120470. /**
  120471. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  120472. * @returns an array of IParticleSystem
  120473. */
  120474. getEmittedParticleSystems(): IParticleSystem[];
  120475. /**
  120476. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  120477. * @returns an array of IParticleSystem
  120478. */
  120479. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  120480. }
  120481. /**
  120482. * @hidden
  120483. */
  120484. export var _IDoNeedToBeInTheBuild: number;
  120485. }
  120486. declare module BABYLON {
  120487. interface Scene {
  120488. /** @hidden (Backing field) */
  120489. _physicsEngine: Nullable<IPhysicsEngine>;
  120490. /**
  120491. * Gets the current physics engine
  120492. * @returns a IPhysicsEngine or null if none attached
  120493. */
  120494. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  120495. /**
  120496. * Enables physics to the current scene
  120497. * @param gravity defines the scene's gravity for the physics engine
  120498. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  120499. * @return a boolean indicating if the physics engine was initialized
  120500. */
  120501. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  120502. /**
  120503. * Disables and disposes the physics engine associated with the scene
  120504. */
  120505. disablePhysicsEngine(): void;
  120506. /**
  120507. * Gets a boolean indicating if there is an active physics engine
  120508. * @returns a boolean indicating if there is an active physics engine
  120509. */
  120510. isPhysicsEnabled(): boolean;
  120511. /**
  120512. * Deletes a physics compound impostor
  120513. * @param compound defines the compound to delete
  120514. */
  120515. deleteCompoundImpostor(compound: any): void;
  120516. /**
  120517. * An event triggered when physic simulation is about to be run
  120518. */
  120519. onBeforePhysicsObservable: Observable<Scene>;
  120520. /**
  120521. * An event triggered when physic simulation has been done
  120522. */
  120523. onAfterPhysicsObservable: Observable<Scene>;
  120524. }
  120525. interface AbstractMesh {
  120526. /** @hidden */
  120527. _physicsImpostor: Nullable<PhysicsImpostor>;
  120528. /**
  120529. * Gets or sets impostor used for physic simulation
  120530. * @see http://doc.babylonjs.com/features/physics_engine
  120531. */
  120532. physicsImpostor: Nullable<PhysicsImpostor>;
  120533. /**
  120534. * Gets the current physics impostor
  120535. * @see http://doc.babylonjs.com/features/physics_engine
  120536. * @returns a physics impostor or null
  120537. */
  120538. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  120539. /** Apply a physic impulse to the mesh
  120540. * @param force defines the force to apply
  120541. * @param contactPoint defines where to apply the force
  120542. * @returns the current mesh
  120543. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120544. */
  120545. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  120546. /**
  120547. * Creates a physic joint between two meshes
  120548. * @param otherMesh defines the other mesh to use
  120549. * @param pivot1 defines the pivot to use on this mesh
  120550. * @param pivot2 defines the pivot to use on the other mesh
  120551. * @param options defines additional options (can be plugin dependent)
  120552. * @returns the current mesh
  120553. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  120554. */
  120555. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  120556. /** @hidden */
  120557. _disposePhysicsObserver: Nullable<Observer<Node>>;
  120558. }
  120559. /**
  120560. * Defines the physics engine scene component responsible to manage a physics engine
  120561. */
  120562. export class PhysicsEngineSceneComponent implements ISceneComponent {
  120563. /**
  120564. * The component name helpful to identify the component in the list of scene components.
  120565. */
  120566. readonly name: string;
  120567. /**
  120568. * The scene the component belongs to.
  120569. */
  120570. scene: Scene;
  120571. /**
  120572. * Creates a new instance of the component for the given scene
  120573. * @param scene Defines the scene to register the component in
  120574. */
  120575. constructor(scene: Scene);
  120576. /**
  120577. * Registers the component in a given scene
  120578. */
  120579. register(): void;
  120580. /**
  120581. * Rebuilds the elements related to this component in case of
  120582. * context lost for instance.
  120583. */
  120584. rebuild(): void;
  120585. /**
  120586. * Disposes the component and the associated ressources
  120587. */
  120588. dispose(): void;
  120589. }
  120590. }
  120591. declare module BABYLON {
  120592. /**
  120593. * A helper for physics simulations
  120594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120595. */
  120596. export class PhysicsHelper {
  120597. private _scene;
  120598. private _physicsEngine;
  120599. /**
  120600. * Initializes the Physics helper
  120601. * @param scene Babylon.js scene
  120602. */
  120603. constructor(scene: Scene);
  120604. /**
  120605. * Applies a radial explosion impulse
  120606. * @param origin the origin of the explosion
  120607. * @param radiusOrEventOptions the radius or the options of radial explosion
  120608. * @param strength the explosion strength
  120609. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120610. * @returns A physics radial explosion event, or null
  120611. */
  120612. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  120613. /**
  120614. * Applies a radial explosion force
  120615. * @param origin the origin of the explosion
  120616. * @param radiusOrEventOptions the radius or the options of radial explosion
  120617. * @param strength the explosion strength
  120618. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120619. * @returns A physics radial explosion event, or null
  120620. */
  120621. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  120622. /**
  120623. * Creates a gravitational field
  120624. * @param origin the origin of the explosion
  120625. * @param radiusOrEventOptions the radius or the options of radial explosion
  120626. * @param strength the explosion strength
  120627. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120628. * @returns A physics gravitational field event, or null
  120629. */
  120630. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  120631. /**
  120632. * Creates a physics updraft event
  120633. * @param origin the origin of the updraft
  120634. * @param radiusOrEventOptions the radius or the options of the updraft
  120635. * @param strength the strength of the updraft
  120636. * @param height the height of the updraft
  120637. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  120638. * @returns A physics updraft event, or null
  120639. */
  120640. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  120641. /**
  120642. * Creates a physics vortex event
  120643. * @param origin the of the vortex
  120644. * @param radiusOrEventOptions the radius or the options of the vortex
  120645. * @param strength the strength of the vortex
  120646. * @param height the height of the vortex
  120647. * @returns a Physics vortex event, or null
  120648. * A physics vortex event or null
  120649. */
  120650. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  120651. }
  120652. /**
  120653. * Represents a physics radial explosion event
  120654. */
  120655. class PhysicsRadialExplosionEvent {
  120656. private _scene;
  120657. private _options;
  120658. private _sphere;
  120659. private _dataFetched;
  120660. /**
  120661. * Initializes a radial explosioin event
  120662. * @param _scene BabylonJS scene
  120663. * @param _options The options for the vortex event
  120664. */
  120665. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  120666. /**
  120667. * Returns the data related to the radial explosion event (sphere).
  120668. * @returns The radial explosion event data
  120669. */
  120670. getData(): PhysicsRadialExplosionEventData;
  120671. /**
  120672. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  120673. * @param impostor A physics imposter
  120674. * @param origin the origin of the explosion
  120675. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  120676. */
  120677. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  120678. /**
  120679. * Triggers affecterd impostors callbacks
  120680. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  120681. */
  120682. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  120683. /**
  120684. * Disposes the sphere.
  120685. * @param force Specifies if the sphere should be disposed by force
  120686. */
  120687. dispose(force?: boolean): void;
  120688. /*** Helpers ***/
  120689. private _prepareSphere;
  120690. private _intersectsWithSphere;
  120691. }
  120692. /**
  120693. * Represents a gravitational field event
  120694. */
  120695. class PhysicsGravitationalFieldEvent {
  120696. private _physicsHelper;
  120697. private _scene;
  120698. private _origin;
  120699. private _options;
  120700. private _tickCallback;
  120701. private _sphere;
  120702. private _dataFetched;
  120703. /**
  120704. * Initializes the physics gravitational field event
  120705. * @param _physicsHelper A physics helper
  120706. * @param _scene BabylonJS scene
  120707. * @param _origin The origin position of the gravitational field event
  120708. * @param _options The options for the vortex event
  120709. */
  120710. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  120711. /**
  120712. * Returns the data related to the gravitational field event (sphere).
  120713. * @returns A gravitational field event
  120714. */
  120715. getData(): PhysicsGravitationalFieldEventData;
  120716. /**
  120717. * Enables the gravitational field.
  120718. */
  120719. enable(): void;
  120720. /**
  120721. * Disables the gravitational field.
  120722. */
  120723. disable(): void;
  120724. /**
  120725. * Disposes the sphere.
  120726. * @param force The force to dispose from the gravitational field event
  120727. */
  120728. dispose(force?: boolean): void;
  120729. private _tick;
  120730. }
  120731. /**
  120732. * Represents a physics updraft event
  120733. */
  120734. class PhysicsUpdraftEvent {
  120735. private _scene;
  120736. private _origin;
  120737. private _options;
  120738. private _physicsEngine;
  120739. private _originTop;
  120740. private _originDirection;
  120741. private _tickCallback;
  120742. private _cylinder;
  120743. private _cylinderPosition;
  120744. private _dataFetched;
  120745. /**
  120746. * Initializes the physics updraft event
  120747. * @param _scene BabylonJS scene
  120748. * @param _origin The origin position of the updraft
  120749. * @param _options The options for the updraft event
  120750. */
  120751. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  120752. /**
  120753. * Returns the data related to the updraft event (cylinder).
  120754. * @returns A physics updraft event
  120755. */
  120756. getData(): PhysicsUpdraftEventData;
  120757. /**
  120758. * Enables the updraft.
  120759. */
  120760. enable(): void;
  120761. /**
  120762. * Disables the updraft.
  120763. */
  120764. disable(): void;
  120765. /**
  120766. * Disposes the cylinder.
  120767. * @param force Specifies if the updraft should be disposed by force
  120768. */
  120769. dispose(force?: boolean): void;
  120770. private getImpostorHitData;
  120771. private _tick;
  120772. /*** Helpers ***/
  120773. private _prepareCylinder;
  120774. private _intersectsWithCylinder;
  120775. }
  120776. /**
  120777. * Represents a physics vortex event
  120778. */
  120779. class PhysicsVortexEvent {
  120780. private _scene;
  120781. private _origin;
  120782. private _options;
  120783. private _physicsEngine;
  120784. private _originTop;
  120785. private _tickCallback;
  120786. private _cylinder;
  120787. private _cylinderPosition;
  120788. private _dataFetched;
  120789. /**
  120790. * Initializes the physics vortex event
  120791. * @param _scene The BabylonJS scene
  120792. * @param _origin The origin position of the vortex
  120793. * @param _options The options for the vortex event
  120794. */
  120795. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  120796. /**
  120797. * Returns the data related to the vortex event (cylinder).
  120798. * @returns The physics vortex event data
  120799. */
  120800. getData(): PhysicsVortexEventData;
  120801. /**
  120802. * Enables the vortex.
  120803. */
  120804. enable(): void;
  120805. /**
  120806. * Disables the cortex.
  120807. */
  120808. disable(): void;
  120809. /**
  120810. * Disposes the sphere.
  120811. * @param force
  120812. */
  120813. dispose(force?: boolean): void;
  120814. private getImpostorHitData;
  120815. private _tick;
  120816. /*** Helpers ***/
  120817. private _prepareCylinder;
  120818. private _intersectsWithCylinder;
  120819. }
  120820. /**
  120821. * Options fot the radial explosion event
  120822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120823. */
  120824. export class PhysicsRadialExplosionEventOptions {
  120825. /**
  120826. * The radius of the sphere for the radial explosion.
  120827. */
  120828. radius: number;
  120829. /**
  120830. * The strenth of the explosion.
  120831. */
  120832. strength: number;
  120833. /**
  120834. * The strenght of the force in correspondence to the distance of the affected object
  120835. */
  120836. falloff: PhysicsRadialImpulseFalloff;
  120837. /**
  120838. * Sphere options for the radial explosion.
  120839. */
  120840. sphere: {
  120841. segments: number;
  120842. diameter: number;
  120843. };
  120844. /**
  120845. * Sphere options for the radial explosion.
  120846. */
  120847. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  120848. }
  120849. /**
  120850. * Options fot the updraft event
  120851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120852. */
  120853. export class PhysicsUpdraftEventOptions {
  120854. /**
  120855. * The radius of the cylinder for the vortex
  120856. */
  120857. radius: number;
  120858. /**
  120859. * The strenth of the updraft.
  120860. */
  120861. strength: number;
  120862. /**
  120863. * The height of the cylinder for the updraft.
  120864. */
  120865. height: number;
  120866. /**
  120867. * The mode for the the updraft.
  120868. */
  120869. updraftMode: PhysicsUpdraftMode;
  120870. }
  120871. /**
  120872. * Options fot the vortex event
  120873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120874. */
  120875. export class PhysicsVortexEventOptions {
  120876. /**
  120877. * The radius of the cylinder for the vortex
  120878. */
  120879. radius: number;
  120880. /**
  120881. * The strenth of the vortex.
  120882. */
  120883. strength: number;
  120884. /**
  120885. * The height of the cylinder for the vortex.
  120886. */
  120887. height: number;
  120888. /**
  120889. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  120890. */
  120891. centripetalForceThreshold: number;
  120892. /**
  120893. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  120894. */
  120895. centripetalForceMultiplier: number;
  120896. /**
  120897. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  120898. */
  120899. centrifugalForceMultiplier: number;
  120900. /**
  120901. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  120902. */
  120903. updraftForceMultiplier: number;
  120904. }
  120905. /**
  120906. * The strenght of the force in correspondence to the distance of the affected object
  120907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120908. */
  120909. export enum PhysicsRadialImpulseFalloff {
  120910. /** Defines that impulse is constant in strength across it's whole radius */
  120911. Constant = 0,
  120912. /** Defines that impulse gets weaker if it's further from the origin */
  120913. Linear = 1
  120914. }
  120915. /**
  120916. * The strength of the force in correspondence to the distance of the affected object
  120917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120918. */
  120919. export enum PhysicsUpdraftMode {
  120920. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  120921. Center = 0,
  120922. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  120923. Perpendicular = 1
  120924. }
  120925. /**
  120926. * Interface for a physics hit data
  120927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120928. */
  120929. export interface PhysicsHitData {
  120930. /**
  120931. * The force applied at the contact point
  120932. */
  120933. force: Vector3;
  120934. /**
  120935. * The contact point
  120936. */
  120937. contactPoint: Vector3;
  120938. /**
  120939. * The distance from the origin to the contact point
  120940. */
  120941. distanceFromOrigin: number;
  120942. }
  120943. /**
  120944. * Interface for radial explosion event data
  120945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120946. */
  120947. export interface PhysicsRadialExplosionEventData {
  120948. /**
  120949. * A sphere used for the radial explosion event
  120950. */
  120951. sphere: Mesh;
  120952. }
  120953. /**
  120954. * Interface for gravitational field event data
  120955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120956. */
  120957. export interface PhysicsGravitationalFieldEventData {
  120958. /**
  120959. * A sphere mesh used for the gravitational field event
  120960. */
  120961. sphere: Mesh;
  120962. }
  120963. /**
  120964. * Interface for updraft event data
  120965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120966. */
  120967. export interface PhysicsUpdraftEventData {
  120968. /**
  120969. * A cylinder used for the updraft event
  120970. */
  120971. cylinder: Mesh;
  120972. }
  120973. /**
  120974. * Interface for vortex event data
  120975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120976. */
  120977. export interface PhysicsVortexEventData {
  120978. /**
  120979. * A cylinder used for the vortex event
  120980. */
  120981. cylinder: Mesh;
  120982. }
  120983. /**
  120984. * Interface for an affected physics impostor
  120985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120986. */
  120987. export interface PhysicsAffectedImpostorWithData {
  120988. /**
  120989. * The impostor affected by the effect
  120990. */
  120991. impostor: PhysicsImpostor;
  120992. /**
  120993. * The data about the hit/horce from the explosion
  120994. */
  120995. hitData: PhysicsHitData;
  120996. }
  120997. }
  120998. declare module BABYLON {
  120999. /** @hidden */
  121000. export var blackAndWhitePixelShader: {
  121001. name: string;
  121002. shader: string;
  121003. };
  121004. }
  121005. declare module BABYLON {
  121006. /**
  121007. * Post process used to render in black and white
  121008. */
  121009. export class BlackAndWhitePostProcess extends PostProcess {
  121010. /**
  121011. * Linear about to convert he result to black and white (default: 1)
  121012. */
  121013. degree: number;
  121014. /**
  121015. * Creates a black and white post process
  121016. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  121017. * @param name The name of the effect.
  121018. * @param options The required width/height ratio to downsize to before computing the render pass.
  121019. * @param camera The camera to apply the render pass to.
  121020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121021. * @param engine The engine which the post process will be applied. (default: current engine)
  121022. * @param reusable If the post process can be reused on the same frame. (default: false)
  121023. */
  121024. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121025. }
  121026. }
  121027. declare module BABYLON {
  121028. /**
  121029. * This represents a set of one or more post processes in Babylon.
  121030. * A post process can be used to apply a shader to a texture after it is rendered.
  121031. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121032. */
  121033. export class PostProcessRenderEffect {
  121034. private _postProcesses;
  121035. private _getPostProcesses;
  121036. private _singleInstance;
  121037. private _cameras;
  121038. private _indicesForCamera;
  121039. /**
  121040. * Name of the effect
  121041. * @hidden
  121042. */
  121043. _name: string;
  121044. /**
  121045. * Instantiates a post process render effect.
  121046. * A post process can be used to apply a shader to a texture after it is rendered.
  121047. * @param engine The engine the effect is tied to
  121048. * @param name The name of the effect
  121049. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  121050. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  121051. */
  121052. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  121053. /**
  121054. * Checks if all the post processes in the effect are supported.
  121055. */
  121056. readonly isSupported: boolean;
  121057. /**
  121058. * Updates the current state of the effect
  121059. * @hidden
  121060. */
  121061. _update(): void;
  121062. /**
  121063. * Attaches the effect on cameras
  121064. * @param cameras The camera to attach to.
  121065. * @hidden
  121066. */
  121067. _attachCameras(cameras: Camera): void;
  121068. /**
  121069. * Attaches the effect on cameras
  121070. * @param cameras The camera to attach to.
  121071. * @hidden
  121072. */
  121073. _attachCameras(cameras: Camera[]): void;
  121074. /**
  121075. * Detaches the effect on cameras
  121076. * @param cameras The camera to detatch from.
  121077. * @hidden
  121078. */
  121079. _detachCameras(cameras: Camera): void;
  121080. /**
  121081. * Detatches the effect on cameras
  121082. * @param cameras The camera to detatch from.
  121083. * @hidden
  121084. */
  121085. _detachCameras(cameras: Camera[]): void;
  121086. /**
  121087. * Enables the effect on given cameras
  121088. * @param cameras The camera to enable.
  121089. * @hidden
  121090. */
  121091. _enable(cameras: Camera): void;
  121092. /**
  121093. * Enables the effect on given cameras
  121094. * @param cameras The camera to enable.
  121095. * @hidden
  121096. */
  121097. _enable(cameras: Nullable<Camera[]>): void;
  121098. /**
  121099. * Disables the effect on the given cameras
  121100. * @param cameras The camera to disable.
  121101. * @hidden
  121102. */
  121103. _disable(cameras: Camera): void;
  121104. /**
  121105. * Disables the effect on the given cameras
  121106. * @param cameras The camera to disable.
  121107. * @hidden
  121108. */
  121109. _disable(cameras: Nullable<Camera[]>): void;
  121110. /**
  121111. * Gets a list of the post processes contained in the effect.
  121112. * @param camera The camera to get the post processes on.
  121113. * @returns The list of the post processes in the effect.
  121114. */
  121115. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  121116. }
  121117. }
  121118. declare module BABYLON {
  121119. /** @hidden */
  121120. export var extractHighlightsPixelShader: {
  121121. name: string;
  121122. shader: string;
  121123. };
  121124. }
  121125. declare module BABYLON {
  121126. /**
  121127. * 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.
  121128. */
  121129. export class ExtractHighlightsPostProcess extends PostProcess {
  121130. /**
  121131. * The luminance threshold, pixels below this value will be set to black.
  121132. */
  121133. threshold: number;
  121134. /** @hidden */
  121135. _exposure: number;
  121136. /**
  121137. * Post process which has the input texture to be used when performing highlight extraction
  121138. * @hidden
  121139. */
  121140. _inputPostProcess: Nullable<PostProcess>;
  121141. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121142. }
  121143. }
  121144. declare module BABYLON {
  121145. /** @hidden */
  121146. export var bloomMergePixelShader: {
  121147. name: string;
  121148. shader: string;
  121149. };
  121150. }
  121151. declare module BABYLON {
  121152. /**
  121153. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121154. */
  121155. export class BloomMergePostProcess extends PostProcess {
  121156. /** Weight of the bloom to be added to the original input. */
  121157. weight: number;
  121158. /**
  121159. * Creates a new instance of @see BloomMergePostProcess
  121160. * @param name The name of the effect.
  121161. * @param originalFromInput Post process which's input will be used for the merge.
  121162. * @param blurred Blurred highlights post process which's output will be used.
  121163. * @param weight Weight of the bloom to be added to the original input.
  121164. * @param options The required width/height ratio to downsize to before computing the render pass.
  121165. * @param camera The camera to apply the render pass to.
  121166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121167. * @param engine The engine which the post process will be applied. (default: current engine)
  121168. * @param reusable If the post process can be reused on the same frame. (default: false)
  121169. * @param textureType Type of textures used when performing the post process. (default: 0)
  121170. * @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)
  121171. */
  121172. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  121173. /** Weight of the bloom to be added to the original input. */
  121174. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121175. }
  121176. }
  121177. declare module BABYLON {
  121178. /**
  121179. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  121180. */
  121181. export class BloomEffect extends PostProcessRenderEffect {
  121182. private bloomScale;
  121183. /**
  121184. * @hidden Internal
  121185. */
  121186. _effects: Array<PostProcess>;
  121187. /**
  121188. * @hidden Internal
  121189. */
  121190. _downscale: ExtractHighlightsPostProcess;
  121191. private _blurX;
  121192. private _blurY;
  121193. private _merge;
  121194. /**
  121195. * The luminance threshold to find bright areas of the image to bloom.
  121196. */
  121197. threshold: number;
  121198. /**
  121199. * The strength of the bloom.
  121200. */
  121201. weight: number;
  121202. /**
  121203. * Specifies the size of the bloom blur kernel, relative to the final output size
  121204. */
  121205. kernel: number;
  121206. /**
  121207. * Creates a new instance of @see BloomEffect
  121208. * @param scene The scene the effect belongs to.
  121209. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  121210. * @param bloomKernel The size of the kernel to be used when applying the blur.
  121211. * @param bloomWeight The the strength of bloom.
  121212. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121213. * @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)
  121214. */
  121215. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  121216. /**
  121217. * Disposes each of the internal effects for a given camera.
  121218. * @param camera The camera to dispose the effect on.
  121219. */
  121220. disposeEffects(camera: Camera): void;
  121221. /**
  121222. * @hidden Internal
  121223. */
  121224. _updateEffects(): void;
  121225. /**
  121226. * Internal
  121227. * @returns if all the contained post processes are ready.
  121228. * @hidden
  121229. */
  121230. _isReady(): boolean;
  121231. }
  121232. }
  121233. declare module BABYLON {
  121234. /** @hidden */
  121235. export var chromaticAberrationPixelShader: {
  121236. name: string;
  121237. shader: string;
  121238. };
  121239. }
  121240. declare module BABYLON {
  121241. /**
  121242. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  121243. */
  121244. export class ChromaticAberrationPostProcess extends PostProcess {
  121245. /**
  121246. * The amount of seperation of rgb channels (default: 30)
  121247. */
  121248. aberrationAmount: number;
  121249. /**
  121250. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  121251. */
  121252. radialIntensity: number;
  121253. /**
  121254. * 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))
  121255. */
  121256. direction: Vector2;
  121257. /**
  121258. * 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))
  121259. */
  121260. centerPosition: Vector2;
  121261. /**
  121262. * Creates a new instance ChromaticAberrationPostProcess
  121263. * @param name The name of the effect.
  121264. * @param screenWidth The width of the screen to apply the effect on.
  121265. * @param screenHeight The height of the screen to apply the effect on.
  121266. * @param options The required width/height ratio to downsize to before computing the render pass.
  121267. * @param camera The camera to apply the render pass to.
  121268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121269. * @param engine The engine which the post process will be applied. (default: current engine)
  121270. * @param reusable If the post process can be reused on the same frame. (default: false)
  121271. * @param textureType Type of textures used when performing the post process. (default: 0)
  121272. * @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)
  121273. */
  121274. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121275. }
  121276. }
  121277. declare module BABYLON {
  121278. /** @hidden */
  121279. export var circleOfConfusionPixelShader: {
  121280. name: string;
  121281. shader: string;
  121282. };
  121283. }
  121284. declare module BABYLON {
  121285. /**
  121286. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  121287. */
  121288. export class CircleOfConfusionPostProcess extends PostProcess {
  121289. /**
  121290. * 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.
  121291. */
  121292. lensSize: number;
  121293. /**
  121294. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121295. */
  121296. fStop: number;
  121297. /**
  121298. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121299. */
  121300. focusDistance: number;
  121301. /**
  121302. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  121303. */
  121304. focalLength: number;
  121305. private _depthTexture;
  121306. /**
  121307. * Creates a new instance CircleOfConfusionPostProcess
  121308. * @param name The name of the effect.
  121309. * @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.
  121310. * @param options The required width/height ratio to downsize to before computing the render pass.
  121311. * @param camera The camera to apply the render pass to.
  121312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121313. * @param engine The engine which the post process will be applied. (default: current engine)
  121314. * @param reusable If the post process can be reused on the same frame. (default: false)
  121315. * @param textureType Type of textures used when performing the post process. (default: 0)
  121316. * @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)
  121317. */
  121318. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121319. /**
  121320. * 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.
  121321. */
  121322. depthTexture: RenderTargetTexture;
  121323. }
  121324. }
  121325. declare module BABYLON {
  121326. /** @hidden */
  121327. export var colorCorrectionPixelShader: {
  121328. name: string;
  121329. shader: string;
  121330. };
  121331. }
  121332. declare module BABYLON {
  121333. /**
  121334. *
  121335. * This post-process allows the modification of rendered colors by using
  121336. * a 'look-up table' (LUT). This effect is also called Color Grading.
  121337. *
  121338. * The object needs to be provided an url to a texture containing the color
  121339. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  121340. * Use an image editing software to tweak the LUT to match your needs.
  121341. *
  121342. * For an example of a color LUT, see here:
  121343. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  121344. * For explanations on color grading, see here:
  121345. * @see http://udn.epicgames.com/Three/ColorGrading.html
  121346. *
  121347. */
  121348. export class ColorCorrectionPostProcess extends PostProcess {
  121349. private _colorTableTexture;
  121350. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121351. }
  121352. }
  121353. declare module BABYLON {
  121354. /** @hidden */
  121355. export var convolutionPixelShader: {
  121356. name: string;
  121357. shader: string;
  121358. };
  121359. }
  121360. declare module BABYLON {
  121361. /**
  121362. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  121363. * input texture to perform effects such as edge detection or sharpening
  121364. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121365. */
  121366. export class ConvolutionPostProcess extends PostProcess {
  121367. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121368. kernel: number[];
  121369. /**
  121370. * Creates a new instance ConvolutionPostProcess
  121371. * @param name The name of the effect.
  121372. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  121373. * @param options The required width/height ratio to downsize to before computing the render pass.
  121374. * @param camera The camera to apply the render pass to.
  121375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121376. * @param engine The engine which the post process will be applied. (default: current engine)
  121377. * @param reusable If the post process can be reused on the same frame. (default: false)
  121378. * @param textureType Type of textures used when performing the post process. (default: 0)
  121379. */
  121380. constructor(name: string,
  121381. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121382. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121383. /**
  121384. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121385. */
  121386. static EdgeDetect0Kernel: number[];
  121387. /**
  121388. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121389. */
  121390. static EdgeDetect1Kernel: number[];
  121391. /**
  121392. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121393. */
  121394. static EdgeDetect2Kernel: number[];
  121395. /**
  121396. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121397. */
  121398. static SharpenKernel: number[];
  121399. /**
  121400. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121401. */
  121402. static EmbossKernel: number[];
  121403. /**
  121404. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121405. */
  121406. static GaussianKernel: number[];
  121407. }
  121408. }
  121409. declare module BABYLON {
  121410. /**
  121411. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  121412. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  121413. * based on samples that have a large difference in distance than the center pixel.
  121414. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  121415. */
  121416. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  121417. direction: Vector2;
  121418. /**
  121419. * Creates a new instance CircleOfConfusionPostProcess
  121420. * @param name The name of the effect.
  121421. * @param scene The scene the effect belongs to.
  121422. * @param direction The direction the blur should be applied.
  121423. * @param kernel The size of the kernel used to blur.
  121424. * @param options The required width/height ratio to downsize to before computing the render pass.
  121425. * @param camera The camera to apply the render pass to.
  121426. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  121427. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  121428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121429. * @param engine The engine which the post process will be applied. (default: current engine)
  121430. * @param reusable If the post process can be reused on the same frame. (default: false)
  121431. * @param textureType Type of textures used when performing the post process. (default: 0)
  121432. * @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)
  121433. */
  121434. 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);
  121435. }
  121436. }
  121437. declare module BABYLON {
  121438. /** @hidden */
  121439. export var depthOfFieldMergePixelShader: {
  121440. name: string;
  121441. shader: string;
  121442. };
  121443. }
  121444. declare module BABYLON {
  121445. /**
  121446. * Options to be set when merging outputs from the default pipeline.
  121447. */
  121448. export class DepthOfFieldMergePostProcessOptions {
  121449. /**
  121450. * The original image to merge on top of
  121451. */
  121452. originalFromInput: PostProcess;
  121453. /**
  121454. * Parameters to perform the merge of the depth of field effect
  121455. */
  121456. depthOfField?: {
  121457. circleOfConfusion: PostProcess;
  121458. blurSteps: Array<PostProcess>;
  121459. };
  121460. /**
  121461. * Parameters to perform the merge of bloom effect
  121462. */
  121463. bloom?: {
  121464. blurred: PostProcess;
  121465. weight: number;
  121466. };
  121467. }
  121468. /**
  121469. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121470. */
  121471. export class DepthOfFieldMergePostProcess extends PostProcess {
  121472. private blurSteps;
  121473. /**
  121474. * Creates a new instance of DepthOfFieldMergePostProcess
  121475. * @param name The name of the effect.
  121476. * @param originalFromInput Post process which's input will be used for the merge.
  121477. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  121478. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  121479. * @param options The required width/height ratio to downsize to before computing the render pass.
  121480. * @param camera The camera to apply the render pass to.
  121481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121482. * @param engine The engine which the post process will be applied. (default: current engine)
  121483. * @param reusable If the post process can be reused on the same frame. (default: false)
  121484. * @param textureType Type of textures used when performing the post process. (default: 0)
  121485. * @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)
  121486. */
  121487. 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);
  121488. /**
  121489. * Updates the effect with the current post process compile time values and recompiles the shader.
  121490. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  121491. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  121492. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  121493. * @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
  121494. * @param onCompiled Called when the shader has been compiled.
  121495. * @param onError Called if there is an error when compiling a shader.
  121496. */
  121497. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  121498. }
  121499. }
  121500. declare module BABYLON {
  121501. /**
  121502. * Specifies the level of max blur that should be applied when using the depth of field effect
  121503. */
  121504. export enum DepthOfFieldEffectBlurLevel {
  121505. /**
  121506. * Subtle blur
  121507. */
  121508. Low = 0,
  121509. /**
  121510. * Medium blur
  121511. */
  121512. Medium = 1,
  121513. /**
  121514. * Large blur
  121515. */
  121516. High = 2
  121517. }
  121518. /**
  121519. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  121520. */
  121521. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  121522. private _circleOfConfusion;
  121523. /**
  121524. * @hidden Internal, blurs from high to low
  121525. */
  121526. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  121527. private _depthOfFieldBlurY;
  121528. private _dofMerge;
  121529. /**
  121530. * @hidden Internal post processes in depth of field effect
  121531. */
  121532. _effects: Array<PostProcess>;
  121533. /**
  121534. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  121535. */
  121536. focalLength: number;
  121537. /**
  121538. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121539. */
  121540. fStop: number;
  121541. /**
  121542. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121543. */
  121544. focusDistance: number;
  121545. /**
  121546. * 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.
  121547. */
  121548. lensSize: number;
  121549. /**
  121550. * Creates a new instance DepthOfFieldEffect
  121551. * @param scene The scene the effect belongs to.
  121552. * @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.
  121553. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121554. * @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)
  121555. */
  121556. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  121557. /**
  121558. * Get the current class name of the current effet
  121559. * @returns "DepthOfFieldEffect"
  121560. */
  121561. getClassName(): string;
  121562. /**
  121563. * 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.
  121564. */
  121565. depthTexture: RenderTargetTexture;
  121566. /**
  121567. * Disposes each of the internal effects for a given camera.
  121568. * @param camera The camera to dispose the effect on.
  121569. */
  121570. disposeEffects(camera: Camera): void;
  121571. /**
  121572. * @hidden Internal
  121573. */
  121574. _updateEffects(): void;
  121575. /**
  121576. * Internal
  121577. * @returns if all the contained post processes are ready.
  121578. * @hidden
  121579. */
  121580. _isReady(): boolean;
  121581. }
  121582. }
  121583. declare module BABYLON {
  121584. /** @hidden */
  121585. export var displayPassPixelShader: {
  121586. name: string;
  121587. shader: string;
  121588. };
  121589. }
  121590. declare module BABYLON {
  121591. /**
  121592. * DisplayPassPostProcess which produces an output the same as it's input
  121593. */
  121594. export class DisplayPassPostProcess extends PostProcess {
  121595. /**
  121596. * Creates the DisplayPassPostProcess
  121597. * @param name The name of the effect.
  121598. * @param options The required width/height ratio to downsize to before computing the render pass.
  121599. * @param camera The camera to apply the render pass to.
  121600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121601. * @param engine The engine which the post process will be applied. (default: current engine)
  121602. * @param reusable If the post process can be reused on the same frame. (default: false)
  121603. */
  121604. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121605. }
  121606. }
  121607. declare module BABYLON {
  121608. /** @hidden */
  121609. export var filterPixelShader: {
  121610. name: string;
  121611. shader: string;
  121612. };
  121613. }
  121614. declare module BABYLON {
  121615. /**
  121616. * Applies a kernel filter to the image
  121617. */
  121618. export class FilterPostProcess extends PostProcess {
  121619. /** The matrix to be applied to the image */
  121620. kernelMatrix: Matrix;
  121621. /**
  121622. *
  121623. * @param name The name of the effect.
  121624. * @param kernelMatrix The matrix to be applied to the image
  121625. * @param options The required width/height ratio to downsize to before computing the render pass.
  121626. * @param camera The camera to apply the render pass to.
  121627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121628. * @param engine The engine which the post process will be applied. (default: current engine)
  121629. * @param reusable If the post process can be reused on the same frame. (default: false)
  121630. */
  121631. constructor(name: string,
  121632. /** The matrix to be applied to the image */
  121633. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121634. }
  121635. }
  121636. declare module BABYLON {
  121637. /** @hidden */
  121638. export var fxaaPixelShader: {
  121639. name: string;
  121640. shader: string;
  121641. };
  121642. }
  121643. declare module BABYLON {
  121644. /** @hidden */
  121645. export var fxaaVertexShader: {
  121646. name: string;
  121647. shader: string;
  121648. };
  121649. }
  121650. declare module BABYLON {
  121651. /**
  121652. * Fxaa post process
  121653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  121654. */
  121655. export class FxaaPostProcess extends PostProcess {
  121656. /** @hidden */
  121657. texelWidth: number;
  121658. /** @hidden */
  121659. texelHeight: number;
  121660. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121661. private _getDefines;
  121662. }
  121663. }
  121664. declare module BABYLON {
  121665. /** @hidden */
  121666. export var grainPixelShader: {
  121667. name: string;
  121668. shader: string;
  121669. };
  121670. }
  121671. declare module BABYLON {
  121672. /**
  121673. * The GrainPostProcess adds noise to the image at mid luminance levels
  121674. */
  121675. export class GrainPostProcess extends PostProcess {
  121676. /**
  121677. * The intensity of the grain added (default: 30)
  121678. */
  121679. intensity: number;
  121680. /**
  121681. * If the grain should be randomized on every frame
  121682. */
  121683. animated: boolean;
  121684. /**
  121685. * Creates a new instance of @see GrainPostProcess
  121686. * @param name The name of the effect.
  121687. * @param options The required width/height ratio to downsize to before computing the render pass.
  121688. * @param camera The camera to apply the render pass to.
  121689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121690. * @param engine The engine which the post process will be applied. (default: current engine)
  121691. * @param reusable If the post process can be reused on the same frame. (default: false)
  121692. * @param textureType Type of textures used when performing the post process. (default: 0)
  121693. * @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)
  121694. */
  121695. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121696. }
  121697. }
  121698. declare module BABYLON {
  121699. /** @hidden */
  121700. export var highlightsPixelShader: {
  121701. name: string;
  121702. shader: string;
  121703. };
  121704. }
  121705. declare module BABYLON {
  121706. /**
  121707. * Extracts highlights from the image
  121708. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121709. */
  121710. export class HighlightsPostProcess extends PostProcess {
  121711. /**
  121712. * Extracts highlights from the image
  121713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121714. * @param name The name of the effect.
  121715. * @param options The required width/height ratio to downsize to before computing the render pass.
  121716. * @param camera The camera to apply the render pass to.
  121717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121718. * @param engine The engine which the post process will be applied. (default: current engine)
  121719. * @param reusable If the post process can be reused on the same frame. (default: false)
  121720. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  121721. */
  121722. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121723. }
  121724. }
  121725. declare module BABYLON {
  121726. /** @hidden */
  121727. export var mrtFragmentDeclaration: {
  121728. name: string;
  121729. shader: string;
  121730. };
  121731. }
  121732. declare module BABYLON {
  121733. /** @hidden */
  121734. export var geometryPixelShader: {
  121735. name: string;
  121736. shader: string;
  121737. };
  121738. }
  121739. declare module BABYLON {
  121740. /** @hidden */
  121741. export var geometryVertexShader: {
  121742. name: string;
  121743. shader: string;
  121744. };
  121745. }
  121746. declare module BABYLON {
  121747. /** @hidden */
  121748. interface ISavedTransformationMatrix {
  121749. world: Matrix;
  121750. viewProjection: Matrix;
  121751. }
  121752. /**
  121753. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  121754. */
  121755. export class GeometryBufferRenderer {
  121756. /**
  121757. * Constant used to retrieve the position texture index in the G-Buffer textures array
  121758. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  121759. */
  121760. static readonly POSITION_TEXTURE_TYPE: number;
  121761. /**
  121762. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  121763. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  121764. */
  121765. static readonly VELOCITY_TEXTURE_TYPE: number;
  121766. /**
  121767. * Dictionary used to store the previous transformation matrices of each rendered mesh
  121768. * in order to compute objects velocities when enableVelocity is set to "true"
  121769. * @hidden
  121770. */
  121771. _previousTransformationMatrices: {
  121772. [index: number]: ISavedTransformationMatrix;
  121773. };
  121774. /**
  121775. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  121776. * in order to compute objects velocities when enableVelocity is set to "true"
  121777. * @hidden
  121778. */
  121779. _previousBonesTransformationMatrices: {
  121780. [index: number]: Float32Array;
  121781. };
  121782. /**
  121783. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  121784. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  121785. */
  121786. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  121787. private _scene;
  121788. private _multiRenderTarget;
  121789. private _ratio;
  121790. private _enablePosition;
  121791. private _enableVelocity;
  121792. private _positionIndex;
  121793. private _velocityIndex;
  121794. protected _effect: Effect;
  121795. protected _cachedDefines: string;
  121796. /**
  121797. * Set the render list (meshes to be rendered) used in the G buffer.
  121798. */
  121799. renderList: Mesh[];
  121800. /**
  121801. * Gets wether or not G buffer are supported by the running hardware.
  121802. * This requires draw buffer supports
  121803. */
  121804. readonly isSupported: boolean;
  121805. /**
  121806. * Returns the index of the given texture type in the G-Buffer textures array
  121807. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  121808. * @returns the index of the given texture type in the G-Buffer textures array
  121809. */
  121810. getTextureIndex(textureType: number): number;
  121811. /**
  121812. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  121813. */
  121814. /**
  121815. * Sets whether or not objects positions are enabled for the G buffer.
  121816. */
  121817. enablePosition: boolean;
  121818. /**
  121819. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  121820. */
  121821. /**
  121822. * Sets wether or not objects velocities are enabled for the G buffer.
  121823. */
  121824. enableVelocity: boolean;
  121825. /**
  121826. * Gets the scene associated with the buffer.
  121827. */
  121828. readonly scene: Scene;
  121829. /**
  121830. * Gets the ratio used by the buffer during its creation.
  121831. * How big is the buffer related to the main canvas.
  121832. */
  121833. readonly ratio: number;
  121834. /** @hidden */
  121835. static _SceneComponentInitialization: (scene: Scene) => void;
  121836. /**
  121837. * Creates a new G Buffer for the scene
  121838. * @param scene The scene the buffer belongs to
  121839. * @param ratio How big is the buffer related to the main canvas.
  121840. */
  121841. constructor(scene: Scene, ratio?: number);
  121842. /**
  121843. * Checks wether everything is ready to render a submesh to the G buffer.
  121844. * @param subMesh the submesh to check readiness for
  121845. * @param useInstances is the mesh drawn using instance or not
  121846. * @returns true if ready otherwise false
  121847. */
  121848. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  121849. /**
  121850. * Gets the current underlying G Buffer.
  121851. * @returns the buffer
  121852. */
  121853. getGBuffer(): MultiRenderTarget;
  121854. /**
  121855. * Gets the number of samples used to render the buffer (anti aliasing).
  121856. */
  121857. /**
  121858. * Sets the number of samples used to render the buffer (anti aliasing).
  121859. */
  121860. samples: number;
  121861. /**
  121862. * Disposes the renderer and frees up associated resources.
  121863. */
  121864. dispose(): void;
  121865. protected _createRenderTargets(): void;
  121866. private _copyBonesTransformationMatrices;
  121867. }
  121868. }
  121869. declare module BABYLON {
  121870. interface Scene {
  121871. /** @hidden (Backing field) */
  121872. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  121873. /**
  121874. * Gets or Sets the current geometry buffer associated to the scene.
  121875. */
  121876. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  121877. /**
  121878. * Enables a GeometryBufferRender and associates it with the scene
  121879. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  121880. * @returns the GeometryBufferRenderer
  121881. */
  121882. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  121883. /**
  121884. * Disables the GeometryBufferRender associated with the scene
  121885. */
  121886. disableGeometryBufferRenderer(): void;
  121887. }
  121888. /**
  121889. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  121890. * in several rendering techniques.
  121891. */
  121892. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  121893. /**
  121894. * The component name helpful to identify the component in the list of scene components.
  121895. */
  121896. readonly name: string;
  121897. /**
  121898. * The scene the component belongs to.
  121899. */
  121900. scene: Scene;
  121901. /**
  121902. * Creates a new instance of the component for the given scene
  121903. * @param scene Defines the scene to register the component in
  121904. */
  121905. constructor(scene: Scene);
  121906. /**
  121907. * Registers the component in a given scene
  121908. */
  121909. register(): void;
  121910. /**
  121911. * Rebuilds the elements related to this component in case of
  121912. * context lost for instance.
  121913. */
  121914. rebuild(): void;
  121915. /**
  121916. * Disposes the component and the associated ressources
  121917. */
  121918. dispose(): void;
  121919. private _gatherRenderTargets;
  121920. }
  121921. }
  121922. declare module BABYLON {
  121923. /** @hidden */
  121924. export var motionBlurPixelShader: {
  121925. name: string;
  121926. shader: string;
  121927. };
  121928. }
  121929. declare module BABYLON {
  121930. /**
  121931. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  121932. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  121933. * As an example, all you have to do is to create the post-process:
  121934. * var mb = new BABYLON.MotionBlurPostProcess(
  121935. * 'mb', // The name of the effect.
  121936. * scene, // The scene containing the objects to blur according to their velocity.
  121937. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  121938. * camera // The camera to apply the render pass to.
  121939. * );
  121940. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  121941. */
  121942. export class MotionBlurPostProcess extends PostProcess {
  121943. /**
  121944. * Defines how much the image is blurred by the movement. Default value is equal to 1
  121945. */
  121946. motionStrength: number;
  121947. /**
  121948. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  121949. */
  121950. /**
  121951. * Sets the number of iterations to be used for motion blur quality
  121952. */
  121953. motionBlurSamples: number;
  121954. private _motionBlurSamples;
  121955. private _geometryBufferRenderer;
  121956. /**
  121957. * Creates a new instance MotionBlurPostProcess
  121958. * @param name The name of the effect.
  121959. * @param scene The scene containing the objects to blur according to their velocity.
  121960. * @param options The required width/height ratio to downsize to before computing the render pass.
  121961. * @param camera The camera to apply the render pass to.
  121962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121963. * @param engine The engine which the post process will be applied. (default: current engine)
  121964. * @param reusable If the post process can be reused on the same frame. (default: false)
  121965. * @param textureType Type of textures used when performing the post process. (default: 0)
  121966. * @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)
  121967. */
  121968. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121969. /**
  121970. * Excludes the given skinned mesh from computing bones velocities.
  121971. * 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.
  121972. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  121973. */
  121974. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121975. /**
  121976. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  121977. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  121978. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  121979. */
  121980. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121981. /**
  121982. * Disposes the post process.
  121983. * @param camera The camera to dispose the post process on.
  121984. */
  121985. dispose(camera?: Camera): void;
  121986. }
  121987. }
  121988. declare module BABYLON {
  121989. /** @hidden */
  121990. export var refractionPixelShader: {
  121991. name: string;
  121992. shader: string;
  121993. };
  121994. }
  121995. declare module BABYLON {
  121996. /**
  121997. * Post process which applies a refractin texture
  121998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121999. */
  122000. export class RefractionPostProcess extends PostProcess {
  122001. /** the base color of the refraction (used to taint the rendering) */
  122002. color: Color3;
  122003. /** simulated refraction depth */
  122004. depth: number;
  122005. /** the coefficient of the base color (0 to remove base color tainting) */
  122006. colorLevel: number;
  122007. private _refTexture;
  122008. private _ownRefractionTexture;
  122009. /**
  122010. * Gets or sets the refraction texture
  122011. * Please note that you are responsible for disposing the texture if you set it manually
  122012. */
  122013. refractionTexture: Texture;
  122014. /**
  122015. * Initializes the RefractionPostProcess
  122016. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  122017. * @param name The name of the effect.
  122018. * @param refractionTextureUrl Url of the refraction texture to use
  122019. * @param color the base color of the refraction (used to taint the rendering)
  122020. * @param depth simulated refraction depth
  122021. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  122022. * @param camera The camera to apply the render pass to.
  122023. * @param options The required width/height ratio to downsize to before computing the render pass.
  122024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122025. * @param engine The engine which the post process will be applied. (default: current engine)
  122026. * @param reusable If the post process can be reused on the same frame. (default: false)
  122027. */
  122028. constructor(name: string, refractionTextureUrl: string,
  122029. /** the base color of the refraction (used to taint the rendering) */
  122030. color: Color3,
  122031. /** simulated refraction depth */
  122032. depth: number,
  122033. /** the coefficient of the base color (0 to remove base color tainting) */
  122034. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122035. /**
  122036. * Disposes of the post process
  122037. * @param camera Camera to dispose post process on
  122038. */
  122039. dispose(camera: Camera): void;
  122040. }
  122041. }
  122042. declare module BABYLON {
  122043. /** @hidden */
  122044. export var sharpenPixelShader: {
  122045. name: string;
  122046. shader: string;
  122047. };
  122048. }
  122049. declare module BABYLON {
  122050. /**
  122051. * The SharpenPostProcess applies a sharpen kernel to every pixel
  122052. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  122053. */
  122054. export class SharpenPostProcess extends PostProcess {
  122055. /**
  122056. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  122057. */
  122058. colorAmount: number;
  122059. /**
  122060. * How much sharpness should be applied (default: 0.3)
  122061. */
  122062. edgeAmount: number;
  122063. /**
  122064. * Creates a new instance ConvolutionPostProcess
  122065. * @param name The name of the effect.
  122066. * @param options The required width/height ratio to downsize to before computing the render pass.
  122067. * @param camera The camera to apply the render pass to.
  122068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122069. * @param engine The engine which the post process will be applied. (default: current engine)
  122070. * @param reusable If the post process can be reused on the same frame. (default: false)
  122071. * @param textureType Type of textures used when performing the post process. (default: 0)
  122072. * @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)
  122073. */
  122074. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122075. }
  122076. }
  122077. declare module BABYLON {
  122078. /**
  122079. * PostProcessRenderPipeline
  122080. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122081. */
  122082. export class PostProcessRenderPipeline {
  122083. private engine;
  122084. private _renderEffects;
  122085. private _renderEffectsForIsolatedPass;
  122086. /**
  122087. * List of inspectable custom properties (used by the Inspector)
  122088. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  122089. */
  122090. inspectableCustomProperties: IInspectable[];
  122091. /**
  122092. * @hidden
  122093. */
  122094. protected _cameras: Camera[];
  122095. /** @hidden */
  122096. _name: string;
  122097. /**
  122098. * Gets pipeline name
  122099. */
  122100. readonly name: string;
  122101. /**
  122102. * Initializes a PostProcessRenderPipeline
  122103. * @param engine engine to add the pipeline to
  122104. * @param name name of the pipeline
  122105. */
  122106. constructor(engine: Engine, name: string);
  122107. /**
  122108. * Gets the class name
  122109. * @returns "PostProcessRenderPipeline"
  122110. */
  122111. getClassName(): string;
  122112. /**
  122113. * If all the render effects in the pipeline are supported
  122114. */
  122115. readonly isSupported: boolean;
  122116. /**
  122117. * Adds an effect to the pipeline
  122118. * @param renderEffect the effect to add
  122119. */
  122120. addEffect(renderEffect: PostProcessRenderEffect): void;
  122121. /** @hidden */
  122122. _rebuild(): void;
  122123. /** @hidden */
  122124. _enableEffect(renderEffectName: string, cameras: Camera): void;
  122125. /** @hidden */
  122126. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  122127. /** @hidden */
  122128. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  122129. /** @hidden */
  122130. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  122131. /** @hidden */
  122132. _attachCameras(cameras: Camera, unique: boolean): void;
  122133. /** @hidden */
  122134. _attachCameras(cameras: Camera[], unique: boolean): void;
  122135. /** @hidden */
  122136. _detachCameras(cameras: Camera): void;
  122137. /** @hidden */
  122138. _detachCameras(cameras: Nullable<Camera[]>): void;
  122139. /** @hidden */
  122140. _update(): void;
  122141. /** @hidden */
  122142. _reset(): void;
  122143. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  122144. /**
  122145. * Disposes of the pipeline
  122146. */
  122147. dispose(): void;
  122148. }
  122149. }
  122150. declare module BABYLON {
  122151. /**
  122152. * PostProcessRenderPipelineManager class
  122153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122154. */
  122155. export class PostProcessRenderPipelineManager {
  122156. private _renderPipelines;
  122157. /**
  122158. * Initializes a PostProcessRenderPipelineManager
  122159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122160. */
  122161. constructor();
  122162. /**
  122163. * Gets the list of supported render pipelines
  122164. */
  122165. readonly supportedPipelines: PostProcessRenderPipeline[];
  122166. /**
  122167. * Adds a pipeline to the manager
  122168. * @param renderPipeline The pipeline to add
  122169. */
  122170. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  122171. /**
  122172. * Attaches a camera to the pipeline
  122173. * @param renderPipelineName The name of the pipeline to attach to
  122174. * @param cameras the camera to attach
  122175. * @param unique if the camera can be attached multiple times to the pipeline
  122176. */
  122177. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  122178. /**
  122179. * Detaches a camera from the pipeline
  122180. * @param renderPipelineName The name of the pipeline to detach from
  122181. * @param cameras the camera to detach
  122182. */
  122183. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  122184. /**
  122185. * Enables an effect by name on a pipeline
  122186. * @param renderPipelineName the name of the pipeline to enable the effect in
  122187. * @param renderEffectName the name of the effect to enable
  122188. * @param cameras the cameras that the effect should be enabled on
  122189. */
  122190. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  122191. /**
  122192. * Disables an effect by name on a pipeline
  122193. * @param renderPipelineName the name of the pipeline to disable the effect in
  122194. * @param renderEffectName the name of the effect to disable
  122195. * @param cameras the cameras that the effect should be disabled on
  122196. */
  122197. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  122198. /**
  122199. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  122200. */
  122201. update(): void;
  122202. /** @hidden */
  122203. _rebuild(): void;
  122204. /**
  122205. * Disposes of the manager and pipelines
  122206. */
  122207. dispose(): void;
  122208. }
  122209. }
  122210. declare module BABYLON {
  122211. interface Scene {
  122212. /** @hidden (Backing field) */
  122213. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  122214. /**
  122215. * Gets the postprocess render pipeline manager
  122216. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122217. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  122218. */
  122219. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  122220. }
  122221. /**
  122222. * Defines the Render Pipeline scene component responsible to rendering pipelines
  122223. */
  122224. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  122225. /**
  122226. * The component name helpfull to identify the component in the list of scene components.
  122227. */
  122228. readonly name: string;
  122229. /**
  122230. * The scene the component belongs to.
  122231. */
  122232. scene: Scene;
  122233. /**
  122234. * Creates a new instance of the component for the given scene
  122235. * @param scene Defines the scene to register the component in
  122236. */
  122237. constructor(scene: Scene);
  122238. /**
  122239. * Registers the component in a given scene
  122240. */
  122241. register(): void;
  122242. /**
  122243. * Rebuilds the elements related to this component in case of
  122244. * context lost for instance.
  122245. */
  122246. rebuild(): void;
  122247. /**
  122248. * Disposes the component and the associated ressources
  122249. */
  122250. dispose(): void;
  122251. private _gatherRenderTargets;
  122252. }
  122253. }
  122254. declare module BABYLON {
  122255. /**
  122256. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  122257. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  122258. */
  122259. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  122260. private _scene;
  122261. private _camerasToBeAttached;
  122262. /**
  122263. * ID of the sharpen post process,
  122264. */
  122265. private readonly SharpenPostProcessId;
  122266. /**
  122267. * @ignore
  122268. * ID of the image processing post process;
  122269. */
  122270. readonly ImageProcessingPostProcessId: string;
  122271. /**
  122272. * @ignore
  122273. * ID of the Fast Approximate Anti-Aliasing post process;
  122274. */
  122275. readonly FxaaPostProcessId: string;
  122276. /**
  122277. * ID of the chromatic aberration post process,
  122278. */
  122279. private readonly ChromaticAberrationPostProcessId;
  122280. /**
  122281. * ID of the grain post process
  122282. */
  122283. private readonly GrainPostProcessId;
  122284. /**
  122285. * Sharpen post process which will apply a sharpen convolution to enhance edges
  122286. */
  122287. sharpen: SharpenPostProcess;
  122288. private _sharpenEffect;
  122289. private bloom;
  122290. /**
  122291. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  122292. */
  122293. depthOfField: DepthOfFieldEffect;
  122294. /**
  122295. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  122296. */
  122297. fxaa: FxaaPostProcess;
  122298. /**
  122299. * Image post processing pass used to perform operations such as tone mapping or color grading.
  122300. */
  122301. imageProcessing: ImageProcessingPostProcess;
  122302. /**
  122303. * Chromatic aberration post process which will shift rgb colors in the image
  122304. */
  122305. chromaticAberration: ChromaticAberrationPostProcess;
  122306. private _chromaticAberrationEffect;
  122307. /**
  122308. * Grain post process which add noise to the image
  122309. */
  122310. grain: GrainPostProcess;
  122311. private _grainEffect;
  122312. /**
  122313. * Glow post process which adds a glow to emissive areas of the image
  122314. */
  122315. private _glowLayer;
  122316. /**
  122317. * Animations which can be used to tweak settings over a period of time
  122318. */
  122319. animations: Animation[];
  122320. private _imageProcessingConfigurationObserver;
  122321. private _sharpenEnabled;
  122322. private _bloomEnabled;
  122323. private _depthOfFieldEnabled;
  122324. private _depthOfFieldBlurLevel;
  122325. private _fxaaEnabled;
  122326. private _imageProcessingEnabled;
  122327. private _defaultPipelineTextureType;
  122328. private _bloomScale;
  122329. private _chromaticAberrationEnabled;
  122330. private _grainEnabled;
  122331. private _buildAllowed;
  122332. /**
  122333. * Gets active scene
  122334. */
  122335. readonly scene: Scene;
  122336. /**
  122337. * Enable or disable the sharpen process from the pipeline
  122338. */
  122339. sharpenEnabled: boolean;
  122340. private _resizeObserver;
  122341. private _hardwareScaleLevel;
  122342. private _bloomKernel;
  122343. /**
  122344. * Specifies the size of the bloom blur kernel, relative to the final output size
  122345. */
  122346. bloomKernel: number;
  122347. /**
  122348. * Specifies the weight of the bloom in the final rendering
  122349. */
  122350. private _bloomWeight;
  122351. /**
  122352. * Specifies the luma threshold for the area that will be blurred by the bloom
  122353. */
  122354. private _bloomThreshold;
  122355. private _hdr;
  122356. /**
  122357. * The strength of the bloom.
  122358. */
  122359. bloomWeight: number;
  122360. /**
  122361. * The strength of the bloom.
  122362. */
  122363. bloomThreshold: number;
  122364. /**
  122365. * The scale of the bloom, lower value will provide better performance.
  122366. */
  122367. bloomScale: number;
  122368. /**
  122369. * Enable or disable the bloom from the pipeline
  122370. */
  122371. bloomEnabled: boolean;
  122372. private _rebuildBloom;
  122373. /**
  122374. * If the depth of field is enabled.
  122375. */
  122376. depthOfFieldEnabled: boolean;
  122377. /**
  122378. * Blur level of the depth of field effect. (Higher blur will effect performance)
  122379. */
  122380. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  122381. /**
  122382. * If the anti aliasing is enabled.
  122383. */
  122384. fxaaEnabled: boolean;
  122385. private _samples;
  122386. /**
  122387. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122388. */
  122389. samples: number;
  122390. /**
  122391. * If image processing is enabled.
  122392. */
  122393. imageProcessingEnabled: boolean;
  122394. /**
  122395. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  122396. */
  122397. glowLayerEnabled: boolean;
  122398. /**
  122399. * Gets the glow layer (or null if not defined)
  122400. */
  122401. readonly glowLayer: Nullable<GlowLayer>;
  122402. /**
  122403. * Enable or disable the chromaticAberration process from the pipeline
  122404. */
  122405. chromaticAberrationEnabled: boolean;
  122406. /**
  122407. * Enable or disable the grain process from the pipeline
  122408. */
  122409. grainEnabled: boolean;
  122410. /**
  122411. * @constructor
  122412. * @param name - The rendering pipeline name (default: "")
  122413. * @param hdr - If high dynamic range textures should be used (default: true)
  122414. * @param scene - The scene linked to this pipeline (default: the last created scene)
  122415. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  122416. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  122417. */
  122418. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  122419. /**
  122420. * Get the class name
  122421. * @returns "DefaultRenderingPipeline"
  122422. */
  122423. getClassName(): string;
  122424. /**
  122425. * Force the compilation of the entire pipeline.
  122426. */
  122427. prepare(): void;
  122428. private _hasCleared;
  122429. private _prevPostProcess;
  122430. private _prevPrevPostProcess;
  122431. private _setAutoClearAndTextureSharing;
  122432. private _depthOfFieldSceneObserver;
  122433. private _buildPipeline;
  122434. private _disposePostProcesses;
  122435. /**
  122436. * Adds a camera to the pipeline
  122437. * @param camera the camera to be added
  122438. */
  122439. addCamera(camera: Camera): void;
  122440. /**
  122441. * Removes a camera from the pipeline
  122442. * @param camera the camera to remove
  122443. */
  122444. removeCamera(camera: Camera): void;
  122445. /**
  122446. * Dispose of the pipeline and stop all post processes
  122447. */
  122448. dispose(): void;
  122449. /**
  122450. * Serialize the rendering pipeline (Used when exporting)
  122451. * @returns the serialized object
  122452. */
  122453. serialize(): any;
  122454. /**
  122455. * Parse the serialized pipeline
  122456. * @param source Source pipeline.
  122457. * @param scene The scene to load the pipeline to.
  122458. * @param rootUrl The URL of the serialized pipeline.
  122459. * @returns An instantiated pipeline from the serialized object.
  122460. */
  122461. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  122462. }
  122463. }
  122464. declare module BABYLON {
  122465. /** @hidden */
  122466. export var lensHighlightsPixelShader: {
  122467. name: string;
  122468. shader: string;
  122469. };
  122470. }
  122471. declare module BABYLON {
  122472. /** @hidden */
  122473. export var depthOfFieldPixelShader: {
  122474. name: string;
  122475. shader: string;
  122476. };
  122477. }
  122478. declare module BABYLON {
  122479. /**
  122480. * BABYLON.JS Chromatic Aberration GLSL Shader
  122481. * Author: Olivier Guyot
  122482. * Separates very slightly R, G and B colors on the edges of the screen
  122483. * Inspired by Francois Tarlier & Martins Upitis
  122484. */
  122485. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  122486. /**
  122487. * @ignore
  122488. * The chromatic aberration PostProcess id in the pipeline
  122489. */
  122490. LensChromaticAberrationEffect: string;
  122491. /**
  122492. * @ignore
  122493. * The highlights enhancing PostProcess id in the pipeline
  122494. */
  122495. HighlightsEnhancingEffect: string;
  122496. /**
  122497. * @ignore
  122498. * The depth-of-field PostProcess id in the pipeline
  122499. */
  122500. LensDepthOfFieldEffect: string;
  122501. private _scene;
  122502. private _depthTexture;
  122503. private _grainTexture;
  122504. private _chromaticAberrationPostProcess;
  122505. private _highlightsPostProcess;
  122506. private _depthOfFieldPostProcess;
  122507. private _edgeBlur;
  122508. private _grainAmount;
  122509. private _chromaticAberration;
  122510. private _distortion;
  122511. private _highlightsGain;
  122512. private _highlightsThreshold;
  122513. private _dofDistance;
  122514. private _dofAperture;
  122515. private _dofDarken;
  122516. private _dofPentagon;
  122517. private _blurNoise;
  122518. /**
  122519. * @constructor
  122520. *
  122521. * Effect parameters are as follow:
  122522. * {
  122523. * chromatic_aberration: number; // from 0 to x (1 for realism)
  122524. * edge_blur: number; // from 0 to x (1 for realism)
  122525. * distortion: number; // from 0 to x (1 for realism)
  122526. * grain_amount: number; // from 0 to 1
  122527. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  122528. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  122529. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  122530. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  122531. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  122532. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  122533. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  122534. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  122535. * }
  122536. * Note: if an effect parameter is unset, effect is disabled
  122537. *
  122538. * @param name The rendering pipeline name
  122539. * @param parameters - An object containing all parameters (see above)
  122540. * @param scene The scene linked to this pipeline
  122541. * @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)
  122542. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122543. */
  122544. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  122545. /**
  122546. * Get the class name
  122547. * @returns "LensRenderingPipeline"
  122548. */
  122549. getClassName(): string;
  122550. /**
  122551. * Gets associated scene
  122552. */
  122553. readonly scene: Scene;
  122554. /**
  122555. * Gets or sets the edge blur
  122556. */
  122557. edgeBlur: number;
  122558. /**
  122559. * Gets or sets the grain amount
  122560. */
  122561. grainAmount: number;
  122562. /**
  122563. * Gets or sets the chromatic aberration amount
  122564. */
  122565. chromaticAberration: number;
  122566. /**
  122567. * Gets or sets the depth of field aperture
  122568. */
  122569. dofAperture: number;
  122570. /**
  122571. * Gets or sets the edge distortion
  122572. */
  122573. edgeDistortion: number;
  122574. /**
  122575. * Gets or sets the depth of field distortion
  122576. */
  122577. dofDistortion: number;
  122578. /**
  122579. * Gets or sets the darken out of focus amount
  122580. */
  122581. darkenOutOfFocus: number;
  122582. /**
  122583. * Gets or sets a boolean indicating if blur noise is enabled
  122584. */
  122585. blurNoise: boolean;
  122586. /**
  122587. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  122588. */
  122589. pentagonBokeh: boolean;
  122590. /**
  122591. * Gets or sets the highlight grain amount
  122592. */
  122593. highlightsGain: number;
  122594. /**
  122595. * Gets or sets the highlight threshold
  122596. */
  122597. highlightsThreshold: number;
  122598. /**
  122599. * Sets the amount of blur at the edges
  122600. * @param amount blur amount
  122601. */
  122602. setEdgeBlur(amount: number): void;
  122603. /**
  122604. * Sets edge blur to 0
  122605. */
  122606. disableEdgeBlur(): void;
  122607. /**
  122608. * Sets the amout of grain
  122609. * @param amount Amount of grain
  122610. */
  122611. setGrainAmount(amount: number): void;
  122612. /**
  122613. * Set grain amount to 0
  122614. */
  122615. disableGrain(): void;
  122616. /**
  122617. * Sets the chromatic aberration amount
  122618. * @param amount amount of chromatic aberration
  122619. */
  122620. setChromaticAberration(amount: number): void;
  122621. /**
  122622. * Sets chromatic aberration amount to 0
  122623. */
  122624. disableChromaticAberration(): void;
  122625. /**
  122626. * Sets the EdgeDistortion amount
  122627. * @param amount amount of EdgeDistortion
  122628. */
  122629. setEdgeDistortion(amount: number): void;
  122630. /**
  122631. * Sets edge distortion to 0
  122632. */
  122633. disableEdgeDistortion(): void;
  122634. /**
  122635. * Sets the FocusDistance amount
  122636. * @param amount amount of FocusDistance
  122637. */
  122638. setFocusDistance(amount: number): void;
  122639. /**
  122640. * Disables depth of field
  122641. */
  122642. disableDepthOfField(): void;
  122643. /**
  122644. * Sets the Aperture amount
  122645. * @param amount amount of Aperture
  122646. */
  122647. setAperture(amount: number): void;
  122648. /**
  122649. * Sets the DarkenOutOfFocus amount
  122650. * @param amount amount of DarkenOutOfFocus
  122651. */
  122652. setDarkenOutOfFocus(amount: number): void;
  122653. private _pentagonBokehIsEnabled;
  122654. /**
  122655. * Creates a pentagon bokeh effect
  122656. */
  122657. enablePentagonBokeh(): void;
  122658. /**
  122659. * Disables the pentagon bokeh effect
  122660. */
  122661. disablePentagonBokeh(): void;
  122662. /**
  122663. * Enables noise blur
  122664. */
  122665. enableNoiseBlur(): void;
  122666. /**
  122667. * Disables noise blur
  122668. */
  122669. disableNoiseBlur(): void;
  122670. /**
  122671. * Sets the HighlightsGain amount
  122672. * @param amount amount of HighlightsGain
  122673. */
  122674. setHighlightsGain(amount: number): void;
  122675. /**
  122676. * Sets the HighlightsThreshold amount
  122677. * @param amount amount of HighlightsThreshold
  122678. */
  122679. setHighlightsThreshold(amount: number): void;
  122680. /**
  122681. * Disables highlights
  122682. */
  122683. disableHighlights(): void;
  122684. /**
  122685. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  122686. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  122687. */
  122688. dispose(disableDepthRender?: boolean): void;
  122689. private _createChromaticAberrationPostProcess;
  122690. private _createHighlightsPostProcess;
  122691. private _createDepthOfFieldPostProcess;
  122692. private _createGrainTexture;
  122693. }
  122694. }
  122695. declare module BABYLON {
  122696. /** @hidden */
  122697. export var ssao2PixelShader: {
  122698. name: string;
  122699. shader: string;
  122700. };
  122701. }
  122702. declare module BABYLON {
  122703. /** @hidden */
  122704. export var ssaoCombinePixelShader: {
  122705. name: string;
  122706. shader: string;
  122707. };
  122708. }
  122709. declare module BABYLON {
  122710. /**
  122711. * Render pipeline to produce ssao effect
  122712. */
  122713. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  122714. /**
  122715. * @ignore
  122716. * The PassPostProcess id in the pipeline that contains the original scene color
  122717. */
  122718. SSAOOriginalSceneColorEffect: string;
  122719. /**
  122720. * @ignore
  122721. * The SSAO PostProcess id in the pipeline
  122722. */
  122723. SSAORenderEffect: string;
  122724. /**
  122725. * @ignore
  122726. * The horizontal blur PostProcess id in the pipeline
  122727. */
  122728. SSAOBlurHRenderEffect: string;
  122729. /**
  122730. * @ignore
  122731. * The vertical blur PostProcess id in the pipeline
  122732. */
  122733. SSAOBlurVRenderEffect: string;
  122734. /**
  122735. * @ignore
  122736. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122737. */
  122738. SSAOCombineRenderEffect: string;
  122739. /**
  122740. * The output strength of the SSAO post-process. Default value is 1.0.
  122741. */
  122742. totalStrength: number;
  122743. /**
  122744. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  122745. */
  122746. maxZ: number;
  122747. /**
  122748. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  122749. */
  122750. minZAspect: number;
  122751. private _samples;
  122752. /**
  122753. * Number of samples used for the SSAO calculations. Default value is 8
  122754. */
  122755. samples: number;
  122756. private _textureSamples;
  122757. /**
  122758. * Number of samples to use for antialiasing
  122759. */
  122760. textureSamples: number;
  122761. /**
  122762. * Ratio object used for SSAO ratio and blur ratio
  122763. */
  122764. private _ratio;
  122765. /**
  122766. * Dynamically generated sphere sampler.
  122767. */
  122768. private _sampleSphere;
  122769. /**
  122770. * Blur filter offsets
  122771. */
  122772. private _samplerOffsets;
  122773. private _expensiveBlur;
  122774. /**
  122775. * If bilateral blur should be used
  122776. */
  122777. expensiveBlur: boolean;
  122778. /**
  122779. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  122780. */
  122781. radius: number;
  122782. /**
  122783. * The base color of the SSAO post-process
  122784. * The final result is "base + ssao" between [0, 1]
  122785. */
  122786. base: number;
  122787. /**
  122788. * Support test.
  122789. */
  122790. static readonly IsSupported: boolean;
  122791. private _scene;
  122792. private _depthTexture;
  122793. private _normalTexture;
  122794. private _randomTexture;
  122795. private _originalColorPostProcess;
  122796. private _ssaoPostProcess;
  122797. private _blurHPostProcess;
  122798. private _blurVPostProcess;
  122799. private _ssaoCombinePostProcess;
  122800. private _firstUpdate;
  122801. /**
  122802. * Gets active scene
  122803. */
  122804. readonly scene: Scene;
  122805. /**
  122806. * @constructor
  122807. * @param name The rendering pipeline name
  122808. * @param scene The scene linked to this pipeline
  122809. * @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 }
  122810. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122811. */
  122812. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  122813. /**
  122814. * Get the class name
  122815. * @returns "SSAO2RenderingPipeline"
  122816. */
  122817. getClassName(): string;
  122818. /**
  122819. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122820. */
  122821. dispose(disableGeometryBufferRenderer?: boolean): void;
  122822. private _createBlurPostProcess;
  122823. /** @hidden */
  122824. _rebuild(): void;
  122825. private _bits;
  122826. private _radicalInverse_VdC;
  122827. private _hammersley;
  122828. private _hemisphereSample_uniform;
  122829. private _generateHemisphere;
  122830. private _createSSAOPostProcess;
  122831. private _createSSAOCombinePostProcess;
  122832. private _createRandomTexture;
  122833. /**
  122834. * Serialize the rendering pipeline (Used when exporting)
  122835. * @returns the serialized object
  122836. */
  122837. serialize(): any;
  122838. /**
  122839. * Parse the serialized pipeline
  122840. * @param source Source pipeline.
  122841. * @param scene The scene to load the pipeline to.
  122842. * @param rootUrl The URL of the serialized pipeline.
  122843. * @returns An instantiated pipeline from the serialized object.
  122844. */
  122845. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  122846. }
  122847. }
  122848. declare module BABYLON {
  122849. /** @hidden */
  122850. export var ssaoPixelShader: {
  122851. name: string;
  122852. shader: string;
  122853. };
  122854. }
  122855. declare module BABYLON {
  122856. /**
  122857. * Render pipeline to produce ssao effect
  122858. */
  122859. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  122860. /**
  122861. * @ignore
  122862. * The PassPostProcess id in the pipeline that contains the original scene color
  122863. */
  122864. SSAOOriginalSceneColorEffect: string;
  122865. /**
  122866. * @ignore
  122867. * The SSAO PostProcess id in the pipeline
  122868. */
  122869. SSAORenderEffect: string;
  122870. /**
  122871. * @ignore
  122872. * The horizontal blur PostProcess id in the pipeline
  122873. */
  122874. SSAOBlurHRenderEffect: string;
  122875. /**
  122876. * @ignore
  122877. * The vertical blur PostProcess id in the pipeline
  122878. */
  122879. SSAOBlurVRenderEffect: string;
  122880. /**
  122881. * @ignore
  122882. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122883. */
  122884. SSAOCombineRenderEffect: string;
  122885. /**
  122886. * The output strength of the SSAO post-process. Default value is 1.0.
  122887. */
  122888. totalStrength: number;
  122889. /**
  122890. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  122891. */
  122892. radius: number;
  122893. /**
  122894. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  122895. * Must not be equal to fallOff and superior to fallOff.
  122896. * Default value is 0.0075
  122897. */
  122898. area: number;
  122899. /**
  122900. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  122901. * Must not be equal to area and inferior to area.
  122902. * Default value is 0.000001
  122903. */
  122904. fallOff: number;
  122905. /**
  122906. * The base color of the SSAO post-process
  122907. * The final result is "base + ssao" between [0, 1]
  122908. */
  122909. base: number;
  122910. private _scene;
  122911. private _depthTexture;
  122912. private _randomTexture;
  122913. private _originalColorPostProcess;
  122914. private _ssaoPostProcess;
  122915. private _blurHPostProcess;
  122916. private _blurVPostProcess;
  122917. private _ssaoCombinePostProcess;
  122918. private _firstUpdate;
  122919. /**
  122920. * Gets active scene
  122921. */
  122922. readonly scene: Scene;
  122923. /**
  122924. * @constructor
  122925. * @param name - The rendering pipeline name
  122926. * @param scene - The scene linked to this pipeline
  122927. * @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 }
  122928. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  122929. */
  122930. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  122931. /**
  122932. * Get the class name
  122933. * @returns "SSAORenderingPipeline"
  122934. */
  122935. getClassName(): string;
  122936. /**
  122937. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122938. */
  122939. dispose(disableDepthRender?: boolean): void;
  122940. private _createBlurPostProcess;
  122941. /** @hidden */
  122942. _rebuild(): void;
  122943. private _createSSAOPostProcess;
  122944. private _createSSAOCombinePostProcess;
  122945. private _createRandomTexture;
  122946. }
  122947. }
  122948. declare module BABYLON {
  122949. /** @hidden */
  122950. export var standardPixelShader: {
  122951. name: string;
  122952. shader: string;
  122953. };
  122954. }
  122955. declare module BABYLON {
  122956. /**
  122957. * Standard rendering pipeline
  122958. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122959. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  122960. */
  122961. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  122962. /**
  122963. * Public members
  122964. */
  122965. /**
  122966. * Post-process which contains the original scene color before the pipeline applies all the effects
  122967. */
  122968. originalPostProcess: Nullable<PostProcess>;
  122969. /**
  122970. * Post-process used to down scale an image x4
  122971. */
  122972. downSampleX4PostProcess: Nullable<PostProcess>;
  122973. /**
  122974. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  122975. */
  122976. brightPassPostProcess: Nullable<PostProcess>;
  122977. /**
  122978. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  122979. */
  122980. blurHPostProcesses: PostProcess[];
  122981. /**
  122982. * Post-process array storing all the vertical blur post-processes used by the pipeline
  122983. */
  122984. blurVPostProcesses: PostProcess[];
  122985. /**
  122986. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  122987. */
  122988. textureAdderPostProcess: Nullable<PostProcess>;
  122989. /**
  122990. * Post-process used to create volumetric lighting effect
  122991. */
  122992. volumetricLightPostProcess: Nullable<PostProcess>;
  122993. /**
  122994. * Post-process used to smooth the previous volumetric light post-process on the X axis
  122995. */
  122996. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  122997. /**
  122998. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  122999. */
  123000. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  123001. /**
  123002. * Post-process used to merge the volumetric light effect and the real scene color
  123003. */
  123004. volumetricLightMergePostProces: Nullable<PostProcess>;
  123005. /**
  123006. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  123007. */
  123008. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  123009. /**
  123010. * Base post-process used to calculate the average luminance of the final image for HDR
  123011. */
  123012. luminancePostProcess: Nullable<PostProcess>;
  123013. /**
  123014. * Post-processes used to create down sample post-processes in order to get
  123015. * the average luminance of the final image for HDR
  123016. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  123017. */
  123018. luminanceDownSamplePostProcesses: PostProcess[];
  123019. /**
  123020. * Post-process used to create a HDR effect (light adaptation)
  123021. */
  123022. hdrPostProcess: Nullable<PostProcess>;
  123023. /**
  123024. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  123025. */
  123026. textureAdderFinalPostProcess: Nullable<PostProcess>;
  123027. /**
  123028. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  123029. */
  123030. lensFlareFinalPostProcess: Nullable<PostProcess>;
  123031. /**
  123032. * Post-process used to merge the final HDR post-process and the real scene color
  123033. */
  123034. hdrFinalPostProcess: Nullable<PostProcess>;
  123035. /**
  123036. * Post-process used to create a lens flare effect
  123037. */
  123038. lensFlarePostProcess: Nullable<PostProcess>;
  123039. /**
  123040. * Post-process that merges the result of the lens flare post-process and the real scene color
  123041. */
  123042. lensFlareComposePostProcess: Nullable<PostProcess>;
  123043. /**
  123044. * Post-process used to create a motion blur effect
  123045. */
  123046. motionBlurPostProcess: Nullable<PostProcess>;
  123047. /**
  123048. * Post-process used to create a depth of field effect
  123049. */
  123050. depthOfFieldPostProcess: Nullable<PostProcess>;
  123051. /**
  123052. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  123053. */
  123054. fxaaPostProcess: Nullable<FxaaPostProcess>;
  123055. /**
  123056. * Represents the brightness threshold in order to configure the illuminated surfaces
  123057. */
  123058. brightThreshold: number;
  123059. /**
  123060. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  123061. */
  123062. blurWidth: number;
  123063. /**
  123064. * Sets if the blur for highlighted surfaces must be only horizontal
  123065. */
  123066. horizontalBlur: boolean;
  123067. /**
  123068. * Gets the overall exposure used by the pipeline
  123069. */
  123070. /**
  123071. * Sets the overall exposure used by the pipeline
  123072. */
  123073. exposure: number;
  123074. /**
  123075. * Texture used typically to simulate "dirty" on camera lens
  123076. */
  123077. lensTexture: Nullable<Texture>;
  123078. /**
  123079. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  123080. */
  123081. volumetricLightCoefficient: number;
  123082. /**
  123083. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  123084. */
  123085. volumetricLightPower: number;
  123086. /**
  123087. * Used the set the blur intensity to smooth the volumetric lights
  123088. */
  123089. volumetricLightBlurScale: number;
  123090. /**
  123091. * Light (spot or directional) used to generate the volumetric lights rays
  123092. * The source light must have a shadow generate so the pipeline can get its
  123093. * depth map
  123094. */
  123095. sourceLight: Nullable<SpotLight | DirectionalLight>;
  123096. /**
  123097. * For eye adaptation, represents the minimum luminance the eye can see
  123098. */
  123099. hdrMinimumLuminance: number;
  123100. /**
  123101. * For eye adaptation, represents the decrease luminance speed
  123102. */
  123103. hdrDecreaseRate: number;
  123104. /**
  123105. * For eye adaptation, represents the increase luminance speed
  123106. */
  123107. hdrIncreaseRate: number;
  123108. /**
  123109. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  123110. */
  123111. /**
  123112. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  123113. */
  123114. hdrAutoExposure: boolean;
  123115. /**
  123116. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  123117. */
  123118. lensColorTexture: Nullable<Texture>;
  123119. /**
  123120. * The overall strengh for the lens flare effect
  123121. */
  123122. lensFlareStrength: number;
  123123. /**
  123124. * Dispersion coefficient for lens flare ghosts
  123125. */
  123126. lensFlareGhostDispersal: number;
  123127. /**
  123128. * Main lens flare halo width
  123129. */
  123130. lensFlareHaloWidth: number;
  123131. /**
  123132. * Based on the lens distortion effect, defines how much the lens flare result
  123133. * is distorted
  123134. */
  123135. lensFlareDistortionStrength: number;
  123136. /**
  123137. * Lens star texture must be used to simulate rays on the flares and is available
  123138. * in the documentation
  123139. */
  123140. lensStarTexture: Nullable<Texture>;
  123141. /**
  123142. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  123143. * flare effect by taking account of the dirt texture
  123144. */
  123145. lensFlareDirtTexture: Nullable<Texture>;
  123146. /**
  123147. * Represents the focal length for the depth of field effect
  123148. */
  123149. depthOfFieldDistance: number;
  123150. /**
  123151. * Represents the blur intensity for the blurred part of the depth of field effect
  123152. */
  123153. depthOfFieldBlurWidth: number;
  123154. /**
  123155. * Gets how much the image is blurred by the movement while using the motion blur post-process
  123156. */
  123157. /**
  123158. * Sets how much the image is blurred by the movement while using the motion blur post-process
  123159. */
  123160. motionStrength: number;
  123161. /**
  123162. * Gets wether or not the motion blur post-process is object based or screen based.
  123163. */
  123164. /**
  123165. * Sets wether or not the motion blur post-process should be object based or screen based
  123166. */
  123167. objectBasedMotionBlur: boolean;
  123168. /**
  123169. * List of animations for the pipeline (IAnimatable implementation)
  123170. */
  123171. animations: Animation[];
  123172. /**
  123173. * Private members
  123174. */
  123175. private _scene;
  123176. private _currentDepthOfFieldSource;
  123177. private _basePostProcess;
  123178. private _fixedExposure;
  123179. private _currentExposure;
  123180. private _hdrAutoExposure;
  123181. private _hdrCurrentLuminance;
  123182. private _motionStrength;
  123183. private _isObjectBasedMotionBlur;
  123184. private _floatTextureType;
  123185. private _ratio;
  123186. private _bloomEnabled;
  123187. private _depthOfFieldEnabled;
  123188. private _vlsEnabled;
  123189. private _lensFlareEnabled;
  123190. private _hdrEnabled;
  123191. private _motionBlurEnabled;
  123192. private _fxaaEnabled;
  123193. private _motionBlurSamples;
  123194. private _volumetricLightStepsCount;
  123195. private _samples;
  123196. /**
  123197. * @ignore
  123198. * Specifies if the bloom pipeline is enabled
  123199. */
  123200. BloomEnabled: boolean;
  123201. /**
  123202. * @ignore
  123203. * Specifies if the depth of field pipeline is enabed
  123204. */
  123205. DepthOfFieldEnabled: boolean;
  123206. /**
  123207. * @ignore
  123208. * Specifies if the lens flare pipeline is enabed
  123209. */
  123210. LensFlareEnabled: boolean;
  123211. /**
  123212. * @ignore
  123213. * Specifies if the HDR pipeline is enabled
  123214. */
  123215. HDREnabled: boolean;
  123216. /**
  123217. * @ignore
  123218. * Specifies if the volumetric lights scattering effect is enabled
  123219. */
  123220. VLSEnabled: boolean;
  123221. /**
  123222. * @ignore
  123223. * Specifies if the motion blur effect is enabled
  123224. */
  123225. MotionBlurEnabled: boolean;
  123226. /**
  123227. * Specifies if anti-aliasing is enabled
  123228. */
  123229. fxaaEnabled: boolean;
  123230. /**
  123231. * Specifies the number of steps used to calculate the volumetric lights
  123232. * Typically in interval [50, 200]
  123233. */
  123234. volumetricLightStepsCount: number;
  123235. /**
  123236. * Specifies the number of samples used for the motion blur effect
  123237. * Typically in interval [16, 64]
  123238. */
  123239. motionBlurSamples: number;
  123240. /**
  123241. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  123242. */
  123243. samples: number;
  123244. /**
  123245. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  123246. * @constructor
  123247. * @param name The rendering pipeline name
  123248. * @param scene The scene linked to this pipeline
  123249. * @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)
  123250. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  123251. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123252. */
  123253. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  123254. private _buildPipeline;
  123255. private _createDownSampleX4PostProcess;
  123256. private _createBrightPassPostProcess;
  123257. private _createBlurPostProcesses;
  123258. private _createTextureAdderPostProcess;
  123259. private _createVolumetricLightPostProcess;
  123260. private _createLuminancePostProcesses;
  123261. private _createHdrPostProcess;
  123262. private _createLensFlarePostProcess;
  123263. private _createDepthOfFieldPostProcess;
  123264. private _createMotionBlurPostProcess;
  123265. private _getDepthTexture;
  123266. private _disposePostProcesses;
  123267. /**
  123268. * Dispose of the pipeline and stop all post processes
  123269. */
  123270. dispose(): void;
  123271. /**
  123272. * Serialize the rendering pipeline (Used when exporting)
  123273. * @returns the serialized object
  123274. */
  123275. serialize(): any;
  123276. /**
  123277. * Parse the serialized pipeline
  123278. * @param source Source pipeline.
  123279. * @param scene The scene to load the pipeline to.
  123280. * @param rootUrl The URL of the serialized pipeline.
  123281. * @returns An instantiated pipeline from the serialized object.
  123282. */
  123283. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  123284. /**
  123285. * Luminance steps
  123286. */
  123287. static LuminanceSteps: number;
  123288. }
  123289. }
  123290. declare module BABYLON {
  123291. /** @hidden */
  123292. export var tonemapPixelShader: {
  123293. name: string;
  123294. shader: string;
  123295. };
  123296. }
  123297. declare module BABYLON {
  123298. /** Defines operator used for tonemapping */
  123299. export enum TonemappingOperator {
  123300. /** Hable */
  123301. Hable = 0,
  123302. /** Reinhard */
  123303. Reinhard = 1,
  123304. /** HejiDawson */
  123305. HejiDawson = 2,
  123306. /** Photographic */
  123307. Photographic = 3
  123308. }
  123309. /**
  123310. * Defines a post process to apply tone mapping
  123311. */
  123312. export class TonemapPostProcess extends PostProcess {
  123313. private _operator;
  123314. /** Defines the required exposure adjustement */
  123315. exposureAdjustment: number;
  123316. /**
  123317. * Creates a new TonemapPostProcess
  123318. * @param name defines the name of the postprocess
  123319. * @param _operator defines the operator to use
  123320. * @param exposureAdjustment defines the required exposure adjustement
  123321. * @param camera defines the camera to use (can be null)
  123322. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  123323. * @param engine defines the hosting engine (can be ignore if camera is set)
  123324. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  123325. */
  123326. constructor(name: string, _operator: TonemappingOperator,
  123327. /** Defines the required exposure adjustement */
  123328. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  123329. }
  123330. }
  123331. declare module BABYLON {
  123332. /** @hidden */
  123333. export var depthVertexShader: {
  123334. name: string;
  123335. shader: string;
  123336. };
  123337. }
  123338. declare module BABYLON {
  123339. /** @hidden */
  123340. export var volumetricLightScatteringPixelShader: {
  123341. name: string;
  123342. shader: string;
  123343. };
  123344. }
  123345. declare module BABYLON {
  123346. /** @hidden */
  123347. export var volumetricLightScatteringPassVertexShader: {
  123348. name: string;
  123349. shader: string;
  123350. };
  123351. }
  123352. declare module BABYLON {
  123353. /** @hidden */
  123354. export var volumetricLightScatteringPassPixelShader: {
  123355. name: string;
  123356. shader: string;
  123357. };
  123358. }
  123359. declare module BABYLON {
  123360. /**
  123361. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  123362. */
  123363. export class VolumetricLightScatteringPostProcess extends PostProcess {
  123364. private _volumetricLightScatteringPass;
  123365. private _volumetricLightScatteringRTT;
  123366. private _viewPort;
  123367. private _screenCoordinates;
  123368. private _cachedDefines;
  123369. /**
  123370. * If not undefined, the mesh position is computed from the attached node position
  123371. */
  123372. attachedNode: {
  123373. position: Vector3;
  123374. };
  123375. /**
  123376. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  123377. */
  123378. customMeshPosition: Vector3;
  123379. /**
  123380. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  123381. */
  123382. useCustomMeshPosition: boolean;
  123383. /**
  123384. * If the post-process should inverse the light scattering direction
  123385. */
  123386. invert: boolean;
  123387. /**
  123388. * The internal mesh used by the post-process
  123389. */
  123390. mesh: Mesh;
  123391. /**
  123392. * @hidden
  123393. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  123394. */
  123395. useDiffuseColor: boolean;
  123396. /**
  123397. * Array containing the excluded meshes not rendered in the internal pass
  123398. */
  123399. excludedMeshes: AbstractMesh[];
  123400. /**
  123401. * Controls the overall intensity of the post-process
  123402. */
  123403. exposure: number;
  123404. /**
  123405. * Dissipates each sample's contribution in range [0, 1]
  123406. */
  123407. decay: number;
  123408. /**
  123409. * Controls the overall intensity of each sample
  123410. */
  123411. weight: number;
  123412. /**
  123413. * Controls the density of each sample
  123414. */
  123415. density: number;
  123416. /**
  123417. * @constructor
  123418. * @param name The post-process name
  123419. * @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)
  123420. * @param camera The camera that the post-process will be attached to
  123421. * @param mesh The mesh used to create the light scattering
  123422. * @param samples The post-process quality, default 100
  123423. * @param samplingModeThe post-process filtering mode
  123424. * @param engine The babylon engine
  123425. * @param reusable If the post-process is reusable
  123426. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  123427. */
  123428. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  123429. /**
  123430. * Returns the string "VolumetricLightScatteringPostProcess"
  123431. * @returns "VolumetricLightScatteringPostProcess"
  123432. */
  123433. getClassName(): string;
  123434. private _isReady;
  123435. /**
  123436. * Sets the new light position for light scattering effect
  123437. * @param position The new custom light position
  123438. */
  123439. setCustomMeshPosition(position: Vector3): void;
  123440. /**
  123441. * Returns the light position for light scattering effect
  123442. * @return Vector3 The custom light position
  123443. */
  123444. getCustomMeshPosition(): Vector3;
  123445. /**
  123446. * Disposes the internal assets and detaches the post-process from the camera
  123447. */
  123448. dispose(camera: Camera): void;
  123449. /**
  123450. * Returns the render target texture used by the post-process
  123451. * @return the render target texture used by the post-process
  123452. */
  123453. getPass(): RenderTargetTexture;
  123454. private _meshExcluded;
  123455. private _createPass;
  123456. private _updateMeshScreenCoordinates;
  123457. /**
  123458. * Creates a default mesh for the Volumeric Light Scattering post-process
  123459. * @param name The mesh name
  123460. * @param scene The scene where to create the mesh
  123461. * @return the default mesh
  123462. */
  123463. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  123464. }
  123465. }
  123466. declare module BABYLON {
  123467. interface Scene {
  123468. /** @hidden (Backing field) */
  123469. _boundingBoxRenderer: BoundingBoxRenderer;
  123470. /** @hidden (Backing field) */
  123471. _forceShowBoundingBoxes: boolean;
  123472. /**
  123473. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  123474. */
  123475. forceShowBoundingBoxes: boolean;
  123476. /**
  123477. * Gets the bounding box renderer associated with the scene
  123478. * @returns a BoundingBoxRenderer
  123479. */
  123480. getBoundingBoxRenderer(): BoundingBoxRenderer;
  123481. }
  123482. interface AbstractMesh {
  123483. /** @hidden (Backing field) */
  123484. _showBoundingBox: boolean;
  123485. /**
  123486. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  123487. */
  123488. showBoundingBox: boolean;
  123489. }
  123490. /**
  123491. * Component responsible of rendering the bounding box of the meshes in a scene.
  123492. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  123493. */
  123494. export class BoundingBoxRenderer implements ISceneComponent {
  123495. /**
  123496. * The component name helpfull to identify the component in the list of scene components.
  123497. */
  123498. readonly name: string;
  123499. /**
  123500. * The scene the component belongs to.
  123501. */
  123502. scene: Scene;
  123503. /**
  123504. * Color of the bounding box lines placed in front of an object
  123505. */
  123506. frontColor: Color3;
  123507. /**
  123508. * Color of the bounding box lines placed behind an object
  123509. */
  123510. backColor: Color3;
  123511. /**
  123512. * Defines if the renderer should show the back lines or not
  123513. */
  123514. showBackLines: boolean;
  123515. /**
  123516. * @hidden
  123517. */
  123518. renderList: SmartArray<BoundingBox>;
  123519. private _colorShader;
  123520. private _vertexBuffers;
  123521. private _indexBuffer;
  123522. private _fillIndexBuffer;
  123523. private _fillIndexData;
  123524. /**
  123525. * Instantiates a new bounding box renderer in a scene.
  123526. * @param scene the scene the renderer renders in
  123527. */
  123528. constructor(scene: Scene);
  123529. /**
  123530. * Registers the component in a given scene
  123531. */
  123532. register(): void;
  123533. private _evaluateSubMesh;
  123534. private _activeMesh;
  123535. private _prepareRessources;
  123536. private _createIndexBuffer;
  123537. /**
  123538. * Rebuilds the elements related to this component in case of
  123539. * context lost for instance.
  123540. */
  123541. rebuild(): void;
  123542. /**
  123543. * @hidden
  123544. */
  123545. reset(): void;
  123546. /**
  123547. * Render the bounding boxes of a specific rendering group
  123548. * @param renderingGroupId defines the rendering group to render
  123549. */
  123550. render(renderingGroupId: number): void;
  123551. /**
  123552. * In case of occlusion queries, we can render the occlusion bounding box through this method
  123553. * @param mesh Define the mesh to render the occlusion bounding box for
  123554. */
  123555. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  123556. /**
  123557. * Dispose and release the resources attached to this renderer.
  123558. */
  123559. dispose(): void;
  123560. }
  123561. }
  123562. declare module BABYLON {
  123563. /** @hidden */
  123564. export var depthPixelShader: {
  123565. name: string;
  123566. shader: string;
  123567. };
  123568. }
  123569. declare module BABYLON {
  123570. /**
  123571. * This represents a depth renderer in Babylon.
  123572. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  123573. */
  123574. export class DepthRenderer {
  123575. private _scene;
  123576. private _depthMap;
  123577. private _effect;
  123578. private readonly _storeNonLinearDepth;
  123579. private readonly _clearColor;
  123580. /** Get if the depth renderer is using packed depth or not */
  123581. readonly isPacked: boolean;
  123582. private _cachedDefines;
  123583. private _camera;
  123584. /**
  123585. * Specifiess that the depth renderer will only be used within
  123586. * the camera it is created for.
  123587. * This can help forcing its rendering during the camera processing.
  123588. */
  123589. useOnlyInActiveCamera: boolean;
  123590. /** @hidden */
  123591. static _SceneComponentInitialization: (scene: Scene) => void;
  123592. /**
  123593. * Instantiates a depth renderer
  123594. * @param scene The scene the renderer belongs to
  123595. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  123596. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  123597. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  123598. */
  123599. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  123600. /**
  123601. * Creates the depth rendering effect and checks if the effect is ready.
  123602. * @param subMesh The submesh to be used to render the depth map of
  123603. * @param useInstances If multiple world instances should be used
  123604. * @returns if the depth renderer is ready to render the depth map
  123605. */
  123606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123607. /**
  123608. * Gets the texture which the depth map will be written to.
  123609. * @returns The depth map texture
  123610. */
  123611. getDepthMap(): RenderTargetTexture;
  123612. /**
  123613. * Disposes of the depth renderer.
  123614. */
  123615. dispose(): void;
  123616. }
  123617. }
  123618. declare module BABYLON {
  123619. interface Scene {
  123620. /** @hidden (Backing field) */
  123621. _depthRenderer: {
  123622. [id: string]: DepthRenderer;
  123623. };
  123624. /**
  123625. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  123626. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  123627. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  123628. * @returns the created depth renderer
  123629. */
  123630. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  123631. /**
  123632. * Disables a depth renderer for a given camera
  123633. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  123634. */
  123635. disableDepthRenderer(camera?: Nullable<Camera>): void;
  123636. }
  123637. /**
  123638. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  123639. * in several rendering techniques.
  123640. */
  123641. export class DepthRendererSceneComponent implements ISceneComponent {
  123642. /**
  123643. * The component name helpfull to identify the component in the list of scene components.
  123644. */
  123645. readonly name: string;
  123646. /**
  123647. * The scene the component belongs to.
  123648. */
  123649. scene: Scene;
  123650. /**
  123651. * Creates a new instance of the component for the given scene
  123652. * @param scene Defines the scene to register the component in
  123653. */
  123654. constructor(scene: Scene);
  123655. /**
  123656. * Registers the component in a given scene
  123657. */
  123658. register(): void;
  123659. /**
  123660. * Rebuilds the elements related to this component in case of
  123661. * context lost for instance.
  123662. */
  123663. rebuild(): void;
  123664. /**
  123665. * Disposes the component and the associated ressources
  123666. */
  123667. dispose(): void;
  123668. private _gatherRenderTargets;
  123669. private _gatherActiveCameraRenderTargets;
  123670. }
  123671. }
  123672. declare module BABYLON {
  123673. /** @hidden */
  123674. export var outlinePixelShader: {
  123675. name: string;
  123676. shader: string;
  123677. };
  123678. }
  123679. declare module BABYLON {
  123680. /** @hidden */
  123681. export var outlineVertexShader: {
  123682. name: string;
  123683. shader: string;
  123684. };
  123685. }
  123686. declare module BABYLON {
  123687. interface Scene {
  123688. /** @hidden */
  123689. _outlineRenderer: OutlineRenderer;
  123690. /**
  123691. * Gets the outline renderer associated with the scene
  123692. * @returns a OutlineRenderer
  123693. */
  123694. getOutlineRenderer(): OutlineRenderer;
  123695. }
  123696. interface AbstractMesh {
  123697. /** @hidden (Backing field) */
  123698. _renderOutline: boolean;
  123699. /**
  123700. * Gets or sets a boolean indicating if the outline must be rendered as well
  123701. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  123702. */
  123703. renderOutline: boolean;
  123704. /** @hidden (Backing field) */
  123705. _renderOverlay: boolean;
  123706. /**
  123707. * Gets or sets a boolean indicating if the overlay must be rendered as well
  123708. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  123709. */
  123710. renderOverlay: boolean;
  123711. }
  123712. /**
  123713. * This class is responsible to draw bothe outline/overlay of meshes.
  123714. * It should not be used directly but through the available method on mesh.
  123715. */
  123716. export class OutlineRenderer implements ISceneComponent {
  123717. /**
  123718. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  123719. */
  123720. private static _StencilReference;
  123721. /**
  123722. * The name of the component. Each component must have a unique name.
  123723. */
  123724. name: string;
  123725. /**
  123726. * The scene the component belongs to.
  123727. */
  123728. scene: Scene;
  123729. /**
  123730. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  123731. */
  123732. zOffset: number;
  123733. private _engine;
  123734. private _effect;
  123735. private _cachedDefines;
  123736. private _savedDepthWrite;
  123737. /**
  123738. * Instantiates a new outline renderer. (There could be only one per scene).
  123739. * @param scene Defines the scene it belongs to
  123740. */
  123741. constructor(scene: Scene);
  123742. /**
  123743. * Register the component to one instance of a scene.
  123744. */
  123745. register(): void;
  123746. /**
  123747. * Rebuilds the elements related to this component in case of
  123748. * context lost for instance.
  123749. */
  123750. rebuild(): void;
  123751. /**
  123752. * Disposes the component and the associated ressources.
  123753. */
  123754. dispose(): void;
  123755. /**
  123756. * Renders the outline in the canvas.
  123757. * @param subMesh Defines the sumesh to render
  123758. * @param batch Defines the batch of meshes in case of instances
  123759. * @param useOverlay Defines if the rendering is for the overlay or the outline
  123760. */
  123761. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  123762. /**
  123763. * Returns whether or not the outline renderer is ready for a given submesh.
  123764. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  123765. * @param subMesh Defines the submesh to check readyness for
  123766. * @param useInstances Defines wheter wee are trying to render instances or not
  123767. * @returns true if ready otherwise false
  123768. */
  123769. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123770. private _beforeRenderingMesh;
  123771. private _afterRenderingMesh;
  123772. }
  123773. }
  123774. declare module BABYLON {
  123775. /**
  123776. * Defines the list of states available for a task inside a AssetsManager
  123777. */
  123778. export enum AssetTaskState {
  123779. /**
  123780. * Initialization
  123781. */
  123782. INIT = 0,
  123783. /**
  123784. * Running
  123785. */
  123786. RUNNING = 1,
  123787. /**
  123788. * Done
  123789. */
  123790. DONE = 2,
  123791. /**
  123792. * Error
  123793. */
  123794. ERROR = 3
  123795. }
  123796. /**
  123797. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  123798. */
  123799. export abstract class AbstractAssetTask {
  123800. /**
  123801. * Task name
  123802. */ name: string;
  123803. /**
  123804. * Callback called when the task is successful
  123805. */
  123806. onSuccess: (task: any) => void;
  123807. /**
  123808. * Callback called when the task is not successful
  123809. */
  123810. onError: (task: any, message?: string, exception?: any) => void;
  123811. /**
  123812. * Creates a new AssetsManager
  123813. * @param name defines the name of the task
  123814. */
  123815. constructor(
  123816. /**
  123817. * Task name
  123818. */ name: string);
  123819. private _isCompleted;
  123820. private _taskState;
  123821. private _errorObject;
  123822. /**
  123823. * Get if the task is completed
  123824. */
  123825. readonly isCompleted: boolean;
  123826. /**
  123827. * Gets the current state of the task
  123828. */
  123829. readonly taskState: AssetTaskState;
  123830. /**
  123831. * Gets the current error object (if task is in error)
  123832. */
  123833. readonly errorObject: {
  123834. message?: string;
  123835. exception?: any;
  123836. };
  123837. /**
  123838. * Internal only
  123839. * @hidden
  123840. */
  123841. _setErrorObject(message?: string, exception?: any): void;
  123842. /**
  123843. * Execute the current task
  123844. * @param scene defines the scene where you want your assets to be loaded
  123845. * @param onSuccess is a callback called when the task is successfully executed
  123846. * @param onError is a callback called if an error occurs
  123847. */
  123848. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123849. /**
  123850. * Execute the current task
  123851. * @param scene defines the scene where you want your assets to be loaded
  123852. * @param onSuccess is a callback called when the task is successfully executed
  123853. * @param onError is a callback called if an error occurs
  123854. */
  123855. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123856. /**
  123857. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  123858. * This can be used with failed tasks that have the reason for failure fixed.
  123859. */
  123860. reset(): void;
  123861. private onErrorCallback;
  123862. private onDoneCallback;
  123863. }
  123864. /**
  123865. * Define the interface used by progress events raised during assets loading
  123866. */
  123867. export interface IAssetsProgressEvent {
  123868. /**
  123869. * Defines the number of remaining tasks to process
  123870. */
  123871. remainingCount: number;
  123872. /**
  123873. * Defines the total number of tasks
  123874. */
  123875. totalCount: number;
  123876. /**
  123877. * Defines the task that was just processed
  123878. */
  123879. task: AbstractAssetTask;
  123880. }
  123881. /**
  123882. * Class used to share progress information about assets loading
  123883. */
  123884. export class AssetsProgressEvent implements IAssetsProgressEvent {
  123885. /**
  123886. * Defines the number of remaining tasks to process
  123887. */
  123888. remainingCount: number;
  123889. /**
  123890. * Defines the total number of tasks
  123891. */
  123892. totalCount: number;
  123893. /**
  123894. * Defines the task that was just processed
  123895. */
  123896. task: AbstractAssetTask;
  123897. /**
  123898. * Creates a AssetsProgressEvent
  123899. * @param remainingCount defines the number of remaining tasks to process
  123900. * @param totalCount defines the total number of tasks
  123901. * @param task defines the task that was just processed
  123902. */
  123903. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  123904. }
  123905. /**
  123906. * Define a task used by AssetsManager to load meshes
  123907. */
  123908. export class MeshAssetTask extends AbstractAssetTask {
  123909. /**
  123910. * Defines the name of the task
  123911. */
  123912. name: string;
  123913. /**
  123914. * Defines the list of mesh's names you want to load
  123915. */
  123916. meshesNames: any;
  123917. /**
  123918. * Defines the root url to use as a base to load your meshes and associated resources
  123919. */
  123920. rootUrl: string;
  123921. /**
  123922. * Defines the filename of the scene to load from
  123923. */
  123924. sceneFilename: string;
  123925. /**
  123926. * Gets the list of loaded meshes
  123927. */
  123928. loadedMeshes: Array<AbstractMesh>;
  123929. /**
  123930. * Gets the list of loaded particle systems
  123931. */
  123932. loadedParticleSystems: Array<IParticleSystem>;
  123933. /**
  123934. * Gets the list of loaded skeletons
  123935. */
  123936. loadedSkeletons: Array<Skeleton>;
  123937. /**
  123938. * Gets the list of loaded animation groups
  123939. */
  123940. loadedAnimationGroups: Array<AnimationGroup>;
  123941. /**
  123942. * Callback called when the task is successful
  123943. */
  123944. onSuccess: (task: MeshAssetTask) => void;
  123945. /**
  123946. * Callback called when the task is successful
  123947. */
  123948. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  123949. /**
  123950. * Creates a new MeshAssetTask
  123951. * @param name defines the name of the task
  123952. * @param meshesNames defines the list of mesh's names you want to load
  123953. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  123954. * @param sceneFilename defines the filename of the scene to load from
  123955. */
  123956. constructor(
  123957. /**
  123958. * Defines the name of the task
  123959. */
  123960. name: string,
  123961. /**
  123962. * Defines the list of mesh's names you want to load
  123963. */
  123964. meshesNames: any,
  123965. /**
  123966. * Defines the root url to use as a base to load your meshes and associated resources
  123967. */
  123968. rootUrl: string,
  123969. /**
  123970. * Defines the filename of the scene to load from
  123971. */
  123972. sceneFilename: string);
  123973. /**
  123974. * Execute the current task
  123975. * @param scene defines the scene where you want your assets to be loaded
  123976. * @param onSuccess is a callback called when the task is successfully executed
  123977. * @param onError is a callback called if an error occurs
  123978. */
  123979. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123980. }
  123981. /**
  123982. * Define a task used by AssetsManager to load text content
  123983. */
  123984. export class TextFileAssetTask extends AbstractAssetTask {
  123985. /**
  123986. * Defines the name of the task
  123987. */
  123988. name: string;
  123989. /**
  123990. * Defines the location of the file to load
  123991. */
  123992. url: string;
  123993. /**
  123994. * Gets the loaded text string
  123995. */
  123996. text: string;
  123997. /**
  123998. * Callback called when the task is successful
  123999. */
  124000. onSuccess: (task: TextFileAssetTask) => void;
  124001. /**
  124002. * Callback called when the task is successful
  124003. */
  124004. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  124005. /**
  124006. * Creates a new TextFileAssetTask object
  124007. * @param name defines the name of the task
  124008. * @param url defines the location of the file to load
  124009. */
  124010. constructor(
  124011. /**
  124012. * Defines the name of the task
  124013. */
  124014. name: string,
  124015. /**
  124016. * Defines the location of the file to load
  124017. */
  124018. url: string);
  124019. /**
  124020. * Execute the current task
  124021. * @param scene defines the scene where you want your assets to be loaded
  124022. * @param onSuccess is a callback called when the task is successfully executed
  124023. * @param onError is a callback called if an error occurs
  124024. */
  124025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124026. }
  124027. /**
  124028. * Define a task used by AssetsManager to load binary data
  124029. */
  124030. export class BinaryFileAssetTask extends AbstractAssetTask {
  124031. /**
  124032. * Defines the name of the task
  124033. */
  124034. name: string;
  124035. /**
  124036. * Defines the location of the file to load
  124037. */
  124038. url: string;
  124039. /**
  124040. * Gets the lodaded data (as an array buffer)
  124041. */
  124042. data: ArrayBuffer;
  124043. /**
  124044. * Callback called when the task is successful
  124045. */
  124046. onSuccess: (task: BinaryFileAssetTask) => void;
  124047. /**
  124048. * Callback called when the task is successful
  124049. */
  124050. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  124051. /**
  124052. * Creates a new BinaryFileAssetTask object
  124053. * @param name defines the name of the new task
  124054. * @param url defines the location of the file to load
  124055. */
  124056. constructor(
  124057. /**
  124058. * Defines the name of the task
  124059. */
  124060. name: string,
  124061. /**
  124062. * Defines the location of the file to load
  124063. */
  124064. url: string);
  124065. /**
  124066. * Execute the current task
  124067. * @param scene defines the scene where you want your assets to be loaded
  124068. * @param onSuccess is a callback called when the task is successfully executed
  124069. * @param onError is a callback called if an error occurs
  124070. */
  124071. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124072. }
  124073. /**
  124074. * Define a task used by AssetsManager to load images
  124075. */
  124076. export class ImageAssetTask extends AbstractAssetTask {
  124077. /**
  124078. * Defines the name of the task
  124079. */
  124080. name: string;
  124081. /**
  124082. * Defines the location of the image to load
  124083. */
  124084. url: string;
  124085. /**
  124086. * Gets the loaded images
  124087. */
  124088. image: HTMLImageElement;
  124089. /**
  124090. * Callback called when the task is successful
  124091. */
  124092. onSuccess: (task: ImageAssetTask) => void;
  124093. /**
  124094. * Callback called when the task is successful
  124095. */
  124096. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  124097. /**
  124098. * Creates a new ImageAssetTask
  124099. * @param name defines the name of the task
  124100. * @param url defines the location of the image to load
  124101. */
  124102. constructor(
  124103. /**
  124104. * Defines the name of the task
  124105. */
  124106. name: string,
  124107. /**
  124108. * Defines the location of the image to load
  124109. */
  124110. url: string);
  124111. /**
  124112. * Execute the current task
  124113. * @param scene defines the scene where you want your assets to be loaded
  124114. * @param onSuccess is a callback called when the task is successfully executed
  124115. * @param onError is a callback called if an error occurs
  124116. */
  124117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124118. }
  124119. /**
  124120. * Defines the interface used by texture loading tasks
  124121. */
  124122. export interface ITextureAssetTask<TEX extends BaseTexture> {
  124123. /**
  124124. * Gets the loaded texture
  124125. */
  124126. texture: TEX;
  124127. }
  124128. /**
  124129. * Define a task used by AssetsManager to load 2D textures
  124130. */
  124131. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  124132. /**
  124133. * Defines the name of the task
  124134. */
  124135. name: string;
  124136. /**
  124137. * Defines the location of the file to load
  124138. */
  124139. url: string;
  124140. /**
  124141. * Defines if mipmap should not be generated (default is false)
  124142. */
  124143. noMipmap?: boolean | undefined;
  124144. /**
  124145. * Defines if texture must be inverted on Y axis (default is false)
  124146. */
  124147. invertY?: boolean | undefined;
  124148. /**
  124149. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124150. */
  124151. samplingMode: number;
  124152. /**
  124153. * Gets the loaded texture
  124154. */
  124155. texture: Texture;
  124156. /**
  124157. * Callback called when the task is successful
  124158. */
  124159. onSuccess: (task: TextureAssetTask) => void;
  124160. /**
  124161. * Callback called when the task is successful
  124162. */
  124163. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  124164. /**
  124165. * Creates a new TextureAssetTask object
  124166. * @param name defines the name of the task
  124167. * @param url defines the location of the file to load
  124168. * @param noMipmap defines if mipmap should not be generated (default is false)
  124169. * @param invertY defines if texture must be inverted on Y axis (default is false)
  124170. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124171. */
  124172. constructor(
  124173. /**
  124174. * Defines the name of the task
  124175. */
  124176. name: string,
  124177. /**
  124178. * Defines the location of the file to load
  124179. */
  124180. url: string,
  124181. /**
  124182. * Defines if mipmap should not be generated (default is false)
  124183. */
  124184. noMipmap?: boolean | undefined,
  124185. /**
  124186. * Defines if texture must be inverted on Y axis (default is false)
  124187. */
  124188. invertY?: boolean | undefined,
  124189. /**
  124190. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124191. */
  124192. samplingMode?: number);
  124193. /**
  124194. * Execute the current task
  124195. * @param scene defines the scene where you want your assets to be loaded
  124196. * @param onSuccess is a callback called when the task is successfully executed
  124197. * @param onError is a callback called if an error occurs
  124198. */
  124199. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124200. }
  124201. /**
  124202. * Define a task used by AssetsManager to load cube textures
  124203. */
  124204. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  124205. /**
  124206. * Defines the name of the task
  124207. */
  124208. name: string;
  124209. /**
  124210. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124211. */
  124212. url: string;
  124213. /**
  124214. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124215. */
  124216. extensions?: string[] | undefined;
  124217. /**
  124218. * Defines if mipmaps should not be generated (default is false)
  124219. */
  124220. noMipmap?: boolean | undefined;
  124221. /**
  124222. * Defines the explicit list of files (undefined by default)
  124223. */
  124224. files?: string[] | undefined;
  124225. /**
  124226. * Gets the loaded texture
  124227. */
  124228. texture: CubeTexture;
  124229. /**
  124230. * Callback called when the task is successful
  124231. */
  124232. onSuccess: (task: CubeTextureAssetTask) => void;
  124233. /**
  124234. * Callback called when the task is successful
  124235. */
  124236. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  124237. /**
  124238. * Creates a new CubeTextureAssetTask
  124239. * @param name defines the name of the task
  124240. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124241. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124242. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124243. * @param files defines the explicit list of files (undefined by default)
  124244. */
  124245. constructor(
  124246. /**
  124247. * Defines the name of the task
  124248. */
  124249. name: string,
  124250. /**
  124251. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124252. */
  124253. url: string,
  124254. /**
  124255. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124256. */
  124257. extensions?: string[] | undefined,
  124258. /**
  124259. * Defines if mipmaps should not be generated (default is false)
  124260. */
  124261. noMipmap?: boolean | undefined,
  124262. /**
  124263. * Defines the explicit list of files (undefined by default)
  124264. */
  124265. files?: string[] | undefined);
  124266. /**
  124267. * Execute the current task
  124268. * @param scene defines the scene where you want your assets to be loaded
  124269. * @param onSuccess is a callback called when the task is successfully executed
  124270. * @param onError is a callback called if an error occurs
  124271. */
  124272. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124273. }
  124274. /**
  124275. * Define a task used by AssetsManager to load HDR cube textures
  124276. */
  124277. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  124278. /**
  124279. * Defines the name of the task
  124280. */
  124281. name: string;
  124282. /**
  124283. * Defines the location of the file to load
  124284. */
  124285. url: string;
  124286. /**
  124287. * Defines the desired size (the more it increases the longer the generation will be)
  124288. */
  124289. size: number;
  124290. /**
  124291. * Defines if mipmaps should not be generated (default is false)
  124292. */
  124293. noMipmap: boolean;
  124294. /**
  124295. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124296. */
  124297. generateHarmonics: boolean;
  124298. /**
  124299. * 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)
  124300. */
  124301. gammaSpace: boolean;
  124302. /**
  124303. * Internal Use Only
  124304. */
  124305. reserved: boolean;
  124306. /**
  124307. * Gets the loaded texture
  124308. */
  124309. texture: HDRCubeTexture;
  124310. /**
  124311. * Callback called when the task is successful
  124312. */
  124313. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  124314. /**
  124315. * Callback called when the task is successful
  124316. */
  124317. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  124318. /**
  124319. * Creates a new HDRCubeTextureAssetTask object
  124320. * @param name defines the name of the task
  124321. * @param url defines the location of the file to load
  124322. * @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.
  124323. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124324. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124325. * @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)
  124326. * @param reserved Internal use only
  124327. */
  124328. constructor(
  124329. /**
  124330. * Defines the name of the task
  124331. */
  124332. name: string,
  124333. /**
  124334. * Defines the location of the file to load
  124335. */
  124336. url: string,
  124337. /**
  124338. * Defines the desired size (the more it increases the longer the generation will be)
  124339. */
  124340. size: number,
  124341. /**
  124342. * Defines if mipmaps should not be generated (default is false)
  124343. */
  124344. noMipmap?: boolean,
  124345. /**
  124346. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124347. */
  124348. generateHarmonics?: boolean,
  124349. /**
  124350. * 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)
  124351. */
  124352. gammaSpace?: boolean,
  124353. /**
  124354. * Internal Use Only
  124355. */
  124356. reserved?: boolean);
  124357. /**
  124358. * Execute the current task
  124359. * @param scene defines the scene where you want your assets to be loaded
  124360. * @param onSuccess is a callback called when the task is successfully executed
  124361. * @param onError is a callback called if an error occurs
  124362. */
  124363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124364. }
  124365. /**
  124366. * Define a task used by AssetsManager to load Equirectangular cube textures
  124367. */
  124368. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  124369. /**
  124370. * Defines the name of the task
  124371. */
  124372. name: string;
  124373. /**
  124374. * Defines the location of the file to load
  124375. */
  124376. url: string;
  124377. /**
  124378. * Defines the desired size (the more it increases the longer the generation will be)
  124379. */
  124380. size: number;
  124381. /**
  124382. * Defines if mipmaps should not be generated (default is false)
  124383. */
  124384. noMipmap: boolean;
  124385. /**
  124386. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124387. * but the standard material would require them in Gamma space) (default is true)
  124388. */
  124389. gammaSpace: boolean;
  124390. /**
  124391. * Gets the loaded texture
  124392. */
  124393. texture: EquiRectangularCubeTexture;
  124394. /**
  124395. * Callback called when the task is successful
  124396. */
  124397. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  124398. /**
  124399. * Callback called when the task is successful
  124400. */
  124401. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  124402. /**
  124403. * Creates a new EquiRectangularCubeTextureAssetTask object
  124404. * @param name defines the name of the task
  124405. * @param url defines the location of the file to load
  124406. * @param size defines the desired size (the more it increases the longer the generation will be)
  124407. * If the size is omitted this implies you are using a preprocessed cubemap.
  124408. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124409. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  124410. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  124411. * (default is true)
  124412. */
  124413. constructor(
  124414. /**
  124415. * Defines the name of the task
  124416. */
  124417. name: string,
  124418. /**
  124419. * Defines the location of the file to load
  124420. */
  124421. url: string,
  124422. /**
  124423. * Defines the desired size (the more it increases the longer the generation will be)
  124424. */
  124425. size: number,
  124426. /**
  124427. * Defines if mipmaps should not be generated (default is false)
  124428. */
  124429. noMipmap?: boolean,
  124430. /**
  124431. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124432. * but the standard material would require them in Gamma space) (default is true)
  124433. */
  124434. gammaSpace?: boolean);
  124435. /**
  124436. * Execute the current task
  124437. * @param scene defines the scene where you want your assets to be loaded
  124438. * @param onSuccess is a callback called when the task is successfully executed
  124439. * @param onError is a callback called if an error occurs
  124440. */
  124441. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124442. }
  124443. /**
  124444. * This class can be used to easily import assets into a scene
  124445. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  124446. */
  124447. export class AssetsManager {
  124448. private _scene;
  124449. private _isLoading;
  124450. protected _tasks: AbstractAssetTask[];
  124451. protected _waitingTasksCount: number;
  124452. protected _totalTasksCount: number;
  124453. /**
  124454. * Callback called when all tasks are processed
  124455. */
  124456. onFinish: (tasks: AbstractAssetTask[]) => void;
  124457. /**
  124458. * Callback called when a task is successful
  124459. */
  124460. onTaskSuccess: (task: AbstractAssetTask) => void;
  124461. /**
  124462. * Callback called when a task had an error
  124463. */
  124464. onTaskError: (task: AbstractAssetTask) => void;
  124465. /**
  124466. * Callback called when a task is done (whatever the result is)
  124467. */
  124468. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  124469. /**
  124470. * Observable called when all tasks are processed
  124471. */
  124472. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  124473. /**
  124474. * Observable called when a task had an error
  124475. */
  124476. onTaskErrorObservable: Observable<AbstractAssetTask>;
  124477. /**
  124478. * Observable called when all tasks were executed
  124479. */
  124480. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  124481. /**
  124482. * Observable called when a task is done (whatever the result is)
  124483. */
  124484. onProgressObservable: Observable<IAssetsProgressEvent>;
  124485. /**
  124486. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  124487. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  124488. */
  124489. useDefaultLoadingScreen: boolean;
  124490. /**
  124491. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  124492. * when all assets have been downloaded.
  124493. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  124494. */
  124495. autoHideLoadingUI: boolean;
  124496. /**
  124497. * Creates a new AssetsManager
  124498. * @param scene defines the scene to work on
  124499. */
  124500. constructor(scene: Scene);
  124501. /**
  124502. * Add a MeshAssetTask to the list of active tasks
  124503. * @param taskName defines the name of the new task
  124504. * @param meshesNames defines the name of meshes to load
  124505. * @param rootUrl defines the root url to use to locate files
  124506. * @param sceneFilename defines the filename of the scene file
  124507. * @returns a new MeshAssetTask object
  124508. */
  124509. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  124510. /**
  124511. * Add a TextFileAssetTask to the list of active tasks
  124512. * @param taskName defines the name of the new task
  124513. * @param url defines the url of the file to load
  124514. * @returns a new TextFileAssetTask object
  124515. */
  124516. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  124517. /**
  124518. * Add a BinaryFileAssetTask to the list of active tasks
  124519. * @param taskName defines the name of the new task
  124520. * @param url defines the url of the file to load
  124521. * @returns a new BinaryFileAssetTask object
  124522. */
  124523. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  124524. /**
  124525. * Add a ImageAssetTask to the list of active tasks
  124526. * @param taskName defines the name of the new task
  124527. * @param url defines the url of the file to load
  124528. * @returns a new ImageAssetTask object
  124529. */
  124530. addImageTask(taskName: string, url: string): ImageAssetTask;
  124531. /**
  124532. * Add a TextureAssetTask to the list of active tasks
  124533. * @param taskName defines the name of the new task
  124534. * @param url defines the url of the file to load
  124535. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124536. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  124537. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  124538. * @returns a new TextureAssetTask object
  124539. */
  124540. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  124541. /**
  124542. * Add a CubeTextureAssetTask to the list of active tasks
  124543. * @param taskName defines the name of the new task
  124544. * @param url defines the url of the file to load
  124545. * @param extensions defines the extension to use to load the cube map (can be null)
  124546. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124547. * @param files defines the list of files to load (can be null)
  124548. * @returns a new CubeTextureAssetTask object
  124549. */
  124550. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  124551. /**
  124552. *
  124553. * Add a HDRCubeTextureAssetTask to the list of active tasks
  124554. * @param taskName defines the name of the new task
  124555. * @param url defines the url of the file to load
  124556. * @param size defines the size you want for the cubemap (can be null)
  124557. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124558. * @param generateHarmonics defines if you want to automatically generate (true by default)
  124559. * @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)
  124560. * @param reserved Internal use only
  124561. * @returns a new HDRCubeTextureAssetTask object
  124562. */
  124563. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  124564. /**
  124565. *
  124566. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  124567. * @param taskName defines the name of the new task
  124568. * @param url defines the url of the file to load
  124569. * @param size defines the size you want for the cubemap (can be null)
  124570. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124571. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  124572. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  124573. * @returns a new EquiRectangularCubeTextureAssetTask object
  124574. */
  124575. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  124576. /**
  124577. * Remove a task from the assets manager.
  124578. * @param task the task to remove
  124579. */
  124580. removeTask(task: AbstractAssetTask): void;
  124581. private _decreaseWaitingTasksCount;
  124582. private _runTask;
  124583. /**
  124584. * Reset the AssetsManager and remove all tasks
  124585. * @return the current instance of the AssetsManager
  124586. */
  124587. reset(): AssetsManager;
  124588. /**
  124589. * Start the loading process
  124590. * @return the current instance of the AssetsManager
  124591. */
  124592. load(): AssetsManager;
  124593. /**
  124594. * Start the loading process as an async operation
  124595. * @return a promise returning the list of failed tasks
  124596. */
  124597. loadAsync(): Promise<void>;
  124598. }
  124599. }
  124600. declare module BABYLON {
  124601. /**
  124602. * Wrapper class for promise with external resolve and reject.
  124603. */
  124604. export class Deferred<T> {
  124605. /**
  124606. * The promise associated with this deferred object.
  124607. */
  124608. readonly promise: Promise<T>;
  124609. private _resolve;
  124610. private _reject;
  124611. /**
  124612. * The resolve method of the promise associated with this deferred object.
  124613. */
  124614. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  124615. /**
  124616. * The reject method of the promise associated with this deferred object.
  124617. */
  124618. readonly reject: (reason?: any) => void;
  124619. /**
  124620. * Constructor for this deferred object.
  124621. */
  124622. constructor();
  124623. }
  124624. }
  124625. declare module BABYLON {
  124626. /**
  124627. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  124628. */
  124629. export class MeshExploder {
  124630. private _centerMesh;
  124631. private _meshes;
  124632. private _meshesOrigins;
  124633. private _toCenterVectors;
  124634. private _scaledDirection;
  124635. private _newPosition;
  124636. private _centerPosition;
  124637. /**
  124638. * Explodes meshes from a center mesh.
  124639. * @param meshes The meshes to explode.
  124640. * @param centerMesh The mesh to be center of explosion.
  124641. */
  124642. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  124643. private _setCenterMesh;
  124644. /**
  124645. * Get class name
  124646. * @returns "MeshExploder"
  124647. */
  124648. getClassName(): string;
  124649. /**
  124650. * "Exploded meshes"
  124651. * @returns Array of meshes with the centerMesh at index 0.
  124652. */
  124653. getMeshes(): Array<Mesh>;
  124654. /**
  124655. * Explodes meshes giving a specific direction
  124656. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  124657. */
  124658. explode(direction?: number): void;
  124659. }
  124660. }
  124661. declare module BABYLON {
  124662. /**
  124663. * Class used to help managing file picking and drag'n'drop
  124664. */
  124665. export class FilesInput {
  124666. /**
  124667. * List of files ready to be loaded
  124668. */
  124669. static readonly FilesToLoad: {
  124670. [key: string]: File;
  124671. };
  124672. /**
  124673. * Callback called when a file is processed
  124674. */
  124675. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  124676. private _engine;
  124677. private _currentScene;
  124678. private _sceneLoadedCallback;
  124679. private _progressCallback;
  124680. private _additionalRenderLoopLogicCallback;
  124681. private _textureLoadingCallback;
  124682. private _startingProcessingFilesCallback;
  124683. private _onReloadCallback;
  124684. private _errorCallback;
  124685. private _elementToMonitor;
  124686. private _sceneFileToLoad;
  124687. private _filesToLoad;
  124688. /**
  124689. * Creates a new FilesInput
  124690. * @param engine defines the rendering engine
  124691. * @param scene defines the hosting scene
  124692. * @param sceneLoadedCallback callback called when scene is loaded
  124693. * @param progressCallback callback called to track progress
  124694. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  124695. * @param textureLoadingCallback callback called when a texture is loading
  124696. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  124697. * @param onReloadCallback callback called when a reload is requested
  124698. * @param errorCallback callback call if an error occurs
  124699. */
  124700. 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);
  124701. private _dragEnterHandler;
  124702. private _dragOverHandler;
  124703. private _dropHandler;
  124704. /**
  124705. * Calls this function to listen to drag'n'drop events on a specific DOM element
  124706. * @param elementToMonitor defines the DOM element to track
  124707. */
  124708. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  124709. /**
  124710. * Release all associated resources
  124711. */
  124712. dispose(): void;
  124713. private renderFunction;
  124714. private drag;
  124715. private drop;
  124716. private _traverseFolder;
  124717. private _processFiles;
  124718. /**
  124719. * Load files from a drop event
  124720. * @param event defines the drop event to use as source
  124721. */
  124722. loadFiles(event: any): void;
  124723. private _processReload;
  124724. /**
  124725. * Reload the current scene from the loaded files
  124726. */
  124727. reload(): void;
  124728. }
  124729. }
  124730. declare module BABYLON {
  124731. /**
  124732. * Defines the root class used to create scene optimization to use with SceneOptimizer
  124733. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124734. */
  124735. export class SceneOptimization {
  124736. /**
  124737. * Defines the priority of this optimization (0 by default which means first in the list)
  124738. */
  124739. priority: number;
  124740. /**
  124741. * Gets a string describing the action executed by the current optimization
  124742. * @returns description string
  124743. */
  124744. getDescription(): string;
  124745. /**
  124746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124747. * @param scene defines the current scene where to apply this optimization
  124748. * @param optimizer defines the current optimizer
  124749. * @returns true if everything that can be done was applied
  124750. */
  124751. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124752. /**
  124753. * Creates the SceneOptimization object
  124754. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124755. * @param desc defines the description associated with the optimization
  124756. */
  124757. constructor(
  124758. /**
  124759. * Defines the priority of this optimization (0 by default which means first in the list)
  124760. */
  124761. priority?: number);
  124762. }
  124763. /**
  124764. * Defines an optimization used to reduce the size of render target textures
  124765. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124766. */
  124767. export class TextureOptimization extends SceneOptimization {
  124768. /**
  124769. * Defines the priority of this optimization (0 by default which means first in the list)
  124770. */
  124771. priority: number;
  124772. /**
  124773. * 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
  124774. */
  124775. maximumSize: number;
  124776. /**
  124777. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  124778. */
  124779. step: number;
  124780. /**
  124781. * Gets a string describing the action executed by the current optimization
  124782. * @returns description string
  124783. */
  124784. getDescription(): string;
  124785. /**
  124786. * Creates the TextureOptimization object
  124787. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124788. * @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
  124789. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  124790. */
  124791. constructor(
  124792. /**
  124793. * Defines the priority of this optimization (0 by default which means first in the list)
  124794. */
  124795. priority?: number,
  124796. /**
  124797. * 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
  124798. */
  124799. maximumSize?: number,
  124800. /**
  124801. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  124802. */
  124803. step?: number);
  124804. /**
  124805. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124806. * @param scene defines the current scene where to apply this optimization
  124807. * @param optimizer defines the current optimizer
  124808. * @returns true if everything that can be done was applied
  124809. */
  124810. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124811. }
  124812. /**
  124813. * Defines an optimization used to increase or decrease the rendering resolution
  124814. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124815. */
  124816. export class HardwareScalingOptimization extends SceneOptimization {
  124817. /**
  124818. * Defines the priority of this optimization (0 by default which means first in the list)
  124819. */
  124820. priority: number;
  124821. /**
  124822. * Defines the maximum scale to use (2 by default)
  124823. */
  124824. maximumScale: number;
  124825. /**
  124826. * Defines the step to use between two passes (0.5 by default)
  124827. */
  124828. step: number;
  124829. private _currentScale;
  124830. private _directionOffset;
  124831. /**
  124832. * Gets a string describing the action executed by the current optimization
  124833. * @return description string
  124834. */
  124835. getDescription(): string;
  124836. /**
  124837. * Creates the HardwareScalingOptimization object
  124838. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124839. * @param maximumScale defines the maximum scale to use (2 by default)
  124840. * @param step defines the step to use between two passes (0.5 by default)
  124841. */
  124842. constructor(
  124843. /**
  124844. * Defines the priority of this optimization (0 by default which means first in the list)
  124845. */
  124846. priority?: number,
  124847. /**
  124848. * Defines the maximum scale to use (2 by default)
  124849. */
  124850. maximumScale?: number,
  124851. /**
  124852. * Defines the step to use between two passes (0.5 by default)
  124853. */
  124854. step?: number);
  124855. /**
  124856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124857. * @param scene defines the current scene where to apply this optimization
  124858. * @param optimizer defines the current optimizer
  124859. * @returns true if everything that can be done was applied
  124860. */
  124861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124862. }
  124863. /**
  124864. * Defines an optimization used to remove shadows
  124865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124866. */
  124867. export class ShadowsOptimization extends SceneOptimization {
  124868. /**
  124869. * Gets a string describing the action executed by the current optimization
  124870. * @return description string
  124871. */
  124872. getDescription(): string;
  124873. /**
  124874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124875. * @param scene defines the current scene where to apply this optimization
  124876. * @param optimizer defines the current optimizer
  124877. * @returns true if everything that can be done was applied
  124878. */
  124879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124880. }
  124881. /**
  124882. * Defines an optimization used to turn post-processes off
  124883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124884. */
  124885. export class PostProcessesOptimization extends SceneOptimization {
  124886. /**
  124887. * Gets a string describing the action executed by the current optimization
  124888. * @return description string
  124889. */
  124890. getDescription(): string;
  124891. /**
  124892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124893. * @param scene defines the current scene where to apply this optimization
  124894. * @param optimizer defines the current optimizer
  124895. * @returns true if everything that can be done was applied
  124896. */
  124897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124898. }
  124899. /**
  124900. * Defines an optimization used to turn lens flares off
  124901. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124902. */
  124903. export class LensFlaresOptimization extends SceneOptimization {
  124904. /**
  124905. * Gets a string describing the action executed by the current optimization
  124906. * @return description string
  124907. */
  124908. getDescription(): string;
  124909. /**
  124910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124911. * @param scene defines the current scene where to apply this optimization
  124912. * @param optimizer defines the current optimizer
  124913. * @returns true if everything that can be done was applied
  124914. */
  124915. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124916. }
  124917. /**
  124918. * Defines an optimization based on user defined callback.
  124919. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124920. */
  124921. export class CustomOptimization extends SceneOptimization {
  124922. /**
  124923. * Callback called to apply the custom optimization.
  124924. */
  124925. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  124926. /**
  124927. * Callback called to get custom description
  124928. */
  124929. onGetDescription: () => string;
  124930. /**
  124931. * Gets a string describing the action executed by the current optimization
  124932. * @returns description string
  124933. */
  124934. getDescription(): string;
  124935. /**
  124936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124937. * @param scene defines the current scene where to apply this optimization
  124938. * @param optimizer defines the current optimizer
  124939. * @returns true if everything that can be done was applied
  124940. */
  124941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124942. }
  124943. /**
  124944. * Defines an optimization used to turn particles off
  124945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124946. */
  124947. export class ParticlesOptimization extends SceneOptimization {
  124948. /**
  124949. * Gets a string describing the action executed by the current optimization
  124950. * @return description string
  124951. */
  124952. getDescription(): string;
  124953. /**
  124954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124955. * @param scene defines the current scene where to apply this optimization
  124956. * @param optimizer defines the current optimizer
  124957. * @returns true if everything that can be done was applied
  124958. */
  124959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124960. }
  124961. /**
  124962. * Defines an optimization used to turn render targets off
  124963. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124964. */
  124965. export class RenderTargetsOptimization extends SceneOptimization {
  124966. /**
  124967. * Gets a string describing the action executed by the current optimization
  124968. * @return description string
  124969. */
  124970. getDescription(): string;
  124971. /**
  124972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124973. * @param scene defines the current scene where to apply this optimization
  124974. * @param optimizer defines the current optimizer
  124975. * @returns true if everything that can be done was applied
  124976. */
  124977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124978. }
  124979. /**
  124980. * Defines an optimization used to merge meshes with compatible materials
  124981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124982. */
  124983. export class MergeMeshesOptimization extends SceneOptimization {
  124984. private static _UpdateSelectionTree;
  124985. /**
  124986. * Gets or sets a boolean which defines if optimization octree has to be updated
  124987. */
  124988. /**
  124989. * Gets or sets a boolean which defines if optimization octree has to be updated
  124990. */
  124991. static UpdateSelectionTree: boolean;
  124992. /**
  124993. * Gets a string describing the action executed by the current optimization
  124994. * @return description string
  124995. */
  124996. getDescription(): string;
  124997. private _canBeMerged;
  124998. /**
  124999. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125000. * @param scene defines the current scene where to apply this optimization
  125001. * @param optimizer defines the current optimizer
  125002. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  125003. * @returns true if everything that can be done was applied
  125004. */
  125005. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  125006. }
  125007. /**
  125008. * Defines a list of options used by SceneOptimizer
  125009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125010. */
  125011. export class SceneOptimizerOptions {
  125012. /**
  125013. * Defines the target frame rate to reach (60 by default)
  125014. */
  125015. targetFrameRate: number;
  125016. /**
  125017. * Defines the interval between two checkes (2000ms by default)
  125018. */
  125019. trackerDuration: number;
  125020. /**
  125021. * Gets the list of optimizations to apply
  125022. */
  125023. optimizations: SceneOptimization[];
  125024. /**
  125025. * Creates a new list of options used by SceneOptimizer
  125026. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  125027. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  125028. */
  125029. constructor(
  125030. /**
  125031. * Defines the target frame rate to reach (60 by default)
  125032. */
  125033. targetFrameRate?: number,
  125034. /**
  125035. * Defines the interval between two checkes (2000ms by default)
  125036. */
  125037. trackerDuration?: number);
  125038. /**
  125039. * Add a new optimization
  125040. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  125041. * @returns the current SceneOptimizerOptions
  125042. */
  125043. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  125044. /**
  125045. * Add a new custom optimization
  125046. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  125047. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  125048. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125049. * @returns the current SceneOptimizerOptions
  125050. */
  125051. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  125052. /**
  125053. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  125054. * @param targetFrameRate defines the target frame rate (60 by default)
  125055. * @returns a SceneOptimizerOptions object
  125056. */
  125057. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125058. /**
  125059. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  125060. * @param targetFrameRate defines the target frame rate (60 by default)
  125061. * @returns a SceneOptimizerOptions object
  125062. */
  125063. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125064. /**
  125065. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  125066. * @param targetFrameRate defines the target frame rate (60 by default)
  125067. * @returns a SceneOptimizerOptions object
  125068. */
  125069. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125070. }
  125071. /**
  125072. * Class used to run optimizations in order to reach a target frame rate
  125073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125074. */
  125075. export class SceneOptimizer implements IDisposable {
  125076. private _isRunning;
  125077. private _options;
  125078. private _scene;
  125079. private _currentPriorityLevel;
  125080. private _targetFrameRate;
  125081. private _trackerDuration;
  125082. private _currentFrameRate;
  125083. private _sceneDisposeObserver;
  125084. private _improvementMode;
  125085. /**
  125086. * Defines an observable called when the optimizer reaches the target frame rate
  125087. */
  125088. onSuccessObservable: Observable<SceneOptimizer>;
  125089. /**
  125090. * Defines an observable called when the optimizer enables an optimization
  125091. */
  125092. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  125093. /**
  125094. * Defines an observable called when the optimizer is not able to reach the target frame rate
  125095. */
  125096. onFailureObservable: Observable<SceneOptimizer>;
  125097. /**
  125098. * Gets a boolean indicating if the optimizer is in improvement mode
  125099. */
  125100. readonly isInImprovementMode: boolean;
  125101. /**
  125102. * Gets the current priority level (0 at start)
  125103. */
  125104. readonly currentPriorityLevel: number;
  125105. /**
  125106. * Gets the current frame rate checked by the SceneOptimizer
  125107. */
  125108. readonly currentFrameRate: number;
  125109. /**
  125110. * Gets or sets the current target frame rate (60 by default)
  125111. */
  125112. /**
  125113. * Gets or sets the current target frame rate (60 by default)
  125114. */
  125115. targetFrameRate: number;
  125116. /**
  125117. * Gets or sets the current interval between two checks (every 2000ms by default)
  125118. */
  125119. /**
  125120. * Gets or sets the current interval between two checks (every 2000ms by default)
  125121. */
  125122. trackerDuration: number;
  125123. /**
  125124. * Gets the list of active optimizations
  125125. */
  125126. readonly optimizations: SceneOptimization[];
  125127. /**
  125128. * Creates a new SceneOptimizer
  125129. * @param scene defines the scene to work on
  125130. * @param options defines the options to use with the SceneOptimizer
  125131. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  125132. * @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)
  125133. */
  125134. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  125135. /**
  125136. * Stops the current optimizer
  125137. */
  125138. stop(): void;
  125139. /**
  125140. * Reset the optimizer to initial step (current priority level = 0)
  125141. */
  125142. reset(): void;
  125143. /**
  125144. * Start the optimizer. By default it will try to reach a specific framerate
  125145. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  125146. */
  125147. start(): void;
  125148. private _checkCurrentState;
  125149. /**
  125150. * Release all resources
  125151. */
  125152. dispose(): void;
  125153. /**
  125154. * Helper function to create a SceneOptimizer with one single line of code
  125155. * @param scene defines the scene to work on
  125156. * @param options defines the options to use with the SceneOptimizer
  125157. * @param onSuccess defines a callback to call on success
  125158. * @param onFailure defines a callback to call on failure
  125159. * @returns the new SceneOptimizer object
  125160. */
  125161. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  125162. }
  125163. }
  125164. declare module BABYLON {
  125165. /**
  125166. * Class used to serialize a scene into a string
  125167. */
  125168. export class SceneSerializer {
  125169. /**
  125170. * Clear cache used by a previous serialization
  125171. */
  125172. static ClearCache(): void;
  125173. /**
  125174. * Serialize a scene into a JSON compatible object
  125175. * @param scene defines the scene to serialize
  125176. * @returns a JSON compatible object
  125177. */
  125178. static Serialize(scene: Scene): any;
  125179. /**
  125180. * Serialize a mesh into a JSON compatible object
  125181. * @param toSerialize defines the mesh to serialize
  125182. * @param withParents defines if parents must be serialized as well
  125183. * @param withChildren defines if children must be serialized as well
  125184. * @returns a JSON compatible object
  125185. */
  125186. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  125187. }
  125188. }
  125189. declare module BABYLON {
  125190. /**
  125191. * Class used to host texture specific utilities
  125192. */
  125193. export class TextureTools {
  125194. /**
  125195. * Uses the GPU to create a copy texture rescaled at a given size
  125196. * @param texture Texture to copy from
  125197. * @param width defines the desired width
  125198. * @param height defines the desired height
  125199. * @param useBilinearMode defines if bilinear mode has to be used
  125200. * @return the generated texture
  125201. */
  125202. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  125203. }
  125204. }
  125205. declare module BABYLON {
  125206. /**
  125207. * This represents the different options available for the video capture.
  125208. */
  125209. export interface VideoRecorderOptions {
  125210. /** Defines the mime type of the video. */
  125211. mimeType: string;
  125212. /** Defines the FPS the video should be recorded at. */
  125213. fps: number;
  125214. /** Defines the chunk size for the recording data. */
  125215. recordChunckSize: number;
  125216. /** The audio tracks to attach to the recording. */
  125217. audioTracks?: MediaStreamTrack[];
  125218. }
  125219. /**
  125220. * This can help with recording videos from BabylonJS.
  125221. * This is based on the available WebRTC functionalities of the browser.
  125222. *
  125223. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  125224. */
  125225. export class VideoRecorder {
  125226. private static readonly _defaultOptions;
  125227. /**
  125228. * Returns whether or not the VideoRecorder is available in your browser.
  125229. * @param engine Defines the Babylon Engine.
  125230. * @returns true if supported otherwise false.
  125231. */
  125232. static IsSupported(engine: Engine): boolean;
  125233. private readonly _options;
  125234. private _canvas;
  125235. private _mediaRecorder;
  125236. private _recordedChunks;
  125237. private _fileName;
  125238. private _resolve;
  125239. private _reject;
  125240. /**
  125241. * True when a recording is already in progress.
  125242. */
  125243. readonly isRecording: boolean;
  125244. /**
  125245. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  125246. * @param engine Defines the BabylonJS Engine you wish to record.
  125247. * @param options Defines options that can be used to customize the capture.
  125248. */
  125249. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  125250. /**
  125251. * Stops the current recording before the default capture timeout passed in the startRecording function.
  125252. */
  125253. stopRecording(): void;
  125254. /**
  125255. * Starts recording the canvas for a max duration specified in parameters.
  125256. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  125257. * If null no automatic download will start and you can rely on the promise to get the data back.
  125258. * @param maxDuration Defines the maximum recording time in seconds.
  125259. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  125260. * @return A promise callback at the end of the recording with the video data in Blob.
  125261. */
  125262. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  125263. /**
  125264. * Releases internal resources used during the recording.
  125265. */
  125266. dispose(): void;
  125267. private _handleDataAvailable;
  125268. private _handleError;
  125269. private _handleStop;
  125270. }
  125271. }
  125272. declare module BABYLON {
  125273. /**
  125274. * Class containing a set of static utilities functions for screenshots
  125275. */
  125276. export class ScreenshotTools {
  125277. /**
  125278. * Captures a screenshot of the current rendering
  125279. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125280. * @param engine defines the rendering engine
  125281. * @param camera defines the source camera
  125282. * @param size This parameter can be set to a single number or to an object with the
  125283. * following (optional) properties: precision, width, height. If a single number is passed,
  125284. * it will be used for both width and height. If an object is passed, the screenshot size
  125285. * will be derived from the parameters. The precision property is a multiplier allowing
  125286. * rendering at a higher or lower resolution
  125287. * @param successCallback defines the callback receives a single parameter which contains the
  125288. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  125289. * src parameter of an <img> to display it
  125290. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  125291. * Check your browser for supported MIME types
  125292. */
  125293. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  125294. /**
  125295. * Captures a screenshot of the current rendering
  125296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125297. * @param engine defines the rendering engine
  125298. * @param camera defines the source camera
  125299. * @param size This parameter can be set to a single number or to an object with the
  125300. * following (optional) properties: precision, width, height. If a single number is passed,
  125301. * it will be used for both width and height. If an object is passed, the screenshot size
  125302. * will be derived from the parameters. The precision property is a multiplier allowing
  125303. * rendering at a higher or lower resolution
  125304. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  125305. * Check your browser for supported MIME types
  125306. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  125307. * to the src parameter of an <img> to display it
  125308. */
  125309. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  125310. /**
  125311. * Generates an image screenshot from the specified camera.
  125312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125313. * @param engine The engine to use for rendering
  125314. * @param camera The camera to use for rendering
  125315. * @param size This parameter can be set to a single number or to an object with the
  125316. * following (optional) properties: precision, width, height. If a single number is passed,
  125317. * it will be used for both width and height. If an object is passed, the screenshot size
  125318. * will be derived from the parameters. The precision property is a multiplier allowing
  125319. * rendering at a higher or lower resolution
  125320. * @param successCallback The callback receives a single parameter which contains the
  125321. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  125322. * src parameter of an <img> to display it
  125323. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125324. * Check your browser for supported MIME types
  125325. * @param samples Texture samples (default: 1)
  125326. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125327. * @param fileName A name for for the downloaded file.
  125328. */
  125329. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  125330. /**
  125331. * Generates an image screenshot from the specified camera.
  125332. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125333. * @param engine The engine to use for rendering
  125334. * @param camera The camera to use for rendering
  125335. * @param size This parameter can be set to a single number or to an object with the
  125336. * following (optional) properties: precision, width, height. If a single number is passed,
  125337. * it will be used for both width and height. If an object is passed, the screenshot size
  125338. * will be derived from the parameters. The precision property is a multiplier allowing
  125339. * rendering at a higher or lower resolution
  125340. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125341. * Check your browser for supported MIME types
  125342. * @param samples Texture samples (default: 1)
  125343. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125344. * @param fileName A name for for the downloaded file.
  125345. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  125346. * to the src parameter of an <img> to display it
  125347. */
  125348. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  125349. /**
  125350. * Gets height and width for screenshot size
  125351. * @private
  125352. */
  125353. private static _getScreenshotSize;
  125354. }
  125355. }
  125356. declare module BABYLON {
  125357. /**
  125358. * A cursor which tracks a point on a path
  125359. */
  125360. export class PathCursor {
  125361. private path;
  125362. /**
  125363. * Stores path cursor callbacks for when an onchange event is triggered
  125364. */
  125365. private _onchange;
  125366. /**
  125367. * The value of the path cursor
  125368. */
  125369. value: number;
  125370. /**
  125371. * The animation array of the path cursor
  125372. */
  125373. animations: Animation[];
  125374. /**
  125375. * Initializes the path cursor
  125376. * @param path The path to track
  125377. */
  125378. constructor(path: Path2);
  125379. /**
  125380. * Gets the cursor point on the path
  125381. * @returns A point on the path cursor at the cursor location
  125382. */
  125383. getPoint(): Vector3;
  125384. /**
  125385. * Moves the cursor ahead by the step amount
  125386. * @param step The amount to move the cursor forward
  125387. * @returns This path cursor
  125388. */
  125389. moveAhead(step?: number): PathCursor;
  125390. /**
  125391. * Moves the cursor behind by the step amount
  125392. * @param step The amount to move the cursor back
  125393. * @returns This path cursor
  125394. */
  125395. moveBack(step?: number): PathCursor;
  125396. /**
  125397. * Moves the cursor by the step amount
  125398. * If the step amount is greater than one, an exception is thrown
  125399. * @param step The amount to move the cursor
  125400. * @returns This path cursor
  125401. */
  125402. move(step: number): PathCursor;
  125403. /**
  125404. * Ensures that the value is limited between zero and one
  125405. * @returns This path cursor
  125406. */
  125407. private ensureLimits;
  125408. /**
  125409. * Runs onchange callbacks on change (used by the animation engine)
  125410. * @returns This path cursor
  125411. */
  125412. private raiseOnChange;
  125413. /**
  125414. * Executes a function on change
  125415. * @param f A path cursor onchange callback
  125416. * @returns This path cursor
  125417. */
  125418. onchange(f: (cursor: PathCursor) => void): PathCursor;
  125419. }
  125420. }
  125421. declare module BABYLON {
  125422. /** @hidden */
  125423. export var blurPixelShader: {
  125424. name: string;
  125425. shader: string;
  125426. };
  125427. }
  125428. declare module BABYLON {
  125429. /** @hidden */
  125430. export var pointCloudVertexDeclaration: {
  125431. name: string;
  125432. shader: string;
  125433. };
  125434. }
  125435. // Mixins
  125436. interface Window {
  125437. mozIndexedDB: IDBFactory;
  125438. webkitIndexedDB: IDBFactory;
  125439. msIndexedDB: IDBFactory;
  125440. webkitURL: typeof URL;
  125441. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  125442. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  125443. WebGLRenderingContext: WebGLRenderingContext;
  125444. MSGesture: MSGesture;
  125445. CANNON: any;
  125446. AudioContext: AudioContext;
  125447. webkitAudioContext: AudioContext;
  125448. PointerEvent: any;
  125449. Math: Math;
  125450. Uint8Array: Uint8ArrayConstructor;
  125451. Float32Array: Float32ArrayConstructor;
  125452. mozURL: typeof URL;
  125453. msURL: typeof URL;
  125454. VRFrameData: any; // WebVR, from specs 1.1
  125455. DracoDecoderModule: any;
  125456. setImmediate(handler: (...args: any[]) => void): number;
  125457. }
  125458. interface HTMLCanvasElement {
  125459. requestPointerLock(): void;
  125460. msRequestPointerLock?(): void;
  125461. mozRequestPointerLock?(): void;
  125462. webkitRequestPointerLock?(): void;
  125463. /** Track wether a record is in progress */
  125464. isRecording: boolean;
  125465. /** Capture Stream method defined by some browsers */
  125466. captureStream(fps?: number): MediaStream;
  125467. }
  125468. interface CanvasRenderingContext2D {
  125469. msImageSmoothingEnabled: boolean;
  125470. }
  125471. interface MouseEvent {
  125472. mozMovementX: number;
  125473. mozMovementY: number;
  125474. webkitMovementX: number;
  125475. webkitMovementY: number;
  125476. msMovementX: number;
  125477. msMovementY: number;
  125478. }
  125479. interface Navigator {
  125480. mozGetVRDevices: (any: any) => any;
  125481. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125482. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125483. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125484. webkitGetGamepads(): Gamepad[];
  125485. msGetGamepads(): Gamepad[];
  125486. webkitGamepads(): Gamepad[];
  125487. }
  125488. interface HTMLVideoElement {
  125489. mozSrcObject: any;
  125490. }
  125491. interface Math {
  125492. fround(x: number): number;
  125493. imul(a: number, b: number): number;
  125494. }
  125495. interface WebGLRenderingContext {
  125496. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  125497. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  125498. vertexAttribDivisor(index: number, divisor: number): void;
  125499. createVertexArray(): any;
  125500. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  125501. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  125502. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  125503. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  125504. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  125505. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  125506. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  125507. // Queries
  125508. createQuery(): WebGLQuery;
  125509. deleteQuery(query: WebGLQuery): void;
  125510. beginQuery(target: number, query: WebGLQuery): void;
  125511. endQuery(target: number): void;
  125512. getQueryParameter(query: WebGLQuery, pname: number): any;
  125513. getQuery(target: number, pname: number): any;
  125514. MAX_SAMPLES: number;
  125515. RGBA8: number;
  125516. READ_FRAMEBUFFER: number;
  125517. DRAW_FRAMEBUFFER: number;
  125518. UNIFORM_BUFFER: number;
  125519. HALF_FLOAT_OES: number;
  125520. RGBA16F: number;
  125521. RGBA32F: number;
  125522. R32F: number;
  125523. RG32F: number;
  125524. RGB32F: number;
  125525. R16F: number;
  125526. RG16F: number;
  125527. RGB16F: number;
  125528. RED: number;
  125529. RG: number;
  125530. R8: number;
  125531. RG8: number;
  125532. UNSIGNED_INT_24_8: number;
  125533. DEPTH24_STENCIL8: number;
  125534. /* Multiple Render Targets */
  125535. drawBuffers(buffers: number[]): void;
  125536. readBuffer(src: number): void;
  125537. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  125538. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  125539. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  125540. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  125541. // Occlusion Query
  125542. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  125543. ANY_SAMPLES_PASSED: number;
  125544. QUERY_RESULT_AVAILABLE: number;
  125545. QUERY_RESULT: number;
  125546. }
  125547. interface WebGLProgram {
  125548. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  125549. }
  125550. interface EXT_disjoint_timer_query {
  125551. QUERY_COUNTER_BITS_EXT: number;
  125552. TIME_ELAPSED_EXT: number;
  125553. TIMESTAMP_EXT: number;
  125554. GPU_DISJOINT_EXT: number;
  125555. QUERY_RESULT_EXT: number;
  125556. QUERY_RESULT_AVAILABLE_EXT: number;
  125557. queryCounterEXT(query: WebGLQuery, target: number): void;
  125558. createQueryEXT(): WebGLQuery;
  125559. beginQueryEXT(target: number, query: WebGLQuery): void;
  125560. endQueryEXT(target: number): void;
  125561. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  125562. deleteQueryEXT(query: WebGLQuery): void;
  125563. }
  125564. interface WebGLUniformLocation {
  125565. _currentState: any;
  125566. }
  125567. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  125568. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  125569. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  125570. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  125571. interface WebGLRenderingContext {
  125572. readonly RASTERIZER_DISCARD: number;
  125573. readonly DEPTH_COMPONENT24: number;
  125574. readonly TEXTURE_3D: number;
  125575. readonly TEXTURE_2D_ARRAY: number;
  125576. readonly TEXTURE_COMPARE_FUNC: number;
  125577. readonly TEXTURE_COMPARE_MODE: number;
  125578. readonly COMPARE_REF_TO_TEXTURE: number;
  125579. readonly TEXTURE_WRAP_R: number;
  125580. readonly HALF_FLOAT: number;
  125581. readonly RGB8: number;
  125582. readonly RED_INTEGER: number;
  125583. readonly RG_INTEGER: number;
  125584. readonly RGB_INTEGER: number;
  125585. readonly RGBA_INTEGER: number;
  125586. readonly R8_SNORM: number;
  125587. readonly RG8_SNORM: number;
  125588. readonly RGB8_SNORM: number;
  125589. readonly RGBA8_SNORM: number;
  125590. readonly R8I: number;
  125591. readonly RG8I: number;
  125592. readonly RGB8I: number;
  125593. readonly RGBA8I: number;
  125594. readonly R8UI: number;
  125595. readonly RG8UI: number;
  125596. readonly RGB8UI: number;
  125597. readonly RGBA8UI: number;
  125598. readonly R16I: number;
  125599. readonly RG16I: number;
  125600. readonly RGB16I: number;
  125601. readonly RGBA16I: number;
  125602. readonly R16UI: number;
  125603. readonly RG16UI: number;
  125604. readonly RGB16UI: number;
  125605. readonly RGBA16UI: number;
  125606. readonly R32I: number;
  125607. readonly RG32I: number;
  125608. readonly RGB32I: number;
  125609. readonly RGBA32I: number;
  125610. readonly R32UI: number;
  125611. readonly RG32UI: number;
  125612. readonly RGB32UI: number;
  125613. readonly RGBA32UI: number;
  125614. readonly RGB10_A2UI: number;
  125615. readonly R11F_G11F_B10F: number;
  125616. readonly RGB9_E5: number;
  125617. readonly RGB10_A2: number;
  125618. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  125619. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  125620. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  125621. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  125622. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  125623. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  125624. 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;
  125625. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  125626. readonly TRANSFORM_FEEDBACK: number;
  125627. readonly INTERLEAVED_ATTRIBS: number;
  125628. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  125629. createTransformFeedback(): WebGLTransformFeedback;
  125630. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  125631. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  125632. beginTransformFeedback(primitiveMode: number): void;
  125633. endTransformFeedback(): void;
  125634. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  125635. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125636. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125637. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125638. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  125639. }
  125640. interface ImageBitmap {
  125641. readonly width: number;
  125642. readonly height: number;
  125643. close(): void;
  125644. }
  125645. interface WebGLQuery extends WebGLObject {
  125646. }
  125647. declare var WebGLQuery: {
  125648. prototype: WebGLQuery;
  125649. new(): WebGLQuery;
  125650. };
  125651. interface WebGLSampler extends WebGLObject {
  125652. }
  125653. declare var WebGLSampler: {
  125654. prototype: WebGLSampler;
  125655. new(): WebGLSampler;
  125656. };
  125657. interface WebGLSync extends WebGLObject {
  125658. }
  125659. declare var WebGLSync: {
  125660. prototype: WebGLSync;
  125661. new(): WebGLSync;
  125662. };
  125663. interface WebGLTransformFeedback extends WebGLObject {
  125664. }
  125665. declare var WebGLTransformFeedback: {
  125666. prototype: WebGLTransformFeedback;
  125667. new(): WebGLTransformFeedback;
  125668. };
  125669. interface WebGLVertexArrayObject extends WebGLObject {
  125670. }
  125671. declare var WebGLVertexArrayObject: {
  125672. prototype: WebGLVertexArrayObject;
  125673. new(): WebGLVertexArrayObject;
  125674. };
  125675. // Type definitions for WebVR API
  125676. // Project: https://w3c.github.io/webvr/
  125677. // Definitions by: six a <https://github.com/lostfictions>
  125678. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  125679. interface VRDisplay extends EventTarget {
  125680. /**
  125681. * Dictionary of capabilities describing the VRDisplay.
  125682. */
  125683. readonly capabilities: VRDisplayCapabilities;
  125684. /**
  125685. * z-depth defining the far plane of the eye view frustum
  125686. * enables mapping of values in the render target depth
  125687. * attachment to scene coordinates. Initially set to 10000.0.
  125688. */
  125689. depthFar: number;
  125690. /**
  125691. * z-depth defining the near plane of the eye view frustum
  125692. * enables mapping of values in the render target depth
  125693. * attachment to scene coordinates. Initially set to 0.01.
  125694. */
  125695. depthNear: number;
  125696. /**
  125697. * An identifier for this distinct VRDisplay. Used as an
  125698. * association point in the Gamepad API.
  125699. */
  125700. readonly displayId: number;
  125701. /**
  125702. * A display name, a user-readable name identifying it.
  125703. */
  125704. readonly displayName: string;
  125705. readonly isConnected: boolean;
  125706. readonly isPresenting: boolean;
  125707. /**
  125708. * If this VRDisplay supports room-scale experiences, the optional
  125709. * stage attribute contains details on the room-scale parameters.
  125710. */
  125711. readonly stageParameters: VRStageParameters | null;
  125712. /**
  125713. * Passing the value returned by `requestAnimationFrame` to
  125714. * `cancelAnimationFrame` will unregister the callback.
  125715. * @param handle Define the hanle of the request to cancel
  125716. */
  125717. cancelAnimationFrame(handle: number): void;
  125718. /**
  125719. * Stops presenting to the VRDisplay.
  125720. * @returns a promise to know when it stopped
  125721. */
  125722. exitPresent(): Promise<void>;
  125723. /**
  125724. * Return the current VREyeParameters for the given eye.
  125725. * @param whichEye Define the eye we want the parameter for
  125726. * @returns the eye parameters
  125727. */
  125728. getEyeParameters(whichEye: string): VREyeParameters;
  125729. /**
  125730. * Populates the passed VRFrameData with the information required to render
  125731. * the current frame.
  125732. * @param frameData Define the data structure to populate
  125733. * @returns true if ok otherwise false
  125734. */
  125735. getFrameData(frameData: VRFrameData): boolean;
  125736. /**
  125737. * Get the layers currently being presented.
  125738. * @returns the list of VR layers
  125739. */
  125740. getLayers(): VRLayer[];
  125741. /**
  125742. * Return a VRPose containing the future predicted pose of the VRDisplay
  125743. * when the current frame will be presented. The value returned will not
  125744. * change until JavaScript has returned control to the browser.
  125745. *
  125746. * The VRPose will contain the position, orientation, velocity,
  125747. * and acceleration of each of these properties.
  125748. * @returns the pose object
  125749. */
  125750. getPose(): VRPose;
  125751. /**
  125752. * Return the current instantaneous pose of the VRDisplay, with no
  125753. * prediction applied.
  125754. * @returns the current instantaneous pose
  125755. */
  125756. getImmediatePose(): VRPose;
  125757. /**
  125758. * The callback passed to `requestAnimationFrame` will be called
  125759. * any time a new frame should be rendered. When the VRDisplay is
  125760. * presenting the callback will be called at the native refresh
  125761. * rate of the HMD. When not presenting this function acts
  125762. * identically to how window.requestAnimationFrame acts. Content should
  125763. * make no assumptions of frame rate or vsync behavior as the HMD runs
  125764. * asynchronously from other displays and at differing refresh rates.
  125765. * @param callback Define the eaction to run next frame
  125766. * @returns the request handle it
  125767. */
  125768. requestAnimationFrame(callback: FrameRequestCallback): number;
  125769. /**
  125770. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  125771. * Repeat calls while already presenting will update the VRLayers being displayed.
  125772. * @param layers Define the list of layer to present
  125773. * @returns a promise to know when the request has been fulfilled
  125774. */
  125775. requestPresent(layers: VRLayer[]): Promise<void>;
  125776. /**
  125777. * Reset the pose for this display, treating its current position and
  125778. * orientation as the "origin/zero" values. VRPose.position,
  125779. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  125780. * updated when calling resetPose(). This should be called in only
  125781. * sitting-space experiences.
  125782. */
  125783. resetPose(): void;
  125784. /**
  125785. * The VRLayer provided to the VRDisplay will be captured and presented
  125786. * in the HMD. Calling this function has the same effect on the source
  125787. * canvas as any other operation that uses its source image, and canvases
  125788. * created without preserveDrawingBuffer set to true will be cleared.
  125789. * @param pose Define the pose to submit
  125790. */
  125791. submitFrame(pose?: VRPose): void;
  125792. }
  125793. declare var VRDisplay: {
  125794. prototype: VRDisplay;
  125795. new(): VRDisplay;
  125796. };
  125797. interface VRLayer {
  125798. leftBounds?: number[] | Float32Array | null;
  125799. rightBounds?: number[] | Float32Array | null;
  125800. source?: HTMLCanvasElement | null;
  125801. }
  125802. interface VRDisplayCapabilities {
  125803. readonly canPresent: boolean;
  125804. readonly hasExternalDisplay: boolean;
  125805. readonly hasOrientation: boolean;
  125806. readonly hasPosition: boolean;
  125807. readonly maxLayers: number;
  125808. }
  125809. interface VREyeParameters {
  125810. /** @deprecated */
  125811. readonly fieldOfView: VRFieldOfView;
  125812. readonly offset: Float32Array;
  125813. readonly renderHeight: number;
  125814. readonly renderWidth: number;
  125815. }
  125816. interface VRFieldOfView {
  125817. readonly downDegrees: number;
  125818. readonly leftDegrees: number;
  125819. readonly rightDegrees: number;
  125820. readonly upDegrees: number;
  125821. }
  125822. interface VRFrameData {
  125823. readonly leftProjectionMatrix: Float32Array;
  125824. readonly leftViewMatrix: Float32Array;
  125825. readonly pose: VRPose;
  125826. readonly rightProjectionMatrix: Float32Array;
  125827. readonly rightViewMatrix: Float32Array;
  125828. readonly timestamp: number;
  125829. }
  125830. interface VRPose {
  125831. readonly angularAcceleration: Float32Array | null;
  125832. readonly angularVelocity: Float32Array | null;
  125833. readonly linearAcceleration: Float32Array | null;
  125834. readonly linearVelocity: Float32Array | null;
  125835. readonly orientation: Float32Array | null;
  125836. readonly position: Float32Array | null;
  125837. readonly timestamp: number;
  125838. }
  125839. interface VRStageParameters {
  125840. sittingToStandingTransform?: Float32Array;
  125841. sizeX?: number;
  125842. sizeY?: number;
  125843. }
  125844. interface Navigator {
  125845. getVRDisplays(): Promise<VRDisplay[]>;
  125846. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  125847. }
  125848. interface Window {
  125849. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  125850. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  125851. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  125852. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  125853. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  125854. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  125855. }
  125856. interface Gamepad {
  125857. readonly displayId: number;
  125858. }
  125859. type XRSessionMode =
  125860. | "inline"
  125861. | "immersive-vr"
  125862. | "immersive-ar";
  125863. type XRReferenceSpaceType =
  125864. | "viewer"
  125865. | "local"
  125866. | "local-floor"
  125867. | "bounded-floor"
  125868. | "unbounded";
  125869. type XREnvironmentBlendMode =
  125870. | "opaque"
  125871. | "additive"
  125872. | "alpha-blend";
  125873. type XRVisibilityState =
  125874. | "visible"
  125875. | "visible-blurred"
  125876. | "hidden";
  125877. type XRHandedness =
  125878. | "none"
  125879. | "left"
  125880. | "right";
  125881. type XRTargetRayMode =
  125882. | "gaze"
  125883. | "tracked-pointer"
  125884. | "screen";
  125885. type XREye =
  125886. | "none"
  125887. | "left"
  125888. | "right";
  125889. interface XRSpace extends EventTarget {
  125890. }
  125891. interface XRRenderState {
  125892. depthNear?: number;
  125893. depthFar?: number;
  125894. inlineVerticalFieldOfView?: number;
  125895. baseLayer?: XRWebGLLayer;
  125896. }
  125897. interface XRInputSource {
  125898. handedness: XRHandedness;
  125899. targetRayMode: XRTargetRayMode;
  125900. targetRaySpace: XRSpace;
  125901. gripSpace: XRSpace | undefined;
  125902. gamepad: Gamepad | undefined;
  125903. profiles: Array<string>;
  125904. }
  125905. interface XRSession {
  125906. addEventListener: Function;
  125907. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125908. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  125909. requestAnimationFrame: Function;
  125910. end(): Promise<void>;
  125911. renderState: XRRenderState;
  125912. inputSources: Array<XRInputSource>;
  125913. }
  125914. interface XRReferenceSpace extends XRSpace {
  125915. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  125916. onreset: any;
  125917. }
  125918. interface XRFrame {
  125919. session: XRSession;
  125920. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  125921. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  125922. }
  125923. interface XRViewerPose extends XRPose {
  125924. views: Array<XRView>;
  125925. }
  125926. interface XRPose {
  125927. transform: XRRigidTransform;
  125928. emulatedPosition: boolean;
  125929. }
  125930. declare var XRWebGLLayer: {
  125931. prototype: XRWebGLLayer;
  125932. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  125933. };
  125934. interface XRWebGLLayer {
  125935. framebuffer: WebGLFramebuffer;
  125936. framebufferWidth: number;
  125937. framebufferHeight: number;
  125938. getViewport: Function;
  125939. }
  125940. interface XRRigidTransform {
  125941. position: DOMPointReadOnly;
  125942. orientation: DOMPointReadOnly;
  125943. matrix: Float32Array;
  125944. inverse: XRRigidTransform;
  125945. }
  125946. interface XRView {
  125947. eye: XREye;
  125948. projectionMatrix: Float32Array;
  125949. transform: XRRigidTransform;
  125950. }
  125951. interface XRInputSourceChangeEvent {
  125952. session: XRSession;
  125953. removed: Array<XRInputSource>;
  125954. added: Array<XRInputSource>;
  125955. }